public function collateChildren(Closure $criteria, $recursive = true)
    {
        $entity_map = new EntityMap;
        $nested_attribute_types = [ EmbeddedEntityListAttribute::CLASS, EntityReferenceListAttribute::CLASS ];
        foreach ($this->getType()->getAttributes([], $nested_attribute_types) as $attribute) {
            foreach ($this->getValue($attribute->getName()) as $child_entity) {
                if ($criteria($child_entity)) {
                    $entity_map->setItem($child_entity->asEmbedPath(), $child_entity);
                }
                if ($recursive) {
                    $entity_map->append($child_entity->collateChildren($criteria));
                }
            }
        }
        return $entity_map;
    }
public function collateChildren(Closure $criteria, $recursive = true)
    {
        $entity_map = new EntityMap;
        $nested_attribute_types = [ EmbeddedEntityListAttribute::CLASS, EntityReferenceListAttribute::CLASS ];
        foreach ($this->getType()->getAttributes([], $nested_attribute_types) as $attribute) {
            foreach ($this->getValue($attribute->getName()) as $child_entity) {
                if ($criteria($child_entity)) {
                    $entity_map->setItem($child_entity->asEmbedPath(), $child_entity);
                }
                if ($recursive) {
                    $entity_map->append($child_entity->collateChildren($criteria));
                }
            }
        }
        return $entity_map;
    }
public function collateChildren ( Closure $ criteria , $ recursive = true ) { $ entity_map = new EntityMap ; $ nested_attribute_types = [ EmbeddedEntityListAttribute :: CLASS , EntityReferenceListAttribute :: CLASS ] ; foreach ( $ this -> getType ( ) -> getAttributes ( [ ] , $ nested_attribute_types ) as $ attribute ) { foreach ( $ this -> getValue ( $ attribute -> getName ( ) ) as $ child_entity ) { if ( $ criteria ( $ child_entity ) ) { $ entity_map -> setItem ( $ child_entity -> asEmbedPath ( ) , $ child_entity ) ; } if ( $ recursive ) { $ entity_map -> append ( $ child_entity -> collateChildren ( $ criteria ) ) ; } } } return $ entity_map ; }
Collate nested entities according to the given predicate and index by embed path

@param Closure $criteria
@param boolean $recursive
@return EntityMap
Collate nested entities according to the given predicate and index by embed path