Updated to Drupal 8.5. Core Media not yet in use.
[yaffs-website] / web / modules / contrib / simple_sitemap / src / Plugin / simple_sitemap / UrlGenerator / ArbitraryUrlGenerator.php
diff --git a/web/modules/contrib/simple_sitemap/src/Plugin/simple_sitemap/UrlGenerator/ArbitraryUrlGenerator.php b/web/modules/contrib/simple_sitemap/src/Plugin/simple_sitemap/UrlGenerator/ArbitraryUrlGenerator.php
new file mode 100644 (file)
index 0000000..81480d6
--- /dev/null
@@ -0,0 +1,103 @@
+<?php
+
+namespace Drupal\simple_sitemap\Plugin\simple_sitemap\UrlGenerator;
+
+use Drupal\simple_sitemap\EntityHelper;
+use Drupal\simple_sitemap\Logger;
+use Drupal\simple_sitemap\Simplesitemap;
+use Drupal\simple_sitemap\SitemapGenerator;
+use Drupal\Core\Language\LanguageManagerInterface;
+use Drupal\Core\Entity\EntityTypeManagerInterface;
+use Drupal\Core\Extension\ModuleHandler;
+use Symfony\Component\DependencyInjection\ContainerInterface;
+
+/**
+ * Class ArbitraryUrlGenerator
+ * @package Drupal\simple_sitemap\Plugin\simple_sitemap\UrlGenerator
+ *
+ * @UrlGenerator(
+ *   id = "arbitrary",
+ *   title = @Translation("Arbitrary URL generator"),
+ *   description = @Translation("Generates URLs from data sets collected in the hook_arbitrary_links_alter hook."),
+ *   weight = 20,
+ * )
+ */
+class ArbitraryUrlGenerator extends UrlGeneratorBase {
+
+  protected $moduleHandler;
+
+  /**
+   * ArbitraryUrlGenerator constructor.
+   * @param array $configuration
+   * @param string $plugin_id
+   * @param mixed $plugin_definition
+   * @param \Drupal\simple_sitemap\Simplesitemap $generator
+   * @param \Drupal\simple_sitemap\SitemapGenerator $sitemap_generator
+   * @param \Drupal\Core\Language\LanguageManagerInterface $language_manager
+   * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
+   * @param \Drupal\simple_sitemap\Logger $logger
+   * @param \Drupal\simple_sitemap\EntityHelper $entityHelper
+   * @param \Drupal\Core\Extension\ModuleHandler $module_handler
+   */
+  public function __construct(
+    array $configuration,
+    $plugin_id,
+    $plugin_definition,
+    Simplesitemap $generator,
+    SitemapGenerator $sitemap_generator,
+    LanguageManagerInterface $language_manager,
+    EntityTypeManagerInterface $entity_type_manager,
+    Logger $logger,
+    EntityHelper $entityHelper,
+    ModuleHandler $module_handler
+  ) {
+    parent::__construct(
+      $configuration,
+      $plugin_id,
+      $plugin_definition,
+      $generator,
+      $sitemap_generator,
+      $language_manager,
+      $entity_type_manager,
+      $logger,
+      $entityHelper
+    );
+    $this->moduleHandler = $module_handler;
+  }
+
+  public static function create(
+    ContainerInterface $container,
+    array $configuration,
+    $plugin_id,
+    $plugin_definition) {
+    return new static(
+      $configuration,
+      $plugin_id,
+      $plugin_definition,
+      $container->get('simple_sitemap.generator'),
+      $container->get('simple_sitemap.sitemap_generator'),
+      $container->get('language_manager'),
+      $container->get('entity_type.manager'),
+      $container->get('simple_sitemap.logger'),
+      $container->get('simple_sitemap.entity_helper'),
+      $container->get('module_handler')
+    );
+  }
+
+
+  /**
+   * @inheritdoc
+   */
+  public function getDataSets() {
+    $arbitrary_links = [];
+    $this->moduleHandler->alter('simple_sitemap_arbitrary_links', $arbitrary_links);
+    return array_values($arbitrary_links);
+  }
+
+  /**
+   * @inheritdoc
+   */
+  protected function processDataSet($data_set) {
+    return $data_set;
+  }
+}