src/CoreBundle/EventListener/DcGeneral/Table/MetaModel/LanguageArrayListener.php
public function handleEncode(EncodePropertyValueFromWidgetEvent $event)
    {
        if (!$this->wantToHandle($event) || ($event->getProperty() !== 'languages')) {
            return;
        }

        $langValues  = (array) $event->getValue();
        $hasFallback = false;
        $output      = [];
        foreach ($langValues as $subValue) {
            $langCode = $subValue['langcode'];
            unset($subValue['langcode']);

            // We clear all subsequent fallbacks after we have found one.
            if ($hasFallback) {
                $subValue['isfallback'] = '';
            }

            if ($subValue['isfallback']) {
                $hasFallback = true;
            }

            $output[$langCode] = $subValue;
        }

        // If no fallback has been set, use the first language available.
        if ((!$hasFallback) && count($output)) {
            $output[$langValues[0]['langcode']]['isfallback'] = '1';
        }

        $event->setValue($output);
    }
public function handleEncode(EncodePropertyValueFromWidgetEvent $event)
    {
        if (!$this->wantToHandle($event) || ($event->getProperty() !== 'languages')) {
            return;
        }

        $langValues  = (array) $event->getValue();
        $hasFallback = false;
        $output      = [];
        foreach ($langValues as $subValue) {
            $langCode = $subValue['langcode'];
            unset($subValue['langcode']);

            // We clear all subsequent fallbacks after we have found one.
            if ($hasFallback) {
                $subValue['isfallback'] = '';
            }

            if ($subValue['isfallback']) {
                $hasFallback = true;
            }

            $output[$langCode] = $subValue;
        }

        // If no fallback has been set, use the first language available.
        if ((!$hasFallback) && count($output)) {
            $output[$langValues[0]['langcode']]['isfallback'] = '1';
        }

        $event->setValue($output);
    }
public function handleEncode ( EncodePropertyValueFromWidgetEvent $ event ) { if ( ! $ this -> wantToHandle ( $ event ) || ( $ event -> getProperty ( ) !== 'languages' ) ) { return ; } $ langValues = ( array ) $ event -> getValue ( ) ; $ hasFallback = false ; $ output = [ ] ; foreach ( $ langValues as $ subValue ) { $ langCode = $ subValue [ 'langcode' ] ; unset ( $ subValue [ 'langcode' ] ) ; // We clear all subsequent fallbacks after we have found one. if ( $ hasFallback ) { $ subValue [ 'isfallback' ] = '' ; } if ( $ subValue [ 'isfallback' ] ) { $ hasFallback = true ; } $ output [ $ langCode ] = $ subValue ; } // If no fallback has been set, use the first language available. if ( ( ! $ hasFallback ) && count ( $ output ) ) { $ output [ $ langValues [ 0 ] [ 'langcode' ] ] [ 'isfallback' ] = '1' ; } $ event -> setValue ( $ output ) ; }
Decode a language array.

@param EncodePropertyValueFromWidgetEvent $event The event.

@return void
Decode a language array .