Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Open sidebar
project
paragraphs
Commits
19e82d38
Commit
19e82d38
authored
Dec 10, 2019
by
Berdir
Committed by
Berdir
Dec 10, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue
#3083331
by Berdir, pratik_kamble, ravi.shankar: Removing deprecated method entityManager
parent
60451785
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
17 additions
and
90 deletions
+17
-90
modules/paragraphs_library/paragraphs_library.install
modules/paragraphs_library/paragraphs_library.install
+2
-2
modules/paragraphs_library/src/Form/LibraryItemForm.php
modules/paragraphs_library/src/Form/LibraryItemForm.php
+4
-31
src/Feeds/Target/Paragraphs.php
src/Feeds/Target/Paragraphs.php
+1
-1
src/Plugin/EntityReferenceSelection/ParagraphSelection.php
src/Plugin/EntityReferenceSelection/ParagraphSelection.php
+3
-49
src/Plugin/Field/FieldWidget/InlineParagraphsWidget.php
src/Plugin/Field/FieldWidget/InlineParagraphsWidget.php
+3
-3
src/Plugin/migrate/source/DrupalSqlBase.php
src/Plugin/migrate/source/DrupalSqlBase.php
+2
-2
src/Plugin/migrate/source/d7/FieldableEntity.php
src/Plugin/migrate/source/d7/FieldableEntity.php
+2
-2
No files found.
modules/paragraphs_library/paragraphs_library.install
View file @
19e82d38
...
...
@@ -65,7 +65,7 @@ function paragraphs_library_install() {
*/
function
paragraphs_library_update_8001
()
{
\
Drupal
::
service
(
'entity.manager'
)
->
clearCachedDefinitions
();
\
Drupal
::
service
(
'entity
_type
.manager'
)
->
clearCachedDefinitions
();
// Load all library items and store their values in memory.
$library_values
=
\
Drupal
::
database
()
->
query
(
'SELECT * FROM {paragraphs_library_item}'
)
->
fetchAll
(
PDO
::
FETCH_ASSOC
);
...
...
@@ -110,7 +110,7 @@ function paragraphs_library_update_8001() {
$entity_definition_update_manager
->
installFieldStorageDefinition
(
'langcode'
,
$entity_type
->
id
(),
'paragraphs_library'
,
$langcode_field
);
$entity_definition_update_manager
->
installFieldStorageDefinition
(
'default_langcode'
,
$entity_type
->
id
(),
'paragraphs_library'
,
$default_langcode_field
);
\
Drupal
::
entityManager
()
->
clearCachedDefinitions
();
\
Drupal
::
entity
Type
Manager
()
->
clearCachedDefinitions
();
foreach
(
$library_values
as
$library_value
)
{
$library_value
[
'paragraphs'
]
=
[
'target_id'
=>
$library_value
[
'paragraphs__target_id'
],
...
...
modules/paragraphs_library/src/Form/LibraryItemForm.php
View file @
19e82d38
...
...
@@ -3,10 +3,10 @@
namespace
Drupal\paragraphs_library\Form
;
use
Drupal\Core\Entity\ContentEntityForm
;
use
Drupal\Core\Entity\EntityTypeManagerInterface
;
use
Drupal\Core\Form\FormStateInterface
;
use
Drupal\Core\Messenger\MessengerInterface
;
use
Symfony\Component\DependencyInjection\ContainerInterface
;
use
Drupal\Core\Entity\EntityManagerInterface
;
use
Drupal\Core\Entity\EntityTypeBundleInfoInterface
;
use
Drupal\Component\Datetime\TimeInterface
;
...
...
@@ -20,30 +20,6 @@ class LibraryItemForm extends ContentEntityForm {
*/
protected
$entity
;
/**
* Provides messenger service.
*
* @var \Drupal\Core\Messenger\Messenger
*/
protected
$messenger
;
/**
* Constructs a LibraryItemForm object.
*
* @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager
* The entity manager.
* @param \Drupal\Core\Messenger\MessengerInterface $messenger
* The messenger service.
* @param \Drupal\Core\Entity\EntityTypeBundleInfoInterface $entity_type_bundle_info
* The entity type bundle service.
* @param \Drupal\Component\Datetime\TimeInterface $time
* The time service.
*/
public
function
__construct
(
EntityManagerInterface
$entity_manager
,
MessengerInterface
$messenger
,
EntityTypeBundleInfoInterface
$entity_type_bundle_info
=
NULL
,
TimeInterface
$time
=
NULL
)
{
parent
::
__construct
(
$entity_manager
,
$entity_type_bundle_info
,
$time
);
$this
->
messenger
=
$messenger
;
}
/**
* {@inheritdoc}
*/
...
...
@@ -61,12 +37,9 @@ class LibraryItemForm extends ContentEntityForm {
* {@inheritdoc}
*/
public
static
function
create
(
ContainerInterface
$container
)
{
return
new
static
(
$container
->
get
(
'entity.manager'
),
$container
->
get
(
'messenger'
),
$container
->
get
(
'entity_type.bundle.info'
),
$container
->
get
(
'datetime.time'
)
);
$form
=
parent
::
create
(
$container
);
$form
->
setMessenger
(
$container
->
get
(
'messenger'
));
return
$form
;
}
/**
...
...
src/Feeds/Target/Paragraphs.php
View file @
19e82d38
...
...
@@ -15,7 +15,7 @@ use Drupal\feeds\Plugin\Type\Target\ConfigurableTargetInterface;
* @FeedsTarget(
* id = "paragraphs",
* field_types = {"entity_reference_revisions"},
* arguments = {"@entity.manager", "@current_user"}
* arguments = {"@entity
_type
.manager", "@current_user"}
* )
*/
class
Paragraphs
extends
Text
implements
ConfigurableTargetInterface
{
...
...
src/Plugin/EntityReferenceSelection/ParagraphSelection.php
View file @
19e82d38
...
...
@@ -2,8 +2,8 @@
namespace
Drupal\paragraphs\Plugin\EntityReferenceSelection
;
use
Drupal\Core\Entity\EntityManagerInterface
;
use
Drupal\Core\Entity\EntityTypeBundleInfoInterface
;
use
Drupal\Core\Entity\EntityTypeManagerInterface
;
use
Drupal\Core\Entity\Plugin\EntityReferenceSelection\DefaultSelection
;
use
Drupal\Core\Extension\ModuleHandlerInterface
;
use
Drupal\Core\Session\AccountInterface
;
...
...
@@ -25,52 +25,6 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
*/
class
ParagraphSelection
extends
DefaultSelection
{
/**
* Entity type bundle info service.
*
* @var \Drupal\Core\Entity\EntityTypeBundleInfoInterface
*/
public
$entityTypeBundleInfo
;
/**
* ParagraphSelection constructor.
*
* @param array $configuration
* A configuration array containing information about the plugin instance.
* @param string $plugin_id
* The plugin_id for the plugin instance.
* @param mixed $plugin_definition
* The plugin implementation definition.
* @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager
* The entity manager service.
* @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
* The module handler service.
* @param \Drupal\Core\Session\AccountInterface $current_user
* The current user.
* @param \Drupal\Core\Entity\EntityTypeBundleInfoInterface $entity_type_bundle_info
* Entity type bundle info service.
*/
public
function
__construct
(
array
$configuration
,
$plugin_id
,
$plugin_definition
,
EntityManagerInterface
$entity_manager
,
ModuleHandlerInterface
$module_handler
,
AccountInterface
$current_user
,
EntityTypeBundleInfoInterface
$entity_type_bundle_info
)
{
parent
::
__construct
(
$configuration
,
$plugin_id
,
$plugin_definition
,
$entity_manager
,
$module_handler
,
$current_user
);
$this
->
entityTypeBundleInfo
=
$entity_type_bundle_info
;
}
/**
* {@inheritdoc}
*/
public
static
function
create
(
ContainerInterface
$container
,
array
$configuration
,
$plugin_id
,
$plugin_definition
)
{
return
new
static
(
$configuration
,
$plugin_id
,
$plugin_definition
,
$container
->
get
(
'entity.manager'
),
$container
->
get
(
'module_handler'
),
$container
->
get
(
'current_user'
),
$container
->
get
(
'entity_type.bundle.info'
)
);
}
/**
* {@inheritdoc}
*/
...
...
@@ -297,9 +251,9 @@ class ParagraphSelection extends DefaultSelection {
protected
function
buildEntityQuery
(
$match
=
NULL
,
$match_operator
=
'CONTAINS'
)
{
$target_type
=
$this
->
configuration
[
'target_type'
];
$handler_settings
=
$this
->
configuration
[
'handler_settings'
];
$entity_type
=
$this
->
entityManager
->
getDefinition
(
$target_type
);
$entity_type
=
$this
->
entity
Type
Manager
->
getDefinition
(
$target_type
);
$query
=
$this
->
entityManager
->
getStorage
(
$target_type
)
->
getQuery
();
$query
=
$this
->
entity
Type
Manager
->
getStorage
(
$target_type
)
->
getQuery
();
// If 'target_bundles' is NULL, all bundles are referenceable, no further
// conditions are needed.
...
...
src/Plugin/Field/FieldWidget/InlineParagraphsWidget.php
View file @
19e82d38
...
...
@@ -230,7 +230,7 @@ class InlineParagraphsWidget extends WidgetBase {
$host
=
$items
->
getEntity
();
$widget_state
=
static
::
getWidgetState
(
$parents
,
$field_name
,
$form_state
);
$entity_manager
=
\
Drupal
::
entityTypeManager
();
$entity_
type_
manager
=
\
Drupal
::
entityTypeManager
();
$target_type
=
$this
->
getFieldSetting
(
'target_type'
);
$item_mode
=
isset
(
$widget_state
[
'paragraphs'
][
$delta
][
'mode'
])
?
$widget_state
[
'paragraphs'
][
$delta
][
'mode'
]
:
'edit'
;
...
...
@@ -260,10 +260,10 @@ class InlineParagraphsWidget extends WidgetBase {
}
elseif
(
isset
(
$widget_state
[
'selected_bundle'
]))
{
$entity_type
=
$entity_manager
->
getDefinition
(
$target_type
);
$entity_type
=
$entity_
type_
manager
->
getDefinition
(
$target_type
);
$bundle_key
=
$entity_type
->
getKey
(
'bundle'
);
$paragraphs_entity
=
$entity_manager
->
getStorage
(
$target_type
)
->
create
(
array
(
$paragraphs_entity
=
$entity_
type_
manager
->
getStorage
(
$target_type
)
->
create
(
array
(
$bundle_key
=>
$widget_state
[
'selected_bundle'
],
));
$paragraphs_entity
->
setParentEntity
(
$items
->
getEntity
(),
$field_name
);
...
...
src/Plugin/migrate/source/DrupalSqlBase.php
View file @
19e82d38
...
...
@@ -20,8 +20,8 @@ abstract class DrupalSqlBase extends MigrateDrupalSqlBase implements Configurabl
/**
* {@inheritdoc}
*/
public
function
__construct
(
array
$configuration
,
$plugin_id
,
$plugin_definition
,
MigrationInterface
$migration
,
StateInterface
$state
,
EntityTypeManagerInterface
$entity_manager
)
{
parent
::
__construct
(
$configuration
,
$plugin_id
,
$plugin_definition
,
$migration
,
$state
,
$entity_manager
);
public
function
__construct
(
array
$configuration
,
$plugin_id
,
$plugin_definition
,
MigrationInterface
$migration
,
StateInterface
$state
,
EntityTypeManagerInterface
$entity_
type_
manager
)
{
parent
::
__construct
(
$configuration
,
$plugin_id
,
$plugin_definition
,
$migration
,
$state
,
$entity_
type_
manager
);
$this
->
setConfiguration
(
$configuration
);
}
...
...
src/Plugin/migrate/source/d7/FieldableEntity.php
View file @
19e82d38
...
...
@@ -20,8 +20,8 @@ abstract class FieldableEntity extends MigrateFieldableEntity implements Configu
/**
* {@inheritdoc}
*/
public
function
__construct
(
array
$configuration
,
$plugin_id
,
$plugin_definition
,
MigrationInterface
$migration
,
StateInterface
$state
,
EntityTypeManagerInterface
$entity_manager
)
{
parent
::
__construct
(
$configuration
,
$plugin_id
,
$plugin_definition
,
$migration
,
$state
,
$entity_manager
);
public
function
__construct
(
array
$configuration
,
$plugin_id
,
$plugin_definition
,
MigrationInterface
$migration
,
StateInterface
$state
,
EntityTypeManagerInterface
$entity_
type_
manager
)
{
parent
::
__construct
(
$configuration
,
$plugin_id
,
$plugin_definition
,
$migration
,
$state
,
$entity_
type_
manager
);
$this
->
setConfiguration
(
$configuration
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment