-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implements a event for adding alls MCW fields to the DCA. This should solve a problem with the fileTree Widget or the pageTree widget. Moved the Event GetOptionsEvent to another folder. Add a new GetOptionsEvent Class under the MCW namespace. Mark the GetOptionsEvent in the MAW namespace as deprecated.
- Loading branch information
1 parent
80d78a9
commit 747bdc7
Showing
6 changed files
with
191 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
system/modules/multicolumnwizard/config/event_listeners.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
|
||
/** | ||
* Contao Open Source CMS | ||
* | ||
* @copyright MEN AT WORK 2017 | ||
* @package MultiColumnWizard | ||
* @license LGPL | ||
* @filesource | ||
*/ | ||
|
||
use ContaoCommunityAlliance\DcGeneral\Factory\Event\BuildDataDefinitionEvent; | ||
This comment has been minimized.
Sorry, something went wrong. |
||
use MultiColumnWizard\DcGeneral\UpdateDataDefinition; | ||
|
||
return array | ||
( | ||
BuildDataDefinitionEvent::NAME => array( | ||
array( | ||
array(new UpdateDataDefinition(), 'addMcwFields'), | ||
UpdateDataDefinition::PRIORITY | ||
) | ||
) | ||
); |
23 changes: 23 additions & 0 deletions
23
system/modules/multicolumnwizard/src/MenAtWork/Event/GetOptionsEvent.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
|
||
/** | ||
* Contao Open Source CMS | ||
* | ||
* @author Christian Schiffler <[email protected]> | ||
* @copyright CyberSpectrum 2014 | ||
* @package MultiColumnWizard | ||
* @license LGPL-3+ | ||
* @filesource | ||
*/ | ||
|
||
namespace MenAtWork\MultiColumnWizard\Event; | ||
|
||
/** | ||
* This event is fired when a MultiColumnWizard wants to retrieve the options for a sub widget in dc-general context. | ||
* | ||
* @deprecated Use the \MultiColumnWizard\Event\GetOptionsEvent class. | ||
*/ | ||
class GetOptionsEvent extends \MultiColumnWizard\Event\GetOptionsEvent | ||
{ | ||
|
||
} |
131 changes: 131 additions & 0 deletions
131
system/modules/multicolumnwizard/src/MultiColumnWizard/DcGeneral/UpdateDataDefinition.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
<?php | ||
|
||
/** | ||
* Contao Open Source CMS | ||
* | ||
* @copyright MEN AT WORK 2017 | ||
* @package MultiColumnWizard | ||
* @license LGPL | ||
* @filesource | ||
*/ | ||
|
||
namespace MultiColumnWizard\DcGeneral; | ||
|
||
use ContaoCommunityAlliance\DcGeneral\DataDefinition\Definition\Properties\DefaultProperty; | ||
use ContaoCommunityAlliance\DcGeneral\Factory\Event\BuildDataDefinitionEvent; | ||
|
||
/** | ||
* Class UpdateDataDefinition | ||
* | ||
* @package MultiColumnWizard\DcGeneral | ||
*/ | ||
class UpdateDataDefinition | ||
{ | ||
const PRIORITY = -500000; | ||
|
||
/** | ||
* Add all fields from the MCW to the DCA. This is needed for some fields, because other components need this | ||
* to create the widget/view etc. | ||
* | ||
* @param BuildDataDefinitionEvent $event | ||
* | ||
* @return void | ||
*/ | ||
function addMcwFields(BuildDataDefinitionEvent $event) | ||
{ | ||
// Get the container and all properties. | ||
$container = $event->getContainer(); | ||
$properties = $container->getPropertiesDefinition(); | ||
|
||
/** @var DefaultProperty $property */ | ||
foreach ($properties as $property) { | ||
// Only run for mcw. | ||
if ('multiColumnWizard' !== $property->getWidgetType()) { | ||
continue; | ||
} | ||
|
||
// Get the extra and make an own field from it. | ||
$config = $property->getExtra(); | ||
|
||
// If we have no data here, go to the next. | ||
if(empty($config['columnFields']) || !is_array($config['columnFields'])){ | ||
continue; | ||
} | ||
|
||
foreach ($config['columnFields'] as $fieldKey => $fieldConfig) { | ||
// Build the default name. | ||
$name = sprintf('%s__%s', $property->getName(), $fieldKey); | ||
|
||
// Make a new field and fill it with the data from the config. | ||
$subProperty = new DefaultProperty($name); | ||
foreach ($fieldConfig as $key => $value) { | ||
switch ($key) { | ||
case 'label': | ||
$subProperty->setLabel($value); | ||
break; | ||
|
||
case 'description': | ||
if (!$subProperty->getDescription()) { | ||
$subProperty->setDescription($value); | ||
} | ||
break; | ||
|
||
case 'default': | ||
if (!$subProperty->getDefaultValue()) { | ||
$subProperty->setDefaultValue($value); | ||
} | ||
break; | ||
|
||
case 'exclude': | ||
$subProperty->setExcluded((bool)$value); | ||
break; | ||
|
||
case 'search': | ||
$subProperty->setSearchable((bool)$value); | ||
break; | ||
|
||
case 'filter': | ||
$subProperty->setFilterable((bool)$value); | ||
break; | ||
|
||
case 'inputType': | ||
$subProperty->setWidgetType($value); | ||
break; | ||
|
||
case 'options': | ||
$subProperty->setOptions($value); | ||
break; | ||
|
||
case 'explanation': | ||
$subProperty->setExplanation($value); | ||
break; | ||
|
||
case 'eval': | ||
$subProperty->setExtra( | ||
array_merge( | ||
(array) $subProperty->getExtra(), | ||
(array) $value | ||
) | ||
); | ||
break; | ||
|
||
case 'reference': | ||
$subProperty->setExtra( | ||
array_merge( | ||
(array) $subProperty->getExtra(), | ||
array('reference' => &$value['reference']) | ||
) | ||
); | ||
break; | ||
|
||
default: | ||
} | ||
} | ||
|
||
// Add all to the current list. | ||
$properties->addProperty($subProperty); | ||
} | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
You've introduced a dependency to DcGeneral here... (MCW > 3.3.10)