MetaModels\DcGeneral\Events\Table\RenderSettings\Subscriber::decodeJumpToValue PHP Method

decodeJumpToValue() public method

Translates the values of the jumpTo entries into the real array.
public decodeJumpToValue ( ContaoCommunityAlliance\DcGeneral\Contao\View\Contao2BackendView\Event\DecodePropertyValueForWidgetEvent $event ) : void
$event ContaoCommunityAlliance\DcGeneral\Contao\View\Contao2BackendView\Event\DecodePropertyValueForWidgetEvent The event.
return void
    public function decodeJumpToValue(DecodePropertyValueForWidgetEvent $event)
    {
        if ($event->getEnvironment()->getDataDefinition()->getName() !== 'tl_metamodel_rendersettings' || $event->getProperty() !== 'jumpTo') {
            return;
        }
        $propInfo = $event->getEnvironment()->getDataDefinition()->getPropertiesDefinition()->getProperty($event->getProperty());
        $value = deserialize($event->getValue(), true);
        if (!$value) {
            return;
        }
        $extra = $propInfo->getExtra();
        $newValues = array();
        $arrLanguages = $extra['columnFields']['langcode']['options'];
        foreach (array_keys($arrLanguages) as $key) {
            $newValue = '';
            $intFilter = 0;
            if ($value) {
                foreach ($value as $arr) {
                    if (!is_array($arr)) {
                        break;
                    }
                    // Set the new value and exit the loop.
                    if (array_search($key, $arr) !== false) {
                        $newValue = '{{link_url::' . $arr['value'] . '}}';
                        $intFilter = $arr['filter'];
                        break;
                    }
                }
            }
            // Build the new array.
            $newValues[] = array('langcode' => $key, 'value' => $newValue, 'filter' => $intFilter);
        }
        $event->setValue($newValues);
    }