Skip to content
Snippets Groups Projects
Commit 1580ae5f authored by Viktor Holovachek's avatar Viktor Holovachek Committed by Valery Lourie
Browse files

Issue #3240059: Deprecated service - entity.manager

parent 71c13ab4
No related branches found
No related tags found
1 merge request!1Issue #3240059: Deprecated service - entity.manager
......@@ -2,7 +2,6 @@
namespace Drupal\simple_lazyloader\Form;
use Drupal\Core\Entity\EntityManager;
use Drupal\Core\Form\ConfigFormBase;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Entity\EntityTypeManagerInterface;
......@@ -14,15 +13,18 @@ use Drupal\Core\Config\ConfigFactoryInterface;
*/
class LazyloaderConfigForm extends ConfigFormBase {
/**
* Provides the entity_type.manager service.
*
* @var \Drupal\Core\Entity\EntityTypeManagerInterface
*/
protected $entityTypeManager;
protected $entityManager;
/**
* Class constructor.
* Constructs a LazyloaderConfigForm object.
*/
public function __construct(ConfigFactoryInterface $config_factory, EntityTypeManagerInterface $entityTypeManager, EntityManager $entityManager) {
public function __construct(ConfigFactoryInterface $config_factory, EntityTypeManagerInterface $entityTypeManager) {
parent::__construct($config_factory);
$this->entityManager = $entityManager;
$this->entityTypeManager = $entityTypeManager;
}
......@@ -32,8 +34,7 @@ class LazyloaderConfigForm extends ConfigFormBase {
public static function create(ContainerInterface $container) {
return new static(
$container->get('config.factory'),
$container->get('entity_type.manager'),
$container->get('entity.manager')
$container->get('entity_type.manager')
);
}
......@@ -41,18 +42,14 @@ class LazyloaderConfigForm extends ConfigFormBase {
* {@inheritdoc}
*/
public function getFormId() {
return 'simple_lazyloader';
}
/**
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state) {
$form = parent::buildForm($form, $form_state);
$config = $this->config('simple_lazyloader.settings');
$form['is_activated'] = [
......@@ -70,9 +67,9 @@ class LazyloaderConfigForm extends ConfigFormBase {
$form['container'] = [
'#type' => 'container',
'#states' => [
"visible" => [
'visible' => [
"input[name='activated_for_all']" => [
"checked" => FALSE,
'checked' => FALSE,
],
],
],
......@@ -100,26 +97,21 @@ class LazyloaderConfigForm extends ConfigFormBase {
];
$entity_type_definitions = $this->entityTypeManager->getDefinitions();
/* @var $definition EntityTypeInterface */
/* @var \Drupal\Core\Entity\EntityTypeInterface $definition */
foreach ($entity_type_definitions as $definition) {
$entity_id = $definition->get('id');
/**
* Check if the current entity is one of
* the available entities for the module.
**/
// Check if the current entity is one
// of the available entities for the module.
if (in_array($entity_id, $entities)) {
$bundles = $this->entityManager->getStorage($entity_id)->loadMultiple();
$bundles = $this->entityTypeManager->getStorage($entity_id)->loadMultiple();
$form[$entity_id] = [
'#title' => $definition->get('label'),
'#group' => 'deactivate_tabs',
'#type' => 'details',
];
/**
* Get all bundles for the specific Entity
* and create a form elements for them.
**/
// Get all bundles for the specific Entity
// and create a form elements for them.
foreach ($bundles as $bundle) {
switch ($entity_id) {
......@@ -169,18 +161,15 @@ class LazyloaderConfigForm extends ConfigFormBase {
$config->set('lazyloader_settings', $form_state->getValues());
$config->save();
}
/**
* {@inheritdoc}
*/
protected function getEditableConfigNames() {
return [
'simple_lazyloader.settings',
];
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment