You are here

public function EntityFlagTypeDeriver::getDerivativeDefinitions in Flag 8.4

Gets the definition of all derivatives of a base plugin.

Parameters

array $base_plugin_definition: The definition array of the base plugin.

Return value

array An array of full derivative definitions keyed on derivative id.

Overrides DeriverBase::getDerivativeDefinitions

See also

getDerivativeDefinition()

File

src/Plugin/Derivative/EntityFlagTypeDeriver.php, line 16

Class

EntityFlagTypeDeriver
Derivative class for entity flag type plugin.

Namespace

Drupal\flag\Plugin\Derivative

Code

public function getDerivativeDefinitions($base_plugin_def) {
  $derivatives = [];
  foreach (\Drupal::entityTypeManager()
    ->getDefinitions() as $entity_id => $entity_type) {

    // Skip config entity types.
    if (!$entity_type instanceof ContentEntityTypeInterface) {
      continue;
    }
    $derivatives[$entity_id] = [
      'title' => $entity_type
        ->getLabel(),
      'entity_type' => $entity_id,
      'config_dependencies' => [
        'module' => [
          $entity_type
            ->getProvider(),
        ],
      ],
    ] + $base_plugin_def;
  }
  return $derivatives;
}