Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
simple_lazyloader
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
simple_lazyloader
Commits
1580ae5f
Commit
1580ae5f
authored
2 months ago
by
Viktor Holovachek
Committed by
Valery Lourie
2 months ago
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#3240059
: Deprecated service - entity.manager
parent
71c13ab4
No related branches found
No related tags found
1 merge request
!1
Issue #3240059: Deprecated service - entity.manager
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/Form/LazyloaderConfigForm.php
+16
-27
16 additions, 27 deletions
src/Form/LazyloaderConfigForm.php
with
16 additions
and
27 deletions
src/Form/LazyloaderConfigForm.php
+
16
−
27
View file @
1580ae5f
...
...
@@ -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
;
/**
* C
lass c
onstruct
or
.
* Construct
s 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
->
entity
Type
Manager
->
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'
,
];
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment