public function testRemoveExistingEntity() { $type = new ArticleType(); $test_entity = $type->createEntity(['uuid' => '2d10d19a-7aca-4d87-aa34-1ea9a5604138']); $map = new EntityMap([$test_entity]); $this->assertNull($map->removeItem($test_entity)); }
/** * Collate nested entities according to the given predicate and index by embed path * * @param Closure $criteria * @param boolean $recursive * @return EntityMap */ 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; }