class SearchApiStatsBlock in Search API Stats 8
Same name in this branch
- 8 modules/search_api_stats_block/src/Plugin/Derivative/SearchApiStatsBlock.php \Drupal\search_api_stats_block\Plugin\Derivative\SearchApiStatsBlock
- 8 modules/search_api_stats_block/src/Plugin/Block/SearchApiStatsBlock.php \Drupal\search_api_stats_block\Plugin\Block\SearchApiStatsBlock
Provides block plugin definitions for mymodule blocks.
Hierarchy
- class \Drupal\Component\Plugin\Derivative\DeriverBase implements DeriverInterface
- class \Drupal\search_api_stats_block\Plugin\Derivative\SearchApiStatsBlock implements ContainerDeriverInterface
Expanded class hierarchy of SearchApiStatsBlock
See also
\Drupal\search_api_stats_block\Plugin\Block\SearchApiStatsBlock
File
- modules/
search_api_stats_block/ src/ Plugin/ Derivative/ SearchApiStatsBlock.php, line 16
Namespace
Drupal\search_api_stats_block\Plugin\DerivativeView source
class SearchApiStatsBlock extends DeriverBase implements ContainerDeriverInterface {
/**
* List of derivative definitions.
*
* @var array
*/
protected $derivatives = [];
/**
* The base plugin ID this derivative is for.
*
* @var string
*/
protected $basePluginId;
/**
* The entity manager.
*
* @var \Drupal\Core\Entity\EntityTypeManagerInterface
*/
protected $entityTypeManager;
/**
* {@inheritdoc}
*/
public function getDerivativeDefinitions($base_plugin_definition) {
/** @var \Drupal\search_api\Entity\Index[] $indexes */
$indexes = Index::loadMultiple();
foreach ($indexes as $key => $index) {
$this->derivatives[$key] = $base_plugin_definition;
$this->derivatives[$key]['admin_label'] = t('Search API stats block: :label', [
':label' => $index
->label(),
]);
$this->derivatives[$key]['config_dependencies']['config'] = [];
}
return $this->derivatives;
}
/**
* Constructs an EntityDeriver object.
*
* @param string $base_plugin_id
* The base plugin ID.
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_manager
* The entity manager.
*/
public function __construct($base_plugin_id, EntityTypeManagerInterface $entity_manager) {
$this->basePluginId = $base_plugin_id;
$this->entityTypeManager = $entity_manager;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container, $base_plugin_id) {
return new static($base_plugin_id, $container
->get('entity_type.manager'));
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DeriverBase:: |
public | function |
Gets the definition of a derivative plugin. Overrides DeriverInterface:: |
|
SearchApiStatsBlock:: |
protected | property | The base plugin ID this derivative is for. | |
SearchApiStatsBlock:: |
protected | property |
List of derivative definitions. Overrides DeriverBase:: |
|
SearchApiStatsBlock:: |
protected | property | The entity manager. | |
SearchApiStatsBlock:: |
public static | function |
Creates a new class instance. Overrides ContainerDeriverInterface:: |
|
SearchApiStatsBlock:: |
public | function |
Gets the definition of all derivatives of a base plugin. Overrides DeriverBase:: |
|
SearchApiStatsBlock:: |
public | function | Constructs an EntityDeriver object. |