diff --git a/src/Entity/XmlSitemap.php b/src/Entity/XmlSitemap.php index c8887de..7206084 100644 --- a/src/Entity/XmlSitemap.php +++ b/src/Entity/XmlSitemap.php @@ -33,8 +33,8 @@ use Drupal\xmlsitemap\XmlSitemapInterface; * "label" = "label" * }, * links = { - * "edit-form" = "xmlsitemap.admin_edit", - * "delete-form" = "xmlsitemap.admin_delete" + * "edit-form" = "/admin/config/search/xmlsitemap/{xmlsitemap}/edit", + * "delete-form" = "/admin/config/search/xmlsitemap/{xmlsitemap}/delete" * } * ) */ diff --git a/src/Form/XmlSitemapEntitiesSettingsForm.php b/src/Form/XmlSitemapEntitiesSettingsForm.php index 5204b92..cfb316b 100644 --- a/src/Form/XmlSitemapEntitiesSettingsForm.php +++ b/src/Form/XmlSitemapEntitiesSettingsForm.php @@ -61,6 +61,13 @@ class XmlSitemapEntitiesSettingsForm extends ConfigFormBase implements Container /** * {@inheritdoc} */ + protected function getEditableConfigNames() { + return ['xmlsitemap.settings']; + } + + /** + * {@inheritdoc} + */ public function buildForm(array $form, FormStateInterface $form_state) { $config = $this->config('xmlsitemap.settings'); $entity_types = $this->entityManager->getDefinitions(); diff --git a/src/Form/XmlSitemapLinkBundleSettingsForm.php b/src/Form/XmlSitemapLinkBundleSettingsForm.php index 7e7677f..609045e 100644 --- a/src/Form/XmlSitemapLinkBundleSettingsForm.php +++ b/src/Form/XmlSitemapLinkBundleSettingsForm.php @@ -64,6 +64,13 @@ class XmlSitemapLinkBundleSettingsForm extends ConfigFormBase implements Contain /** * {@inheritdoc} */ + protected function getEditableConfigNames() { + return ['xmlsitemap.settings']; + } + + /** + * {@inheritdoc} + */ public function buildForm(array $form, FormStateInterface $form_state, $entity = NULL, $bundle = NULL) { $this->entity_type = $entity; $this->bundle_type = $bundle; diff --git a/src/Form/XmlSitemapRebuildForm.php b/src/Form/XmlSitemapRebuildForm.php index 614f8c7..342fdf5 100644 --- a/src/Form/XmlSitemapRebuildForm.php +++ b/src/Form/XmlSitemapRebuildForm.php @@ -58,6 +58,13 @@ class XmlSitemapRebuildForm extends ConfigFormBase { /** * {@inheritdoc} */ + protected function getEditableConfigNames() { + return ['xmlsitemap.settings']; + } + + /** + * {@inheritdoc} + */ public function buildForm(array $form, FormStateInterface $form_state) { $request = $this->getRequest(); if (!$request->request && !$this->state->get('xmlsitemap_rebuild_needed')) { diff --git a/src/Form/XmlSitemapSettingsForm.php b/src/Form/XmlSitemapSettingsForm.php index 00ad1f2..b35d2b9 100644 --- a/src/Form/XmlSitemapSettingsForm.php +++ b/src/Form/XmlSitemapSettingsForm.php @@ -81,6 +81,13 @@ class XmlSitemapSettingsForm extends ConfigFormBase { /** * {@inheritdoc} */ + protected function getEditableConfigNames() { + return ['xmlsitemap.settings']; + } + + /** + * {@inheritdoc} + */ public function buildForm(array $form, FormStateInterface $form_state) { $config = $this->config('xmlsitemap.settings'); $intervals = array(300, 900, 1800, 3600, 10800, 21600, 43200, 86400, 172800, 259200, 604800); diff --git a/src/Tests/XmlSitemapTestBase.php b/src/Tests/XmlSitemapTestBase.php index cc65eba..4af473e 100644 --- a/src/Tests/XmlSitemapTestBase.php +++ b/src/Tests/XmlSitemapTestBase.php @@ -405,7 +405,7 @@ abstract class XmlSitemapTestBase extends WebTestBase { if ($id = parent::verbose($verbose_message)) { $url = file_create_url($this->originalFileDirectory . '/simpletest/verbose/' . get_class($this) . '-' . $id . '.html'); $message_url = Url::fromUri($url, array('attributes' => array('target' => '_blank'))); - $this->error($this->l($message, $message_url)), 'User notice'); + $this->error($this->l($message, $message_url), 'User notice'); } } diff --git a/src/XmlSitemapGenerator.php b/src/XmlSitemapGenerator.php index 7808098..f243fe8 100644 --- a/src/XmlSitemapGenerator.php +++ b/src/XmlSitemapGenerator.php @@ -80,7 +80,7 @@ class XmlSitemapGenerator implements XmlSitemapGeneratorInterface { * The state handler. */ public function __construct(ConfigFactoryInterface $config_factory, EntityManagerInterface $entity_manager, StateInterface $state, LanguageManagerInterface $language_manager) { - $this->config = $config_factory->get('xmlsitemap.settings'); + $this->config = $config_factory->getEditable('xmlsitemap.settings'); $this->entityManager = $entity_manager; $this->state = $state; $this->languageManager = $language_manager; @@ -241,7 +241,7 @@ class XmlSitemapGenerator implements XmlSitemapGeneratorInterface { ); // @todo Add a separate hook_xmlsitemap_link_url_alter() here? $link['loc'] = empty($link['loc']) ? '' : $link['loc']; - $link_url = Url::fromRoute($link['loc'], [], $link_options + $url_options); + $link_url = Url::fromRoute($link['loc'], [], $link_options + $url_options)->toString(); // Skip this link if it was a duplicate of the last one. // @todo Figure out a way to do this before generation so we can report diff --git a/xmlsitemap.install b/xmlsitemap.install index 98f982c..238bab6 100644 --- a/xmlsitemap.install +++ b/xmlsitemap.install @@ -315,8 +315,9 @@ function xmlsitemap_install() { function xmlsitemap_uninstall() { // Remove config variables. $variables = array_keys(xmlsitemap_config_variables()); + $editable = \Drupal::configFactory()->getEditable('xmlsitemap.settings'); foreach ($variables as $variable) { - \Drupal::config('xmlsitemap.settings')->clear($variable); + $editable->clear($variable); } $variables = array_keys(xmlsitemap_state_variables()); diff --git a/xmlsitemap.links.action.yml b/xmlsitemap.links.action.yml index 7dae59d..f3b943c 100644 --- a/xmlsitemap.links.action.yml +++ b/xmlsitemap.links.action.yml @@ -1,5 +1,5 @@ xmlsitemap.add: - route_name: xmlsitemap.admin_add + route_name: entity.xmlsitemap.add_form title: 'Add XML Sitemap' appears_on: - xmlsitemap.admin_search diff --git a/xmlsitemap.links.task.yml b/xmlsitemap.links.task.yml index 7a897d4..5be0cc2 100644 --- a/xmlsitemap.links.task.yml +++ b/xmlsitemap.links.task.yml @@ -1,19 +1,19 @@ xmlsitemap.add: - route_name: 'xmlsitemap.admin_add' + route_name: 'entity.xmlsitemap.add_form' title: 'Add XmlSitemap' appears_on: - xmlsitemap.admin_search - xmlsitemap.admin_search_list xmlsitemap.edit: - route_name: 'xmlsitemap.admin_edit' + route_name: 'entity.xmlsitemap.edit_form' title: 'Edit XmlSitemap' appears_on: - xmlsitemap.admin_search - xmlsitemap.admin_search_list xmlsitemap.delete: - route_name: 'xmlsitemap.admin_delete' + route_name: 'entity.xmlsitemap.delete_form' title: 'Delete XmlSitemap' appears_on: - xmlsitemap.admin_search diff --git a/xmlsitemap.module b/xmlsitemap.module index 3748aed..8658d13 100644 --- a/xmlsitemap.module +++ b/xmlsitemap.module @@ -112,8 +112,8 @@ function xmlsitemap_help($route_name, RouteMatchInterface $route_match) { case 'help.page.xmlsitemap': case 'xmlsitemap.admin_settings': case 'xmlsitemap.entities_settings': - case 'xmlsitemap.admin_edit': - case 'xmlsitemap.admin_delete': + case 'entity.xmlsitemap.edit_form': + case 'entity.xmlsitemap.delete_form': return; case 'xmlsitemap.admin_search': break; @@ -760,9 +760,9 @@ function xmlsitemap_link_bundle_settings_save($entity, $bundle, array $settings, } foreach ($settings as $key => $value) { - \Drupal::config("xmlsitemap.settings.{$entity}.{$bundle}")->set($key, $value); + \Drupal::configFactory()->getEditable("xmlsitemap.settings.{$entity}.{$bundle}")->set($key, $value); } - \Drupal::config("xmlsitemap.settings.{$entity}.{$bundle}")->save(); + \Drupal::configFactory()->getEditable("xmlsitemap.settings.{$entity}.{$bundle}")->save(); foreach (\Drupal::languageManager()->getLanguages() as $lang) { \Drupal::cache()->delete('xmlsitemap:link_info:' . $lang->getId()); @@ -784,7 +784,7 @@ function xmlsitemap_link_bundle_rename($entity, $bundle_old, $bundle_new) { if ($bundle_old != $bundle_new) { if (!\Drupal::config("xmlsitemap.settings.{$entity}.{$bundle_old}")->isNew()) { $settings = xmlsitemap_link_bundle_load($entity, $bundle_old); - \Drupal::config("xmlsitemap.settings.{$entity}.{$bundle_old}")->delete(); + \Drupal::configFactory()->getEditable("xmlsitemap.settings.{$entity}.{$bundle_old}")->delete(); xmlsitemap_link_bundle_settings_save($entity, $bundle_new, $settings, FALSE); \Drupal::service('xmlsitemap.link_storage')->updateMultiple(array('subtype' => $bundle_new), array('type' => $entity, 'subtype' => $bundle_old)); } @@ -807,10 +807,10 @@ function xmlsitemap_link_type_rename($entity_old, $entity_new, $bundles = NULL) if (!strpos($key, "xmlsitemap_settings_{$entity_old}") && !strpos($key, "xmlsitemap_entity_{$entity_old}")) { continue; } - \Drupal::config('xmlsitemap.settings')->clear($key); + \Drupal::configFactory()->getEditable('xmlsitemap.settings')->clear($key); if (isset($value)) { $variable_new = str_replace('xmlsitemap_settings_' . $entity_old, 'xmlsitemap_settings_' . $entity_new, $key); - \Drupal::config('xmlsitemap.settings')->set($variable_new, $value)->save(); + \Drupal::configFactory()->getEditable('xmlsitemap.settings')->set($variable_new, $value)->save(); } } @@ -864,7 +864,7 @@ function xmlsitemap_link_bundle_load($entity, $bundle, $load_bundle_info = TRUE) * If TRUE, deletes bundle links from {xmlsitemap} table. */ function xmlsitemap_link_bundle_delete($entity, $bundle, $delete_links = TRUE) { - \Drupal::config("xmlsitemap.settings.{$entity}.{$bundle}")->delete(); + \Drupal::configFactory()->getEditable("xmlsitemap.settings.{$entity}.{$bundle}")->delete(); if ($delete_links) { \Drupal::service('xmlsitemap.link_storage')->deleteMultiple(array('type' => $entity, 'subtype' => $bundle)); } @@ -940,8 +940,8 @@ function xmlsitemap_entity_bundle_rename($entity_type_id, $bundle_old, $bundle_n /** * Implements hook_entity_bundle_delete(). */ -function xmlsitemap_entity_bundle_delete($entity_type, $bundle, $instances) { - xmlsitemap_link_bundle_delete($entity_type, $bundle, TRUE); +function xmlsitemap_entity_bundle_delete($entity_type_id, $bundle) { + xmlsitemap_link_bundle_delete($entity_type_id, $bundle, TRUE); } /** @@ -2391,7 +2391,7 @@ function xmlsitemap_check_status() { $messages = array(); foreach ($modules as $module) { module_load_install($module); - $requirements = \Drupal::moduleHandler()->invoke($module, 'requirements', 'runtime'); + $requirements = \Drupal::moduleHandler()->invoke($module, 'requirements', array('runtime')); foreach ($requirements as $requirement) { if (isset($requirement['severity']) && max(REQUIREMENT_OK, $requirement['severity'])) { $messages[] = $requirement['description']; diff --git a/xmlsitemap.routing.yml b/xmlsitemap.routing.yml index 8c64ba0..78523e5 100644 --- a/xmlsitemap.routing.yml +++ b/xmlsitemap.routing.yml @@ -14,7 +14,7 @@ xmlsitemap.admin_search_list: requirements: _permission: 'administer xmlsitemap' -xmlsitemap.admin_add: +entity.xmlsitemap.add_form: path: '/admin/config/search/xmlsitemap/add' defaults: _entity_form: 'xmlsitemap.add' @@ -22,7 +22,7 @@ xmlsitemap.admin_add: requirements: _permission: 'administer xmlsitemap' -xmlsitemap.admin_edit: +entity.xmlsitemap.edit_form: path: '/admin/config/search/xmlsitemap/{xmlsitemap}/edit' defaults: _entity_form: 'xmlsitemap.edit' @@ -30,7 +30,7 @@ xmlsitemap.admin_edit: requirements: _permission: 'administer xmlsitemap' -xmlsitemap.admin_delete: +entity.xmlsitemap.delete_form: path: '/admin/config/search/xmlsitemap/{xmlsitemap}/delete' defaults: _entity_form: 'xmlsitemap.delete'