MetaModels\DcGeneral\Events\Table\InputScreenCondition\Subscriber::decodeValueValue PHP Method

decodeValueValue() public method

Translates an value to a generated alias to allow numeric values.
public decodeValueValue ( ContaoCommunityAlliance\DcGeneral\Contao\View\Contao2BackendView\Event\DecodePropertyValueForWidgetEvent $event ) : void
$event ContaoCommunityAlliance\DcGeneral\Contao\View\Contao2BackendView\Event\DecodePropertyValueForWidgetEvent The event.
return void
    public function decodeValueValue(DecodePropertyValueForWidgetEvent $event)
    {
        if ($event->getEnvironment()->getDataDefinition()->getName() !== 'tl_metamodel_dcasetting_condition' || $event->getProperty() !== 'value') {
            return;
        }
        if (is_array($event->getValue())) {
            $values = array();
            foreach ($event->getValue() as $value) {
                $values[] = 'value_' . $value;
            }
            // Cut off the 'value_' prefix.
            $event->setValue($values);
        } else {
            $event->setValue('value_' . $event->getValue());
        }
    }