class OrganigramsBlocks in Organigrams 8
Same name in this branch
- 8 src/Plugin/Derivative/OrganigramsBlocks.php \Drupal\organigrams\Plugin\Derivative\OrganigramsBlocks
- 8 src/Plugin/Block/OrganigramsBlocks.php \Drupal\organigrams\Plugin\Block\OrganigramsBlocks
Same name and namespace in other branches
- 8.2 src/Plugin/Derivative/OrganigramsBlocks.php \Drupal\organigrams\Plugin\Derivative\OrganigramsBlocks
Provides block plugin definitions for organigrams.
Hierarchy
- class \Drupal\Component\Plugin\Derivative\DeriverBase implements DeriverInterface
- class \Drupal\organigrams\Plugin\Derivative\OrganigramsBlocks implements ContainerDeriverInterface
Expanded class hierarchy of OrganigramsBlocks
See also
\Drupal\organigrams\Plugin\Block\NodeBlock
File
- src/
Plugin/ Derivative/ OrganigramsBlocks.php, line 15
Namespace
Drupal\organigrams\Plugin\DerivativeView source
class OrganigramsBlocks extends DeriverBase implements ContainerDeriverInterface {
/**
* The node storage.
*
* @var \Drupal\Core\Entity\EntityStorageInterface
*/
protected $taxonomyStorage;
/**
* Constructs new OrganigramsBlocks.
*
* @param \Drupal\Core\Entity\EntityStorageInterface $taxonomy_storage
* The taxonomy storage.
*/
public function __construct(EntityStorageInterface $taxonomy_storage) {
$this->taxonomyStorage = $taxonomy_storage;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container, $base_plugin_id) {
return new static($container
->get('entity_type.manager')
->getStorage('taxonomy_vocabulary'));
}
/**
* {@inheritdoc}
*
* Create a block for every organigram.
*/
public function getDerivativeDefinitions($base_plugin_definition) {
// Load all vocabularies and iterate through them.
$taxonomy_vocabularies = $this->taxonomyStorage
->loadMultiple();
foreach ($taxonomy_vocabularies as $vocabulary) {
// Skip if the vocabulary has no organigrams settings.
if (empty($vocabulary
->getThirdPartySettings('organigrams'))) {
continue;
}
// Create the block.
$this->derivatives[$vocabulary
->id()] = $base_plugin_definition;
$this->derivatives[$vocabulary
->id()]['admin_label'] = t('Organigram block:') . ' ' . $vocabulary
->label();
}
return $this->derivatives;
}
}
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:: |
|
OrganigramsBlocks:: |
protected | property | The node storage. | |
OrganigramsBlocks:: |
public static | function |
Creates a new class instance. Overrides ContainerDeriverInterface:: |
|
OrganigramsBlocks:: |
public | function |
Create a block for every organigram. Overrides DeriverBase:: |
|
OrganigramsBlocks:: |
public | function | Constructs new OrganigramsBlocks. |