protected function buildTypePropertiesMapping(EntityTypeDefinition $type_definition)
 {
     $type_properties = [];
     foreach ($type_definition->getAttributes() as $attribute) {
         $handler_function = sprintf('map%s', implode('', array_map('ucfirst', explode('-', $attribute->getShortName()))));
         if (is_callable(array($this, $handler_function))) {
             $mapping = $this->{$handler_function}($attribute->getName(), $attribute, $type_definition);
             if (!empty($mapping)) {
                 $type_properties[$attribute->getName()] = $mapping;
             }
         }
     }
     return $type_properties;
 }
Example #2
0
 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;
 }