You are here

public function QuickFormMenuLink::getDerivativeDefinitions in farmOS 2.x

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

modules/core/quick/src/Plugin/Derivative/QuickFormMenuLink.php, line 47

Class

QuickFormMenuLink
Provides menu links for quick forms.

Namespace

Drupal\farm_quick\Plugin\Derivative

Code

public function getDerivativeDefinitions($base_plugin_definition) {
  $links = [];

  // Load quick forms.
  $quick_forms = $this->quickFormManager
    ->getDefinitions();

  // Add a top level menu parent.
  if (!empty($quick_forms)) {
    $links['farm.quick'] = [
      'title' => 'Quick forms',
      'route_name' => 'farm.quick',
      'weight' => -100,
    ] + $base_plugin_definition;
  }

  // Add a link for each quick form.
  foreach ($quick_forms as $quick_form) {
    $route_id = 'farm.quick.' . $quick_form['id'];
    $links[$route_id] = [
      'title' => $quick_form['label'],
      'parent' => 'farm.quick',
      'route_name' => $route_id,
    ] + $base_plugin_definition;
  }
  return $links;
}