Commit a61961f8 authored by gbyte.co's avatar gbyte.co

Clean up

parent ca23c0ea
......@@ -172,6 +172,7 @@ function simple_sitemap_configurable_language_delete(ConfigurableLanguageInterfa
/** @var \Drupal\simple_sitemap\Simplesitemap $generator */
$generator = \Drupal::service('simple_sitemap.generator');
$excluded_languages = $generator->getSetting('excluded_languages');
if (isset($excluded_languages[$language->id()])) {
unset($excluded_languages[$language->id()]);
......@@ -230,17 +231,17 @@ function simple_sitemap_delete_bundle_config($entity_type_id, $bundle) {
/** @var \Drupal\simple_sitemap\Simplesitemap $generator */
$generator = \Drupal::service('simple_sitemap.generator');
$deleted_bundle_settings = $generator->getBundleSettings($entity_type_id, $bundle);
if (!empty($deleted_bundle_settings['index'])) {
// Delete bundle settings.
if (!empty($deleted_bundle_settings = $generator->getBundleSettings($entity_type_id, $bundle))) {
\Drupal::service('config.factory')->getEditable("simple_sitemap.bundle_settings.$entity_type_id.$bundle")->delete();
$message = 'You may want to <a href="@url">regenerate</a> your XML sitemaps now.';
if ($generator->getSetting('cron_generate')) {
$message .= ' Otherwise the sitemaps will be regenerated during a future cron run.';
if (!empty($deleted_bundle_settings['index'])) {
$message = 'You may want to <a href="@url">regenerate</a> your XML sitemaps now.';
if ($generator->getSetting('cron_generate')) {
$message .= ' Otherwise the sitemaps will be regenerated during a future cron run.';
}
\Drupal::messenger()->addMessage(t($message, ['@url' => $GLOBALS['base_url'] . '/admin/config/search/simplesitemap']));
}
\Drupal::messenger()->addMessage(t($message, ['@url' => $GLOBALS['base_url'] . '/admin/config/search/simplesitemap']));
}
}
......
......@@ -16,8 +16,6 @@ use Drupal\Core\Language\Language;
/**
* Class UrlGeneratorBase
* @package Drupal\simple_sitemap\Plugin\simple_sitemap\UrlGenerator
*
* @todo Remove queue services from this and its children.
*/
abstract class UrlGeneratorBase extends SimplesitemapPluginBase implements UrlGeneratorInterface {
......@@ -139,7 +137,6 @@ abstract class UrlGeneratorBase extends SimplesitemapPluginBase implements UrlGe
* @return array
*/
protected function getUrlVariants(array $path_data, Url $url_object) {
$url_variants = [];
if (!$url_object->isRouted()) {
......@@ -237,12 +234,16 @@ abstract class UrlGeneratorBase extends SimplesitemapPluginBase implements UrlGe
*/
abstract protected function processDataSet($data_set);
/**
* @param $data_set
* @return array
*/
public function generate($data_set) {
$path_data = $this->processDataSet($data_set);
if (!$path_data) {
return [];
}
if ($path_data['url'] instanceof Url) {
if (isset($path_data['url']) && $path_data['url'] instanceof Url) {
$url_object = $path_data['url'];
unset($path_data['url']);
return $this->getUrlVariants($path_data, $url_object);
......
......@@ -17,7 +17,7 @@ class SimplesitemapTest extends SimplesitemapTestBase {
* @throws \Drupal\Component\Plugin\Exception\PluginException
* @throws \Behat\Mink\Exception\ExpectationException
*/
public function testInitialGenerationtestInitialGeneration() {
public function testInitialGeneration() {
$this->generator->generateSitemap('backend');
$this->drupalGet($this->defaultSitemapUrl);
$this->assertSession()->responseContains('urlset');
......
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