src/Contao/View/Contao2BackendView/Subscriber/MultipleHandlerSubscriber.php
public function handleOriginalWidget(BuildWidgetEvent $event)
    {
        $environment = $event->getEnvironment();

        if (!$this->scopeDeterminator->currentScopeIsBackend()
            || ('select' !== $environment->getInputProvider()->getParameter('act'))
            || ('edit' !== $environment->getInputProvider()->getParameter('select'))
        ) {
            return;
        }

        $properties = $environment->getDataDefinition()->getPropertiesDefinition();

        $this->findModelIdByPropertyName($event);

        $model   = $event->getModel();
        $modelId = ModelId::fromModel($model);

        $originalPropertyName = $this->getOriginalPropertyName($event->getProperty()->getName(), $modelId);
        if ((null === $originalPropertyName)
            || ((null !== $originalPropertyName) && (false === $properties->hasProperty($originalPropertyName)))
        ) {
            return;
        }

        $originalProperty = $properties->getProperty($originalPropertyName);

        $originalExtra = $copiedExtra = $originalProperty->getExtra();

        if (!empty($originalExtra['orderField'])) {
            $orderId = \str_replace('::', '____', $modelId->getSerialized()) . '_' . $copiedExtra['orderField'];

            $copiedExtra['orderField'] = $orderId;

            $isChanged = $model->getMeta($model::IS_CHANGED);
            $model->setProperty($orderId, $model->getProperty($originalExtra['orderField']));
            $model->setMeta($model::IS_CHANGED, $isChanged);
        }

        $originalProperty->setExtra($copiedExtra);

        $originalEvent =
            new BuildWidgetEvent($environment, $model, $originalProperty);

        $environment->getEventDispatcher()->dispatch(BuildWidgetEvent::NAME, $originalEvent);

        $originalEvent->getWidget()->id   = $event->getProperty()->getName();
        $originalEvent->getWidget()->name =
            \str_replace('::', '____', $modelId->getSerialized()) . '_[' . $originalPropertyName . ']';

        $originalEvent->getWidget()->tl_class = '';

        $event->setWidget($originalEvent->getWidget());

        $originalProperty->setExtra($originalExtra);

        $event->stopPropagation();
    }
public function handleOriginalWidget(BuildWidgetEvent $event)
    {
        $environment = $event->getEnvironment();

        if (!$this->scopeDeterminator->currentScopeIsBackend()
            || ('select' !== $environment->getInputProvider()->getParameter('act'))
            || ('edit' !== $environment->getInputProvider()->getParameter('select'))
        ) {
            return;
        }

        $properties = $environment->getDataDefinition()->getPropertiesDefinition();

        $this->findModelIdByPropertyName($event);

        $model   = $event->getModel();
        $modelId = ModelId::fromModel($model);

        $originalPropertyName = $this->getOriginalPropertyName($event->getProperty()->getName(), $modelId);
        if ((null === $originalPropertyName)
            || ((null !== $originalPropertyName) && (false === $properties->hasProperty($originalPropertyName)))
        ) {
            return;
        }

        $originalProperty = $properties->getProperty($originalPropertyName);

        $originalExtra = $copiedExtra = $originalProperty->getExtra();

        if (!empty($originalExtra['orderField'])) {
            $orderId = \str_replace('::', '____', $modelId->getSerialized()) . '_' . $copiedExtra['orderField'];

            $copiedExtra['orderField'] = $orderId;

            $isChanged = $model->getMeta($model::IS_CHANGED);
            $model->setProperty($orderId, $model->getProperty($originalExtra['orderField']));
            $model->setMeta($model::IS_CHANGED, $isChanged);
        }

        $originalProperty->setExtra($copiedExtra);

        $originalEvent =
            new BuildWidgetEvent($environment, $model, $originalProperty);

        $environment->getEventDispatcher()->dispatch(BuildWidgetEvent::NAME, $originalEvent);

        $originalEvent->getWidget()->id   = $event->getProperty()->getName();
        $originalEvent->getWidget()->name =
            \str_replace('::', '____', $modelId->getSerialized()) . '_[' . $originalPropertyName . ']';

        $originalEvent->getWidget()->tl_class = '';

        $event->setWidget($originalEvent->getWidget());

        $originalProperty->setExtra($originalExtra);

        $event->stopPropagation();
    }
public function handleOriginalWidget ( BuildWidgetEvent $ event ) { $ environment = $ event -> getEnvironment ( ) ; if ( ! $ this -> scopeDeterminator -> currentScopeIsBackend ( ) || ( 'select' !== $ environment -> getInputProvider ( ) -> getParameter ( 'act' ) ) || ( 'edit' !== $ environment -> getInputProvider ( ) -> getParameter ( 'select' ) ) ) { return ; } $ properties = $ environment -> getDataDefinition ( ) -> getPropertiesDefinition ( ) ; $ this -> findModelIdByPropertyName ( $ event ) ; $ model = $ event -> getModel ( ) ; $ modelId = ModelId :: fromModel ( $ model ) ; $ originalPropertyName = $ this -> getOriginalPropertyName ( $ event -> getProperty ( ) -> getName ( ) , $ modelId ) ; if ( ( null === $ originalPropertyName ) || ( ( null !== $ originalPropertyName ) && ( false === $ properties -> hasProperty ( $ originalPropertyName ) ) ) ) { return ; } $ originalProperty = $ properties -> getProperty ( $ originalPropertyName ) ; $ originalExtra = $ copiedExtra = $ originalProperty -> getExtra ( ) ; if ( ! empty ( $ originalExtra [ 'orderField' ] ) ) { $ orderId = \ str_replace ( '::' , '____' , $ modelId -> getSerialized ( ) ) . '_' . $ copiedExtra [ 'orderField' ] ; $ copiedExtra [ 'orderField' ] = $ orderId ; $ isChanged = $ model -> getMeta ( $ model :: IS_CHANGED ) ; $ model -> setProperty ( $ orderId , $ model -> getProperty ( $ originalExtra [ 'orderField' ] ) ) ; $ model -> setMeta ( $ model :: IS_CHANGED , $ isChanged ) ; } $ originalProperty -> setExtra ( $ copiedExtra ) ; $ originalEvent = new BuildWidgetEvent ( $ environment , $ model , $ originalProperty ) ; $ environment -> getEventDispatcher ( ) -> dispatch ( BuildWidgetEvent :: NAME , $ originalEvent ) ; $ originalEvent -> getWidget ( ) -> id = $ event -> getProperty ( ) -> getName ( ) ; $ originalEvent -> getWidget ( ) -> name = \ str_replace ( '::' , '____' , $ modelId -> getSerialized ( ) ) . '_[' . $ originalPropertyName . ']' ; $ originalEvent -> getWidget ( ) -> tl_class = '' ; $ event -> setWidget ( $ originalEvent -> getWidget ( ) ) ; $ originalProperty -> setExtra ( $ originalExtra ) ; $ event -> stopPropagation ( ) ; }
Handle the original widget.

@param BuildWidgetEvent $event The build widget event.

@return void
Handle the original widget .