Commit ec4cc107 authored by andrei.dincu's avatar andrei.dincu
Browse files

Issue #2249723 by andrei.dincu: Add container injection in...

Issue #2249723 by andrei.dincu: Add container injection in XmlSitemapEntitiesSettingsForm class for entity manager
parent 93c93a0c
......@@ -9,11 +9,14 @@ namespace Drupal\xmlsitemap\Form;
use Drupal\Core\Form\ConfigFormBase;
use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Entity\EntityManagerInterface;
use Drupal\Core\DependencyInjection\ContainerInjectionInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
* Configure what entities will be included in sitemap
*/
class XmlSitemapEntitiesSettingsForm extends ConfigFormBase {
class XmlSitemapEntitiesSettingsForm extends ConfigFormBase implements ContainerInjectionInterface {
/**
* Custom entities that can be included in sitemap.
......@@ -22,6 +25,13 @@ class XmlSitemapEntitiesSettingsForm extends ConfigFormBase {
*/
protected $entities;
/**
* The entity manager.
*
* @var \Drupal\Core\Entity\EntityManagerInterface
*/
protected $entityManager;
/**
* {@inheritdoc}
*/
......@@ -29,9 +39,27 @@ class XmlSitemapEntitiesSettingsForm extends ConfigFormBase {
return 'xmlsitemap_config_entities_settings_form';
}
public function __construct(ConfigFactoryInterface $config_factory) {
/**
* Constructs a ContentLanguageSettingsForm object.
*
* @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
* The config factory.
* @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager
* The entity manager.
*/
public function __construct(ConfigFactoryInterface $config_factory, EntityManagerInterface $entity_manager) {
parent::__construct($config_factory);
$this->entities = array('menu', 'user', 'taxonomy', 'node');
$this->entityManager = $entity_manager;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
return new static(
$container->get('config.factory'), $container->get('entity.manager')
);
}
/**
......
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