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; }
protected function getWorkflowConfig(EntityTypeDefinition $entity_type_definition) { $vendor_opt = $entity_type_definition->getOptions()->filterByName('vendor'); $package_opt = $entity_type_definition->getOptions()->filterByName('package'); if (!$vendor_opt || !$package_opt) { throw new RuntimeError('Missing vendor- and/or package-option for entity-type: ' . $entity_type_definition->getName()); } return ['name' => sprintf(self::WORKFLOW_NAME_PATTERN, StringToolkit::asSnakeCase($vendor_opt->getValue()), StringToolkit::asSnakeCase($package_opt->getValue()), StringToolkit::asSnakeCase($entity_type_definition->getName())), 'file' => sprintf('/%s_%s/config/%s/workflows.xml', $vendor_opt->getValue(), $package_opt->getValue(), $entity_type_definition->getName())]; }
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; }