src/Contao/View/Contao2BackendView/Subscriber/MultipleHandlerSubscriber.php
private function findModelIdByPropertyName(BuildWidgetEvent $event)
    {
        if (null !== $event->getModel()->getId()) {
            return;
        }

        $environment    = $event->getEnvironment();
        $dataDefinition = $environment->getDataDefinition();
        $inputProvider  = $environment->getInputProvider();
        $sessionStorage = $environment->getSessionStorage();

        $session = $sessionStorage->get($dataDefinition->getName() . '.' . $inputProvider->getParameter('mode'));

        $model = null;
        foreach ($session['models'] as $sessionModel) {
            $model = $sessionModel;

            if (0 !== \strpos($event->getProperty()->getName(), \str_replace('::', '____', $sessionModel))) {
                continue;
            }

            break;
        }

        $modelId = ModelId::fromSerialized($model);

        $event->getModel()->setId($modelId->getId());
    }
private function findModelIdByPropertyName(BuildWidgetEvent $event)
    {
        if (null !== $event->getModel()->getId()) {
            return;
        }

        $environment    = $event->getEnvironment();
        $dataDefinition = $environment->getDataDefinition();
        $inputProvider  = $environment->getInputProvider();
        $sessionStorage = $environment->getSessionStorage();

        $session = $sessionStorage->get($dataDefinition->getName() . '.' . $inputProvider->getParameter('mode'));

        $model = null;
        foreach ($session['models'] as $sessionModel) {
            $model = $sessionModel;

            if (0 !== \strpos($event->getProperty()->getName(), \str_replace('::', '____', $sessionModel))) {
                continue;
            }

            break;
        }

        $modelId = ModelId::fromSerialized($model);

        $event->getModel()->setId($modelId->getId());
    }
private function findModelIdByPropertyName ( BuildWidgetEvent $ event ) { if ( null !== $ event -> getModel ( ) -> getId ( ) ) { return ; } $ environment = $ event -> getEnvironment ( ) ; $ dataDefinition = $ environment -> getDataDefinition ( ) ; $ inputProvider = $ environment -> getInputProvider ( ) ; $ sessionStorage = $ environment -> getSessionStorage ( ) ; $ session = $ sessionStorage -> get ( $ dataDefinition -> getName ( ) . '.' . $ inputProvider -> getParameter ( 'mode' ) ) ; $ model = null ; foreach ( $ session [ 'models' ] as $ sessionModel ) { $ model = $ sessionModel ; if ( 0 !== \ strpos ( $ event -> getProperty ( ) -> getName ( ) , \ str_replace ( '::' , '____' , $ sessionModel ) ) ) { continue ; } break ; } $ modelId = ModelId :: fromSerialized ( $ model ) ; $ event -> getModel ( ) -> setId ( $ modelId -> getId ( ) ) ; }
Find the model id by property name, if model id not set.

@param BuildWidgetEvent $event The event.

@return void
Find the model id by property name if model id not set .