protected function parseXpath(DOMXPath $xpath, DOMElement $context) { $embed_definitions_list = new EntityTypeDefinitionList(); $node_list = $xpath->query('//embed_definition', $context); foreach ($node_list as $element) { $embed_type_data = $this->parseEntityTypeDefinition($xpath, $element); $embed_definition = new EmbedDefinition($embed_type_data); $embed_definitions_list->addItem($embed_definition); } return $embed_definitions_list; }
public function getUsedReferenceDefinitions(EntityTypeDefinition $type_definition) { $reference_definitions_list = new EntityTypeDefinitionList(); $reference_attributes = $type_definition->getAttributes()->filterByType('entity-reference-list'); foreach ($reference_attributes as $reference_attribute) { $references_option = $reference_attribute->getOptions()->filterByName('entity_types'); $references = $this->getReferenceDefinitions($references_option->getValue()->toArray()); foreach ($references as $reference) { if (!$reference_definitions_list->hasItem($reference)) { $reference_definitions_list->addItem($reference); } } } $used_embed_types = new EntityTypeDefinitionList(); $embed_type_attributes = $type_definition->getAttributes()->filterByType('embedded-entity-list'); foreach ($embed_type_attributes as $embed_type_attribute) { $embed_typed_types_opt = $embed_type_attribute->getOptions()->filterByName('entity_types'); $embed_types = $this->getEmbedDefinitions($embed_typed_types_opt->getValue()->toArray()); foreach ($embed_types as $embed_type) { if (!$used_embed_types->hasItem($embed_type)) { $used_embed_types->addItem($embed_type); } } } foreach ($used_embed_types as $embed_type) { foreach ($this->getUsedReferenceDefinitions($embed_type) as $reference) { if (!$reference_definitions_list->hasItem($reference)) { $reference_definitions_list->addItem($reference); } } } return $reference_definitions_list; }