protected function insertParents($entity, array $path, array $parents)
    {
        $propertyName = reset($path);
        $propertyValue = Core::get()->getObjectService()->getObjectProperty($entity, $propertyName);

        if (1 === count($path)) {
            if (is_object($propertyValue)
                && Core::get()->getParentsUtility()->classUsesParentsTrait($propertyValue)
            ) {
                /** @var ParentsTrait $propertyValue */
                $propertyValue->attachParents($this->filterParents($parents));
            }
        } else {
            if (is_object($propertyValue)) {
                $parents[] = $propertyValue;
            }

            array_shift($path);
            $this->insertParents($propertyValue, $path, $parents);
        }
    }
protected function insertParents($entity, array $path, array $parents)
    {
        $propertyName = reset($path);
        $propertyValue = Core::get()->getObjectService()->getObjectProperty($entity, $propertyName);

        if (1 === count($path)) {
            if (is_object($propertyValue)
                && Core::get()->getParentsUtility()->classUsesParentsTrait($propertyValue)
            ) {
                /** @var ParentsTrait $propertyValue */
                $propertyValue->attachParents($this->filterParents($parents));
            }
        } else {
            if (is_object($propertyValue)) {
                $parents[] = $propertyValue;
            }

            array_shift($path);
            $this->insertParents($propertyValue, $path, $parents);
        }
    }
protected function insertParents ( $ entity , array $ path , array $ parents ) { $ propertyName = reset ( $ path ) ; $ propertyValue = Core :: get ( ) -> getObjectService ( ) -> getObjectProperty ( $ entity , $ propertyName ) ; if ( 1 === count ( $ path ) ) { if ( is_object ( $ propertyValue ) && Core :: get ( ) -> getParentsUtility ( ) -> classUsesParentsTrait ( $ propertyValue ) ) { /** @var ParentsTrait $propertyValue */ $ propertyValue -> attachParents ( $ this -> filterParents ( $ parents ) ) ; } } else { if ( is_object ( $ propertyValue ) ) { $ parents [ ] = $ propertyValue ; } array_shift ( $ path ) ; $ this -> insertParents ( $ propertyValue , $ path , $ parents ) ; } }
Internal function to fill the parents.

@param mixed    $entity
@param array    $path
@param object[] $parents
Internal function to fill the parents .