You are here

public function OrganigramsBlocks::getDerivativeDefinitions in Organigrams 8.2

Same name and namespace in other branches
  1. 8 src/Plugin/Derivative/OrganigramsBlocks.php \Drupal\organigrams\Plugin\Derivative\OrganigramsBlocks::getDerivativeDefinitions()

Create a block for every organigram.

Overrides DeriverBase::getDerivativeDefinitions

File

src/Plugin/Derivative/OrganigramsBlocks.php, line 50

Class

OrganigramsBlocks
Provides block plugin definitions for organigrams.

Namespace

Drupal\organigrams\Plugin\Derivative

Code

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'] = $this
      ->t('Organigram block:') . ' ' . $vocabulary
      ->label();
  }
  return $this->derivatives;
}