class EntityBlock in Entity Blocks 8
Same name in this branch
- 8 src/Plugin/Derivative/EntityBlock.php \Drupal\entity_block\Plugin\Derivative\EntityBlock
- 8 src/Plugin/Block/EntityBlock.php \Drupal\entity_block\Plugin\Block\EntityBlock
Provides block plugin definitions for all Entity Block block displays.
Hierarchy
- class \Drupal\entity_block\Plugin\Derivative\EntityBlock implements ContainerDeriverInterface
Expanded class hierarchy of EntityBlock
See also
\Drupal\entity_block\Plugin\block\block\EntityBlock
File
- src/
Plugin/ Derivative/ EntityBlock.php, line 14
Namespace
Drupal\entity_block\Plugin\DerivativeView source
class EntityBlock implements ContainerDeriverInterface {
/**
* List of derivative definitions.
*
* @var array
*/
protected $derivatives = [];
/**
* The base plugin ID.
*
* @var string
*/
protected $basePluginId;
/**
* The entity type manager.
*
* @var EntityTypeManagerInterface
*/
protected $entityTypeManager;
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container, $base_plugin_id) {
return new static($base_plugin_id, $container
->get('entity_type.manager'));
}
/**
* Constructs a EntityBlock object.
*
* @param string $base_plugin_id
* The base plugin ID.
* @param EntityTypeManagerInterface $entityTypeManager
* The entity type manager.
*/
public function __construct($base_plugin_id, EntityTypeManagerInterface $entityTypeManager) {
$this->basePluginId = $base_plugin_id;
$this->entityTypeManager = $entityTypeManager;
}
/**
* {@inheritdoc}
*/
public function getDerivativeDefinition($derivative_id, $base_plugin_definition) {
if (!empty($this->derivatives) && !empty($this->derivatives[$derivative_id])) {
return $this->derivatives[$derivative_id];
}
$this
->getDerivativeDefinitions($base_plugin_definition);
return $this->derivatives[$derivative_id];
}
/**
* {@inheritdoc}
*/
public function getDerivativeDefinitions($base_plugin_definition) {
foreach ($this->entityTypeManager
->getDefinitions() as $entityDefinition) {
if ($entityDefinition
->hasViewBuilderClass()) {
$delta = $entityDefinition
->id();
$this->derivatives[$delta] = [
'category' => 'Entity Block',
'admin_label' => $entityDefinition
->getLabel(),
'config_dependencies' => [
'config' => [],
],
];
$this->derivatives[$delta] += $base_plugin_definition;
}
}
return $this->derivatives;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
EntityBlock:: |
protected | property | The base plugin ID. | |
EntityBlock:: |
protected | property | List of derivative definitions. | |
EntityBlock:: |
protected | property | The entity type manager. | |
EntityBlock:: |
public static | function |
Creates a new class instance. Overrides ContainerDeriverInterface:: |
|
EntityBlock:: |
public | function |
Gets the definition of a derivative plugin. Overrides DeriverInterface:: |
|
EntityBlock:: |
public | function |
Gets the definition of all derivatives of a base plugin. Overrides DeriverInterface:: |
|
EntityBlock:: |
public | function | Constructs a EntityBlock object. |