src/Contao/Subscriber/FallbackResetSubscriber.php
private function determineFilterConfig(AbstractModelAwareEvent $event)
    {
        $environment  = $event->getEnvironment();
        $model        = $event->getModel();
        $dataProvider = $environment->getDataProvider($model->getProviderName());
        $definition   = $environment->getDataDefinition();
        $relationship = $definition->getModelRelationshipDefinition();

        $root = $relationship->getRootCondition();
        if (null !== $root && $root->matches($model)) {
            return $dataProvider->getEmptyConfig()->setFilter($root->getFilterArray());
        }

        $parentFilter = $relationship->getChildCondition(
            $definition->getBasicDefinition()->getParentDataProvider(),
            $model->getProviderName()
        );

        if (null !== $parentFilter) {
            $parentConfig   = $dataProvider->getEmptyConfig()->setFilter($parentFilter->getInverseFilterFor($model));
            $parentProvider = $environment->getDataProvider($parentFilter->getSourceName());
            $parent         = $parentProvider->fetchAll($parentConfig)->get(0);
            return $dataProvider->getEmptyConfig()->setFilter($parentFilter->getFilter($parent));
        }

        // Trigger BC layer in handleFallback().
        if ((null === $root) && (0 === \count($relationship->getChildConditions()))) {
            return null;
        }

        return $dataProvider->getEmptyConfig();
    }
private function determineFilterConfig(AbstractModelAwareEvent $event)
    {
        $environment  = $event->getEnvironment();
        $model        = $event->getModel();
        $dataProvider = $environment->getDataProvider($model->getProviderName());
        $definition   = $environment->getDataDefinition();
        $relationship = $definition->getModelRelationshipDefinition();

        $root = $relationship->getRootCondition();
        if (null !== $root && $root->matches($model)) {
            return $dataProvider->getEmptyConfig()->setFilter($root->getFilterArray());
        }

        $parentFilter = $relationship->getChildCondition(
            $definition->getBasicDefinition()->getParentDataProvider(),
            $model->getProviderName()
        );

        if (null !== $parentFilter) {
            $parentConfig   = $dataProvider->getEmptyConfig()->setFilter($parentFilter->getInverseFilterFor($model));
            $parentProvider = $environment->getDataProvider($parentFilter->getSourceName());
            $parent         = $parentProvider->fetchAll($parentConfig)->get(0);
            return $dataProvider->getEmptyConfig()->setFilter($parentFilter->getFilter($parent));
        }

        // Trigger BC layer in handleFallback().
        if ((null === $root) && (0 === \count($relationship->getChildConditions()))) {
            return null;
        }

        return $dataProvider->getEmptyConfig();
    }
private function determineFilterConfig ( AbstractModelAwareEvent $ event ) { $ environment = $ event -> getEnvironment ( ) ; $ model = $ event -> getModel ( ) ; $ dataProvider = $ environment -> getDataProvider ( $ model -> getProviderName ( ) ) ; $ definition = $ environment -> getDataDefinition ( ) ; $ relationship = $ definition -> getModelRelationshipDefinition ( ) ; $ root = $ relationship -> getRootCondition ( ) ; if ( null !== $ root && $ root -> matches ( $ model ) ) { return $ dataProvider -> getEmptyConfig ( ) -> setFilter ( $ root -> getFilterArray ( ) ) ; } $ parentFilter = $ relationship -> getChildCondition ( $ definition -> getBasicDefinition ( ) -> getParentDataProvider ( ) , $ model -> getProviderName ( ) ) ; if ( null !== $ parentFilter ) { $ parentConfig = $ dataProvider -> getEmptyConfig ( ) -> setFilter ( $ parentFilter -> getInverseFilterFor ( $ model ) ) ; $ parentProvider = $ environment -> getDataProvider ( $ parentFilter -> getSourceName ( ) ) ; $ parent = $ parentProvider -> fetchAll ( $ parentConfig ) -> get ( 0 ) ; return $ dataProvider -> getEmptyConfig ( ) -> setFilter ( $ parentFilter -> getFilter ( $ parent ) ) ; } // Trigger BC layer in handleFallback(). if ( ( null === $ root ) && ( 0 === \ count ( $ relationship -> getChildConditions ( ) ) ) ) { return null ; } return $ dataProvider -> getEmptyConfig ( ) ; }
Determine the filter config to use.

@param AbstractModelAwareEvent $event The event.

@return ConfigInterface|null
Determine the filter config to use .