You are here

public function EntityBrowserBlockDeriver::getDerivativeDefinitions in Entity Browser Block 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/EntityBrowserBlockDeriver.php, line 45

Class

EntityBrowserBlockDeriver
Retrieves block plugin definitions for all entity browsers.

Namespace

Drupal\entity_browser_block\Plugin\Derivative

Code

public function getDerivativeDefinitions($base_plugin_definition) {

  /** @var \Drupal\entity_browser\EntityBrowserInterface[] $browsers */
  $browsers = $this->browserStorage
    ->loadMultiple();

  // Reset the discovered definitions.
  $this->derivatives = [];
  foreach ($browsers as $browser) {
    $this->derivatives[$browser
      ->id()] = $base_plugin_definition;
    $this->derivatives[$browser
      ->id()]['admin_label'] = $browser
      ->label();
    $this->derivatives[$browser
      ->id()]['config_dependencies']['config'] = [
      $browser
        ->getConfigDependencyName(),
    ];
  }
  return parent::getDerivativeDefinitions($base_plugin_definition);
}