You are here

public function JuiceboxConfFieldContextualLinks::getDerivativeDefinitions in Juicebox HTML5 Responsive Image Galleries 8.3

Same name and namespace in other branches
  1. 8.2 src/Plugin/Derivative/JuiceboxConfFieldContextualLinks.php \Drupal\juicebox\Plugin\Derivative\JuiceboxConfFieldContextualLinks::getDerivativeDefinitions()

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/JuiceboxConfFieldContextualLinks.php, line 55

Class

JuiceboxConfFieldContextualLinks
Provides dynamic contextual links for Juicebox field conf editing.

Namespace

Drupal\juicebox\Plugin\Derivative

Code

public function getDerivativeDefinitions($base_plugin_definition) {

  // We need a contextual link defined for each entity type (that may contain
  // a Juicebox gallery) in order to provide a link to the relevant edit
  // display screen. These link definitions must be unique because the related
  // route to the edit display screen is different for each entity type.
  foreach ($this->entityTypeManager
    ->getDefinitions() as $entity_type_id => $entity_type) {

    // Only fieldable entity are candidates.
    if ($entity_type
      ->isSubclassOf('\\Drupal\\Core\\Entity\\ContentEntityInterface')) {
      $bundle_entity_type = $entity_type
        ->getBundleEntityType();
      $this->derivatives['juicebox.conf_field_' . $entity_type_id]['title'] = $this
        ->t('Configure galleries of this field instance');
      $this->derivatives['juicebox.conf_field_' . $entity_type_id]['route_name'] = 'entity.entity_view_display.' . $entity_type_id . '.view_mode';
      $this->derivatives['juicebox.conf_field_' . $entity_type_id]['group'] = 'juicebox_conf_field_' . $entity_type_id;
    }
  }
  return parent::getDerivativeDefinitions($base_plugin_definition);
}