Commit 19e82d38 authored by Berdir's avatar Berdir Committed by Berdir

Issue #3083331 by Berdir, pratik_kamble, ravi.shankar: Removing deprecated method entityManager

parent 60451785
...@@ -65,7 +65,7 @@ function paragraphs_library_install() { ...@@ -65,7 +65,7 @@ function paragraphs_library_install() {
*/ */
function paragraphs_library_update_8001() { 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. // Load all library items and store their values in memory.
$library_values = \Drupal::database()->query('SELECT * FROM {paragraphs_library_item}')->fetchAll(PDO::FETCH_ASSOC); $library_values = \Drupal::database()->query('SELECT * FROM {paragraphs_library_item}')->fetchAll(PDO::FETCH_ASSOC);
...@@ -110,7 +110,7 @@ function paragraphs_library_update_8001() { ...@@ -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('langcode', $entity_type->id(), 'paragraphs_library', $langcode_field);
$entity_definition_update_manager->installFieldStorageDefinition('default_langcode', $entity_type->id(), 'paragraphs_library', $default_langcode_field); $entity_definition_update_manager->installFieldStorageDefinition('default_langcode', $entity_type->id(), 'paragraphs_library', $default_langcode_field);
\Drupal::entityManager()->clearCachedDefinitions(); \Drupal::entityTypeManager()->clearCachedDefinitions();
foreach ($library_values as $library_value) { foreach ($library_values as $library_value) {
$library_value['paragraphs'] = [ $library_value['paragraphs'] = [
'target_id' => $library_value['paragraphs__target_id'], 'target_id' => $library_value['paragraphs__target_id'],
......
...@@ -3,10 +3,10 @@ ...@@ -3,10 +3,10 @@
namespace Drupal\paragraphs_library\Form; namespace Drupal\paragraphs_library\Form;
use Drupal\Core\Entity\ContentEntityForm; use Drupal\Core\Entity\ContentEntityForm;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Messenger\MessengerInterface; use Drupal\Core\Messenger\MessengerInterface;
use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\DependencyInjection\ContainerInterface;
use Drupal\Core\Entity\EntityManagerInterface;
use Drupal\Core\Entity\EntityTypeBundleInfoInterface; use Drupal\Core\Entity\EntityTypeBundleInfoInterface;
use Drupal\Component\Datetime\TimeInterface; use Drupal\Component\Datetime\TimeInterface;
...@@ -20,30 +20,6 @@ class LibraryItemForm extends ContentEntityForm { ...@@ -20,30 +20,6 @@ class LibraryItemForm extends ContentEntityForm {
*/ */
protected $entity; 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} * {@inheritdoc}
*/ */
...@@ -61,12 +37,9 @@ class LibraryItemForm extends ContentEntityForm { ...@@ -61,12 +37,9 @@ class LibraryItemForm extends ContentEntityForm {
* {@inheritdoc} * {@inheritdoc}
*/ */
public static function create(ContainerInterface $container) { public static function create(ContainerInterface $container) {
return new static( $form = parent::create($container);
$container->get('entity.manager'), $form->setMessenger($container->get('messenger'));
$container->get('messenger'), return $form;
$container->get('entity_type.bundle.info'),
$container->get('datetime.time')
);
} }
/** /**
......
...@@ -15,7 +15,7 @@ use Drupal\feeds\Plugin\Type\Target\ConfigurableTargetInterface; ...@@ -15,7 +15,7 @@ use Drupal\feeds\Plugin\Type\Target\ConfigurableTargetInterface;
* @FeedsTarget( * @FeedsTarget(
* id = "paragraphs", * id = "paragraphs",
* field_types = {"entity_reference_revisions"}, * field_types = {"entity_reference_revisions"},
* arguments = {"@entity.manager", "@current_user"} * arguments = {"@entity_type.manager", "@current_user"}
* ) * )
*/ */
class Paragraphs extends Text implements ConfigurableTargetInterface { class Paragraphs extends Text implements ConfigurableTargetInterface {
......
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
namespace Drupal\paragraphs\Plugin\EntityReferenceSelection; namespace Drupal\paragraphs\Plugin\EntityReferenceSelection;
use Drupal\Core\Entity\EntityManagerInterface;
use Drupal\Core\Entity\EntityTypeBundleInfoInterface; use Drupal\Core\Entity\EntityTypeBundleInfoInterface;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Entity\Plugin\EntityReferenceSelection\DefaultSelection; use Drupal\Core\Entity\Plugin\EntityReferenceSelection\DefaultSelection;
use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\Core\Session\AccountInterface; use Drupal\Core\Session\AccountInterface;
...@@ -25,52 +25,6 @@ use Symfony\Component\DependencyInjection\ContainerInterface; ...@@ -25,52 +25,6 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
*/ */
class ParagraphSelection extends DefaultSelection { 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} * {@inheritdoc}
*/ */
...@@ -297,9 +251,9 @@ class ParagraphSelection extends DefaultSelection { ...@@ -297,9 +251,9 @@ class ParagraphSelection extends DefaultSelection {
protected function buildEntityQuery($match = NULL, $match_operator = 'CONTAINS') { protected function buildEntityQuery($match = NULL, $match_operator = 'CONTAINS') {
$target_type = $this->configuration['target_type']; $target_type = $this->configuration['target_type'];
$handler_settings = $this->configuration['handler_settings']; $handler_settings = $this->configuration['handler_settings'];
$entity_type = $this->entityManager->getDefinition($target_type); $entity_type = $this->entityTypeManager->getDefinition($target_type);
$query = $this->entityManager->getStorage($target_type)->getQuery(); $query = $this->entityTypeManager->getStorage($target_type)->getQuery();
// If 'target_bundles' is NULL, all bundles are referenceable, no further // If 'target_bundles' is NULL, all bundles are referenceable, no further
// conditions are needed. // conditions are needed.
......
...@@ -230,7 +230,7 @@ class InlineParagraphsWidget extends WidgetBase { ...@@ -230,7 +230,7 @@ class InlineParagraphsWidget extends WidgetBase {
$host = $items->getEntity(); $host = $items->getEntity();
$widget_state = static::getWidgetState($parents, $field_name, $form_state); $widget_state = static::getWidgetState($parents, $field_name, $form_state);
$entity_manager = \Drupal::entityTypeManager(); $entity_type_manager = \Drupal::entityTypeManager();
$target_type = $this->getFieldSetting('target_type'); $target_type = $this->getFieldSetting('target_type');
$item_mode = isset($widget_state['paragraphs'][$delta]['mode']) ? $widget_state['paragraphs'][$delta]['mode'] : 'edit'; $item_mode = isset($widget_state['paragraphs'][$delta]['mode']) ? $widget_state['paragraphs'][$delta]['mode'] : 'edit';
...@@ -260,10 +260,10 @@ class InlineParagraphsWidget extends WidgetBase { ...@@ -260,10 +260,10 @@ class InlineParagraphsWidget extends WidgetBase {
} }
elseif (isset($widget_state['selected_bundle'])) { 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'); $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'], $bundle_key => $widget_state['selected_bundle'],
)); ));
$paragraphs_entity->setParentEntity($items->getEntity(), $field_name); $paragraphs_entity->setParentEntity($items->getEntity(), $field_name);
......
...@@ -20,8 +20,8 @@ abstract class DrupalSqlBase extends MigrateDrupalSqlBase implements Configurabl ...@@ -20,8 +20,8 @@ abstract class DrupalSqlBase extends MigrateDrupalSqlBase implements Configurabl
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration, StateInterface $state, EntityTypeManagerInterface $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_manager); parent::__construct($configuration, $plugin_id, $plugin_definition, $migration, $state, $entity_type_manager);
$this->setConfiguration($configuration); $this->setConfiguration($configuration);
} }
......
...@@ -20,8 +20,8 @@ abstract class FieldableEntity extends MigrateFieldableEntity implements Configu ...@@ -20,8 +20,8 @@ abstract class FieldableEntity extends MigrateFieldableEntity implements Configu
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration, StateInterface $state, EntityTypeManagerInterface $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_manager); parent::__construct($configuration, $plugin_id, $plugin_definition, $migration, $state, $entity_type_manager);
$this->setConfiguration($configuration); $this->setConfiguration($configuration);
} }
......
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