3 namespace Drupal\simple_sitemap\Plugin\simple_sitemap\UrlGenerator;
5 use Drupal\simple_sitemap\EntityHelper;
6 use Drupal\simple_sitemap\Logger;
7 use Drupal\simple_sitemap\Simplesitemap;
8 use Drupal\simple_sitemap\SitemapGenerator;
9 use Drupal\Core\Language\LanguageManagerInterface;
10 use Drupal\Core\Entity\EntityTypeManagerInterface;
11 use Drupal\Core\Extension\ModuleHandler;
12 use Symfony\Component\DependencyInjection\ContainerInterface;
15 * Class ArbitraryUrlGenerator
16 * @package Drupal\simple_sitemap\Plugin\simple_sitemap\UrlGenerator
20 * title = @Translation("Arbitrary URL generator"),
21 * description = @Translation("Generates URLs from data sets collected in the hook_arbitrary_links_alter hook."),
25 class ArbitraryUrlGenerator extends UrlGeneratorBase {
27 protected $moduleHandler;
30 * ArbitraryUrlGenerator constructor.
31 * @param array $configuration
32 * @param string $plugin_id
33 * @param mixed $plugin_definition
34 * @param \Drupal\simple_sitemap\Simplesitemap $generator
35 * @param \Drupal\simple_sitemap\SitemapGenerator $sitemap_generator
36 * @param \Drupal\Core\Language\LanguageManagerInterface $language_manager
37 * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
38 * @param \Drupal\simple_sitemap\Logger $logger
39 * @param \Drupal\simple_sitemap\EntityHelper $entityHelper
40 * @param \Drupal\Core\Extension\ModuleHandler $module_handler
42 public function __construct(
46 Simplesitemap $generator,
47 SitemapGenerator $sitemap_generator,
48 LanguageManagerInterface $language_manager,
49 EntityTypeManagerInterface $entity_type_manager,
51 EntityHelper $entityHelper,
52 ModuleHandler $module_handler
65 $this->moduleHandler = $module_handler;
68 public static function create(
69 ContainerInterface $container,
77 $container->get('simple_sitemap.generator'),
78 $container->get('simple_sitemap.sitemap_generator'),
79 $container->get('language_manager'),
80 $container->get('entity_type.manager'),
81 $container->get('simple_sitemap.logger'),
82 $container->get('simple_sitemap.entity_helper'),
83 $container->get('module_handler')
91 public function getDataSets() {
92 $arbitrary_links = [];
93 $this->moduleHandler->alter('simple_sitemap_arbitrary_links', $arbitrary_links);
94 return array_values($arbitrary_links);
100 protected function processDataSet($data_set) {