You are here

class VocabularySitemapDeriver 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

Hierarchy

Expanded class hierarchy of VocabularySitemapDeriver

File

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

Namespace

Drupal\sitemap\Plugin\Derivative
View source
class VocabularySitemapDeriver extends DeriverBase implements ContainerDeriverInterface {

  /**
   * {@inheritdoc}
   */
  public static function create(ContainerInterface $container, $base_plugin_id) {
    return new static();
  }

  /**
   * {@inheritdoc}
   */
  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;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
DeriverBase::$derivatives protected property List of derivative definitions. 1
DeriverBase::getDerivativeDefinition public function Gets the definition of a derivative plugin. Overrides DeriverInterface::getDerivativeDefinition
VocabularySitemapDeriver::create public static function Creates a new class instance. Overrides ContainerDeriverInterface::create
VocabularySitemapDeriver::getDerivativeDefinitions public function Gets the definition of all derivatives of a base plugin. Overrides DeriverBase::getDerivativeDefinitions