You are here

public function OgLocalTask::getDerivativeDefinitions in Organic groups 8

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/OgLocalTask.php, line 61

Class

OgLocalTask
Provides local task definitions for all entity bundles.

Namespace

Drupal\og\Plugin\Derivative

Code

public function getDerivativeDefinitions($base_plugin_definition) {
  $derivatives = [];
  foreach (array_keys($this->groupTypeManager
    ->getGroupMap()) as $entity_type_id) {
    $route_name = "entity.{$entity_type_id}.og_admin_routes";
    if (!$this->routProvider
      ->getRoutesByNames([
      $route_name,
    ])) {

      // Route not found.
      continue;
    }
    $derivatives[$entity_type_id . '.og_admin_routes'] = [
      'route_name' => $route_name,
      'title' => $this
        ->t('Group'),
      'base_route' => 'entity.' . $entity_type_id . '.canonical',
      'weight' => 50,
    ];
  }

  // @todo Coder throws a false positive for this line. Remove this once the
  //   issue is fixed in the Coder project.
  // @see https://www.drupal.org/project/coder/issues/3065679
  // @codingStandardsIgnoreLine
  foreach ($derivatives as &$entry) {

    // @codingStandardsIgnoreLine
    $entry += $base_plugin_definition;
  }
  return $derivatives;
}