src/Controller/ModelCollector.php
public function searchParentOfIn(ModelInterface $model, CollectionInterface $models)
    {
        foreach ($models as $candidate) {
            /** @var ModelInterface $candidate */
            foreach ($this->relationships->getChildConditions($candidate->getProviderName()) as $condition) {
                if ($condition->matches($candidate, $model)) {
                    return $candidate;
                }

                $provider = $this->environment->getDataProvider($condition->getDestinationName());
                $config   = $provider->getEmptyConfig()->setFilter($condition->getFilter($candidate));
                $result   = $this->searchParentOfIn($model, $provider->fetchAll($config));
                if (null !== $result) {
                    return $result;
                }
            }
        }

        return null;
    }
public function searchParentOfIn(ModelInterface $model, CollectionInterface $models)
    {
        foreach ($models as $candidate) {
            /** @var ModelInterface $candidate */
            foreach ($this->relationships->getChildConditions($candidate->getProviderName()) as $condition) {
                if ($condition->matches($candidate, $model)) {
                    return $candidate;
                }

                $provider = $this->environment->getDataProvider($condition->getDestinationName());
                $config   = $provider->getEmptyConfig()->setFilter($condition->getFilter($candidate));
                $result   = $this->searchParentOfIn($model, $provider->fetchAll($config));
                if (null !== $result) {
                    return $result;
                }
            }
        }

        return null;
    }
public function searchParentOfIn ( ModelInterface $ model , CollectionInterface $ models ) { foreach ( $ models as $ candidate ) { /** @var ModelInterface $candidate */ foreach ( $ this -> relationships -> getChildConditions ( $ candidate -> getProviderName ( ) ) as $ condition ) { if ( $ condition -> matches ( $ candidate , $ model ) ) { return $ candidate ; } $ provider = $ this -> environment -> getDataProvider ( $ condition -> getDestinationName ( ) ) ; $ config = $ provider -> getEmptyConfig ( ) -> setFilter ( $ condition -> getFilter ( $ candidate ) ) ; $ result = $ this -> searchParentOfIn ( $ model , $ provider -> fetchAll ( $ config ) ) ; if ( null !== $ result ) { return $ result ; } } } return null ; }
Search the parent of the passed model in the passed collection.

This recursively tries to load the parent from sub collections in sub providers.

@param ModelInterface      $model  The model to search the parent for.
@param CollectionInterface $models The collection to search in.

@return ModelInterface
Search the parent of the passed model in the passed collection .