class EntityBrowserBlockDeriver in Entity Browser Block 8
Retrieves block plugin definitions for all entity browsers.
Hierarchy
- class \Drupal\Component\Plugin\Derivative\DeriverBase implements DeriverInterface
- class \Drupal\entity_browser_block\Plugin\Derivative\EntityBrowserBlockDeriver implements ContainerDeriverInterface
Expanded class hierarchy of EntityBrowserBlockDeriver
File
- src/
Plugin/ Derivative/ EntityBrowserBlockDeriver.php, line 13
Namespace
Drupal\entity_browser_block\Plugin\DerivativeView source
class EntityBrowserBlockDeriver extends DeriverBase implements ContainerDeriverInterface {
/**
* The browser storage.
*
* @var \Drupal\Core\Entity\EntityStorageInterface
*/
protected $browserStorage;
/**
* Constructs a EntityBrowserBlockDeriver object.
*
* @param \Drupal\Core\Entity\EntityStorageInterface $browser_storage
* The browser storage.
*/
public function __construct(EntityStorageInterface $browser_storage) {
$this->browserStorage = $browser_storage;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container, $base_plugin_id) {
$entity_manager = $container
->get('entity_type.manager');
return new static($entity_manager
->getStorage('entity_browser'));
}
/**
* {@inheritdoc}
*/
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);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DeriverBase:: |
protected | property | List of derivative definitions. | 1 |
DeriverBase:: |
public | function |
Gets the definition of a derivative plugin. Overrides DeriverInterface:: |
|
EntityBrowserBlockDeriver:: |
protected | property | The browser storage. | |
EntityBrowserBlockDeriver:: |
public static | function |
Creates a new class instance. Overrides ContainerDeriverInterface:: |
|
EntityBrowserBlockDeriver:: |
public | function |
Gets the definition of all derivatives of a base plugin. Overrides DeriverBase:: |
|
EntityBrowserBlockDeriver:: |
public | function | Constructs a EntityBrowserBlockDeriver object. |