Created
May 15, 2017 20:53
-
-
Save stefanheimes/e0e3d8f9c0a51438b2f344a2170a5c4d to your computer and use it in GitHub Desktop.
Bugfix MCW
This file contains hidden or 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
<?php | |
use ContaoCommunityAlliance\DcGeneral\DataDefinition\Definition\Properties\DefaultProperty; | |
use ContaoCommunityAlliance\DcGeneral\Factory\Event\BuildDataDefinitionEvent; | |
return array | |
( | |
BuildDataDefinitionEvent::NAME => array( | |
array( | |
function (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(); | |
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' => &$subProperty['reference']) | |
) | |
); | |
break; | |
default: | |
} | |
} | |
// Add all to the current list. | |
$properties->addProperty($subProperty); | |
} | |
} | |
}, | |
-500000 | |
) | |
), | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment