You are here

public function VocabularySitemapDeriver::getDerivativeDefinitions in Sitemap 2.0.x

Same name and namespace in other branches
  1. 8.2 src/Plugin/Derivative/VocabularySitemapDeriver.php \Drupal\sitemap\Plugin\Derivative\VocabularySitemapDeriver::getDerivativeDefinitions()

Gets the definition of all derivatives of a base plugin.

Parameters

array $base_plugin_definition: The definition array of the base plugin.

Return value

array An array of full derivative definitions keyed on derivative id.

Overrides DeriverBase::getDerivativeDefinitions

See also

getDerivativeDefinition()

File

src/Plugin/Derivative/VocabularySitemapDeriver.php, line 25

Class

VocabularySitemapDeriver

Namespace

Drupal\sitemap\Plugin\Derivative

Code

public function getDerivativeDefinitions($base_plugin_definition) {
  if (\Drupal::moduleHandler()
    ->moduleExists('taxonomy')) {
    foreach (Vocabulary::loadMultiple() as $id => $vocabulary) {

      /* @var $vocabulary \Drupal\taxonomy\VocabularyInterface */
      $this->derivatives[$id] = $base_plugin_definition;
      $this->derivatives[$id]['title'] = t('Vocabulary: @vocabulary', [
        '@vocabulary' => $vocabulary
          ->label(),
      ]);
      $this->derivatives[$id]['description'] = $vocabulary
        ->getDescription();
      $this->derivatives[$id]['settings']['title'] = '';
      $this->derivatives[$id]['vocabulary'] = $vocabulary
        ->id();
      $this->derivatives[$id]['config_dependencies']['config'] = [
        $vocabulary
          ->getConfigDependencyName(),
      ];
    }
  }
  return $this->derivatives;
}