public function saveValues(EncodePropertyValueFromWidgetEvent $event)
    {
        if (!$this->scopeDeterminator->currentScopeIsBackend()) {
            return;
        }

        if (($event->getEnvironment()->getDataDefinition()->getName() !== 'tl_metamodel_attribute')
            || ($event->getProperty() !== 'translatedtabletext_cols')) {
            return;
        }

        $metaModelName = $this->factory->translateIdToMetaModelName($event->getModel()->getProperty('pid'));
        $objMetaModel  = $this->factory->getMetaModel($metaModelName);
        $varValue      = $event->getValue();

        // Not translated, make it a plain string.
        if (!$objMetaModel->isTranslated()) {
            $event->setValue(\serialize($varValue));

            return;
        }

        $arrLangValues = \deserialize($varValue);
        $arrOutput     = [];

        foreach ($arrLangValues as $varSubValue) {
            $strLangCode = $varSubValue['langcode'];
            unset($varSubValue['langcode']);
            if (\count($varSubValue) > 1) {
                $arrOutput[$strLangCode] = $varSubValue;
            } else {
                $arrKeys = \array_keys($varSubValue);

                $arrOutput[$strLangCode] = $varSubValue[$arrKeys[0]];
            }
        }

        $event->setValue(\serialize($arrOutput));
    }
public function saveValues(EncodePropertyValueFromWidgetEvent $event)
    {
        if (!$this->scopeDeterminator->currentScopeIsBackend()) {
            return;
        }

        if (($event->getEnvironment()->getDataDefinition()->getName() !== 'tl_metamodel_attribute')
            || ($event->getProperty() !== 'translatedtabletext_cols')) {
            return;
        }

        $metaModelName = $this->factory->translateIdToMetaModelName($event->getModel()->getProperty('pid'));
        $objMetaModel  = $this->factory->getMetaModel($metaModelName);
        $varValue      = $event->getValue();

        // Not translated, make it a plain string.
        if (!$objMetaModel->isTranslated()) {
            $event->setValue(\serialize($varValue));

            return;
        }

        $arrLangValues = \deserialize($varValue);
        $arrOutput     = [];

        foreach ($arrLangValues as $varSubValue) {
            $strLangCode = $varSubValue['langcode'];
            unset($varSubValue['langcode']);
            if (\count($varSubValue) > 1) {
                $arrOutput[$strLangCode] = $varSubValue;
            } else {
                $arrKeys = \array_keys($varSubValue);

                $arrOutput[$strLangCode] = $varSubValue[$arrKeys[0]];
            }
        }

        $event->setValue(\serialize($arrOutput));
    }
public function saveValues ( EncodePropertyValueFromWidgetEvent $ event ) { if ( ! $ this -> scopeDeterminator -> currentScopeIsBackend ( ) ) { return ; } if ( ( $ event -> getEnvironment ( ) -> getDataDefinition ( ) -> getName ( ) !== 'tl_metamodel_attribute' ) || ( $ event -> getProperty ( ) !== 'translatedtabletext_cols' ) ) { return ; } $ metaModelName = $ this -> factory -> translateIdToMetaModelName ( $ event -> getModel ( ) -> getProperty ( 'pid' ) ) ; $ objMetaModel = $ this -> factory -> getMetaModel ( $ metaModelName ) ; $ varValue = $ event -> getValue ( ) ; // Not translated, make it a plain string. if ( ! $ objMetaModel -> isTranslated ( ) ) { $ event -> setValue ( \ serialize ( $ varValue ) ) ; return ; } $ arrLangValues = \ deserialize ( $ varValue ) ; $ arrOutput = [ ] ; foreach ( $ arrLangValues as $ varSubValue ) { $ strLangCode = $ varSubValue [ 'langcode' ] ; unset ( $ varSubValue [ 'langcode' ] ) ; if ( \ count ( $ varSubValue ) > 1 ) { $ arrOutput [ $ strLangCode ] = $ varSubValue ; } else { $ arrKeys = \ array_keys ( $ varSubValue ) ; $ arrOutput [ $ strLangCode ] = $ varSubValue [ $ arrKeys [ 0 ] ] ; } } $ event -> setValue ( \ serialize ( $ arrOutput ) ) ; }
Encode the values into a serialized array.

@param EncodePropertyValueFromWidgetEvent $event The event.

@return void
Encode the values into a serialized array .