You are here

public function EntityTraitManager::getDefinitionsByEntityType in Commerce Core 8.2

Gets the definitions filtered by entity type.

Parameters

string $entity_type_id: The entity type id.

Return value

array The definitions.

Overrides EntityTraitManagerInterface::getDefinitionsByEntityType

File

src/EntityTraitManager.php, line 63

Class

EntityTraitManager
Manages discovery and instantiation of entity trait plugins.

Namespace

Drupal\commerce

Code

public function getDefinitionsByEntityType($entity_type_id) {
  $definitions = $this
    ->getDefinitions();
  $definitions = array_filter($definitions, function ($definition) use ($entity_type_id) {
    return empty($definition['entity_types']) || in_array($entity_type_id, $definition['entity_types']);
  });
  return $definitions;
}