Commit 07522ee6 authored by Dave Reid's avatar Dave Reid Committed by Dave Reid

Issue #3012402 by thalles, Dave Reid: Fixed XmlSitemapLinkBundleSettingsForm...

Issue #3012402 by thalles, Dave Reid: Fixed XmlSitemapLinkBundleSettingsForm to use dependency injection.
parent 959c7b52
......@@ -2,9 +2,12 @@
namespace Drupal\xmlsitemap\Form;
use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Form\ConfigFormBase;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\State\StateInterface;
use Drupal\Core\Url;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpFoundation\RedirectResponse;
/**
......@@ -17,6 +20,36 @@ class XmlSitemapLinkBundleSettingsForm extends ConfigFormBase {
private $bundle_type;
// @codingStandardsIgnoreEnd
/**
* The state system.
*
* @var \Drupal\Core\State\StateInterface
*/
protected $state;
/**
* Constructs a XmlSitemapLinkBundleSettingsForm object.
*
* @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
* The factory for configuration objects.
* @param \Drupal\Core\State\StateInterface $state
* The state system.
*/
public function __construct(ConfigFactoryInterface $config_factory, StateInterface $state) {
parent::__construct($config_factory);
$this->state = $state;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
return new static(
$container->get('config.factory'),
$container->get('state')
);
}
/**
* {@inheritdoc}
*/
......@@ -90,7 +123,7 @@ class XmlSitemapLinkBundleSettingsForm extends ConfigFormBase {
$xmlsitemap = $form_state->getValue('xmlsitemap');
xmlsitemap_link_bundle_settings_save($this->entity_type, $this->bundle_type, $xmlsitemap, TRUE);
\Drupal::state()->set('xmlsitemap_regenerate_needed', TRUE);
$this->state->set('xmlsitemap_regenerate_needed', TRUE);
$entity_info = $form['xmlsitemap']['#entity_info'];
if (!empty($form['xmlsitemap']['#show_message'])) {
......
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