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

        if (($event->getEnvironment()->getDataDefinition()->getName() !== 'tl_metamodel_attribute')
            || ($event->getProperty() !== 'translatedtabletext_cols')
            || ($event->getEnvironment()->getInputProvider()->getParameter('act') === 'select'
                && !$event->getModel()->getId())
        ) {
            return;
        }

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

        // Check model and input for the cols and get the max value.
        $intModelCols = $event->getModel()->getProperty('tabletext_quantity_cols');
        $intInputCols = $event->getEnvironment()->getInputProvider()->getValue('tabletext_quantity_cols');
        $intCols      = \max((int) $intModelCols, (int) $intInputCols);

        $varValue = $event->getValue();

        // Kick unused lines.
        foreach ((array) $varValue as $strLanguage => $arrRows) {
            if (\count($arrRows) > $intCols) {
                $varValue[$strLanguage] = array_slice($varValue[$strLanguage], 0, $intCols);
            }
        }

        $arrLangValues = \deserialize($varValue);
        if (!$objMetaModel->isTranslated()) {
            // If we have an array, return the first value and exit, if not an array, return the value itself.
            if (\is_array($arrLangValues)) {
                $event->setValue($arrLangValues[\key($arrLangValues)]);
            } else {
                $event->setValue($arrLangValues);
            }

            return;
        }

        $arrOutput = [];
        // Sort like in MetaModel definition.
        if ($arrLanguages) {
            foreach ($arrLanguages as $strLangCode) {
                if (\is_array($arrLangValues)) {
                    $varSubValue = $arrLangValues[$strLangCode];
                } else {
                    $varSubValue = $arrLangValues;
                }

                if (\is_array($varSubValue)) {
                    $arrOutput[] = ['langcode' => $strLangCode, 'rowLabels' => $varSubValue];
                } else {
                    $arrOutput[] = ['langcode' => $strLangCode, 'value' => $varSubValue];
                }
            }
        }

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

        if (($event->getEnvironment()->getDataDefinition()->getName() !== 'tl_metamodel_attribute')
            || ($event->getProperty() !== 'translatedtabletext_cols')
            || ($event->getEnvironment()->getInputProvider()->getParameter('act') === 'select'
                && !$event->getModel()->getId())
        ) {
            return;
        }

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

        // Check model and input for the cols and get the max value.
        $intModelCols = $event->getModel()->getProperty('tabletext_quantity_cols');
        $intInputCols = $event->getEnvironment()->getInputProvider()->getValue('tabletext_quantity_cols');
        $intCols      = \max((int) $intModelCols, (int) $intInputCols);

        $varValue = $event->getValue();

        // Kick unused lines.
        foreach ((array) $varValue as $strLanguage => $arrRows) {
            if (\count($arrRows) > $intCols) {
                $varValue[$strLanguage] = array_slice($varValue[$strLanguage], 0, $intCols);
            }
        }

        $arrLangValues = \deserialize($varValue);
        if (!$objMetaModel->isTranslated()) {
            // If we have an array, return the first value and exit, if not an array, return the value itself.
            if (\is_array($arrLangValues)) {
                $event->setValue($arrLangValues[\key($arrLangValues)]);
            } else {
                $event->setValue($arrLangValues);
            }

            return;
        }

        $arrOutput = [];
        // Sort like in MetaModel definition.
        if ($arrLanguages) {
            foreach ($arrLanguages as $strLangCode) {
                if (\is_array($arrLangValues)) {
                    $varSubValue = $arrLangValues[$strLangCode];
                } else {
                    $varSubValue = $arrLangValues;
                }

                if (\is_array($varSubValue)) {
                    $arrOutput[] = ['langcode' => $strLangCode, 'rowLabels' => $varSubValue];
                } else {
                    $arrOutput[] = ['langcode' => $strLangCode, 'value' => $varSubValue];
                }
            }
        }

        $event->setValue(\serialize($arrOutput));
    }
public function loadValues ( DecodePropertyValueForWidgetEvent $ event ) { if ( ! $ this -> scopeDeterminator -> currentScopeIsBackend ( ) ) { return ; } if ( ( $ event -> getEnvironment ( ) -> getDataDefinition ( ) -> getName ( ) !== 'tl_metamodel_attribute' ) || ( $ event -> getProperty ( ) !== 'translatedtabletext_cols' ) || ( $ event -> getEnvironment ( ) -> getInputProvider ( ) -> getParameter ( 'act' ) === 'select' && ! $ event -> getModel ( ) -> getId ( ) ) ) { return ; } $ metaModelName = $ this -> factory -> translateIdToMetaModelName ( $ event -> getModel ( ) -> getProperty ( 'pid' ) ) ; $ objMetaModel = $ this -> factory -> getMetaModel ( $ metaModelName ) ; $ arrLanguages = $ objMetaModel -> getAvailableLanguages ( ) ; // Check model and input for the cols and get the max value. $ intModelCols = $ event -> getModel ( ) -> getProperty ( 'tabletext_quantity_cols' ) ; $ intInputCols = $ event -> getEnvironment ( ) -> getInputProvider ( ) -> getValue ( 'tabletext_quantity_cols' ) ; $ intCols = \ max ( ( int ) $ intModelCols , ( int ) $ intInputCols ) ; $ varValue = $ event -> getValue ( ) ; // Kick unused lines. foreach ( ( array ) $ varValue as $ strLanguage => $ arrRows ) { if ( \ count ( $ arrRows ) > $ intCols ) { $ varValue [ $ strLanguage ] = array_slice ( $ varValue [ $ strLanguage ] , 0 , $ intCols ) ; } } $ arrLangValues = \ deserialize ( $ varValue ) ; if ( ! $ objMetaModel -> isTranslated ( ) ) { // If we have an array, return the first value and exit, if not an array, return the value itself. if ( \ is_array ( $ arrLangValues ) ) { $ event -> setValue ( $ arrLangValues [ \ key ( $ arrLangValues ) ] ) ; } else { $ event -> setValue ( $ arrLangValues ) ; } return ; } $ arrOutput = [ ] ; // Sort like in MetaModel definition. if ( $ arrLanguages ) { foreach ( $ arrLanguages as $ strLangCode ) { if ( \ is_array ( $ arrLangValues ) ) { $ varSubValue = $ arrLangValues [ $ strLangCode ] ; } else { $ varSubValue = $ arrLangValues ; } if ( \ is_array ( $ varSubValue ) ) { $ arrOutput [ ] = [ 'langcode' => $ strLangCode , 'rowLabels' => $ varSubValue ] ; } else { $ arrOutput [ ] = [ 'langcode' => $ strLangCode , 'value' => $ varSubValue ] ; } } } $ event -> setValue ( \ serialize ( $ arrOutput ) ) ; }
Decode the values into a real table array.

@param DecodePropertyValueForWidgetEvent $event The event.

@return void

@SuppressWarnings(PHPMD.CyclomaticComplexity)
@SuppressWarnings(PHPMD.NPathComplexity)
Decode the values into a real table array .