Commit 4ab0d5e2 authored by gbyte.co's avatar gbyte.co

Add weight functionality to plugins

parent fb9a7cca
......@@ -22,4 +22,9 @@ class UrlGenerator extends Plugin {
* @var string
*/
public $id;
/**
* @var integer
*/
public $weight;
}
......@@ -16,7 +16,8 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
* @package Drupal\simple_sitemap\Plugin\simple_sitemap\UrlGenerator
*
* @UrlGenerator(
* id = "arbitrary"
* id = "arbitrary",
* weight = 20
* )
*/
class ArbitraryUrlGenerator extends UrlGeneratorBase {
......
......@@ -18,7 +18,8 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
* @package Drupal\simple_sitemap\Plugin\simple_sitemap\UrlGenerator
*
* @UrlGenerator(
* id = "custom"
* id = "custom",
* weight = 0
* )
*/
class CustomUrlGenerator extends UrlGeneratorBase {
......
......@@ -7,7 +7,8 @@ namespace Drupal\simple_sitemap\Plugin\simple_sitemap\UrlGenerator;
* @package Drupal\simple_sitemap\Plugin\simple_sitemap\UrlGenerator
*
* @UrlGenerator(
* id = "entity"
* id = "entity",
* weight = 10
* )
*/
class EntityUrlGenerator extends UrlGeneratorBase {
......
......@@ -249,7 +249,13 @@ class Simplesitemap {
'from' => $from,
]);
foreach ($this->urlGeneratorManager->getDefinitions() as $plugin) {
$plugins = $this->urlGeneratorManager->getDefinitions();
usort($plugins, function($a, $b) {
return $a['weight'] - $b['weight'];
});
foreach ($plugins as $plugin) {
$this->batch->addOperation($plugin['id']);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment