diff --git a/modules/entity_form/src/Plugin/EntityBrowser/Widget/EntityForm.php b/modules/entity_form/src/Plugin/EntityBrowser/Widget/EntityForm.php index 50d33ec..bf3ceae 100644 --- a/modules/entity_form/src/Plugin/EntityBrowser/Widget/EntityForm.php +++ b/modules/entity_form/src/Plugin/EntityBrowser/Widget/EntityForm.php @@ -62,7 +62,7 @@ class EntityForm extends WidgetBase { $entity_type = $form_state->hasValue(array_merge($parents, ['entity_type'])) ? $form_state->getValue(array_merge($parents, ['entity_type'])) : $this->configuration['entity_type']; $bundle = $form_state->hasValue(array_merge($parents, ['bundle', 'select'])) ? $form_state->getValue(array_merge($parents, ['bundle', 'select'])) : $this->configuration['bundle']; - $definitions = $this->entityManager->getDefinitions(); + $definitions = $this->entityTypeManager->getDefinitions(); $entity_types = array_combine( array_keys($definitions), array_map(function (EntityTypeInterface $item) { return $item->getLabel(); }, $definitions) @@ -81,7 +81,7 @@ class EntityForm extends WidgetBase { $bundles = []; if ($entity_type) { - $definitions = $this->entityManager->getBundleInfo($entity_type); + $definitions = $this->entityTypeManager->getBundleInfo($entity_type); $bundles = array_map(function ($item) { return $item['label']; }, $definitions); } diff --git a/src/Controllers/EntityBrowserFormController.php b/src/Controllers/EntityBrowserFormController.php index ba06893..e7cffc4 100644 --- a/src/Controllers/EntityBrowserFormController.php +++ b/src/Controllers/EntityBrowserFormController.php @@ -12,7 +12,7 @@ use Drupal\Core\Controller\ControllerResolverInterface; use Drupal\Core\Controller\HtmlFormController; use Drupal\Core\DependencyInjection\ClassResolverInterface; use Drupal\Core\DependencyInjection\ContainerInjectionInterface; -use Drupal\Core\Entity\EntityManagerInterface; +use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\Core\Form\FormBuilderInterface; use Drupal\Core\Routing\RouteMatchInterface; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -55,15 +55,15 @@ class EntityBrowserFormController extends HtmlFormController implements Containe * The class resolver. * @param RouteMatchInterface $route_match * Current route match service. - * @param EntityManagerInterface $entity_manager - * Entity manager service. + * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager + * Entity type manager service. * @param \Symfony\Component\HttpFoundation\Request $request * Current request. */ - public function __construct(ControllerResolverInterface $controller_resolver, FormBuilderInterface $form_builder, ClassResolverInterface $class_resolver, RouteMatchInterface $route_match, EntityManagerInterface $entity_manager, Request $request) { + public function __construct(ControllerResolverInterface $controller_resolver, FormBuilderInterface $form_builder, ClassResolverInterface $class_resolver, RouteMatchInterface $route_match, EntityTypeManagerInterface $entity_type_manager, Request $request) { parent::__construct($controller_resolver, $form_builder, $class_resolver); $this->currentRouteMatch = $route_match; - $this->browserStorage = $entity_manager->getStorage('entity_browser'); + $this->browserStorage = $entity_type_manager->getStorage('entity_browser'); $this->request = $request; $this->formBuilder = $form_builder; } diff --git a/src/Permissions.php b/src/Permissions.php index a25fc9d..b162dd5 100644 --- a/src/Permissions.php +++ b/src/Permissions.php @@ -8,7 +8,7 @@ namespace Drupal\entity_browser; use Drupal\Core\DependencyInjection\ContainerInjectionInterface; -use Drupal\Core\Entity\EntityManagerInterface; +use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\Core\StringTranslation\TranslationManager; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -34,12 +34,12 @@ class Permissions implements ContainerInjectionInterface { /** * Constructs Permissions object. * - * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager + * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager * Entity manager service. * @param \Drupal\Core\StringTranslation\TranslationManager $translation */ - public function __construct(EntityManagerInterface $entity_manager, TranslationManager $translation) { - $this->browserStorage = $entity_manager->getStorage('entity_browser'); + public function __construct(EntityTypeManagerInterface $entity_type_manager, TranslationManager $translation) { + $this->browserStorage = $entity_type_manager->getStorage('entity_browser'); $this->translationManager = $translation; } @@ -48,7 +48,7 @@ class Permissions implements ContainerInjectionInterface { */ public static function create(ContainerInterface $container) { return new static( - $container->get('entity.manager'), + $container->get('entity_type.manager'), $container->get('string_translation') ); } diff --git a/src/Plugin/EntityBrowser/SelectionDisplay/MultiStepDisplay.php b/src/Plugin/EntityBrowser/SelectionDisplay/MultiStepDisplay.php index 69ca549..3c862cc 100644 --- a/src/Plugin/EntityBrowser/SelectionDisplay/MultiStepDisplay.php +++ b/src/Plugin/EntityBrowser/SelectionDisplay/MultiStepDisplay.php @@ -2,8 +2,7 @@ namespace Drupal\entity_browser\Plugin\EntityBrowser\SelectionDisplay; -use Drupal\Component\Utility\Html; -use Drupal\Core\Entity\EntityManagerInterface; +use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\Core\Form\FormStateInterface; use Drupal\entity_browser\FieldWidgetDisplayManager; use Drupal\entity_browser\SelectionDisplayBase; @@ -39,13 +38,13 @@ class MultiStepDisplay extends SelectionDisplayBase { * The plugin implementation definition. * @param \Symfony\Component\EventDispatcher\EventDispatcherInterface $event_dispatcher * Event dispatcher service. - * @param \Drupal\Core\Entity\EntityManagerInterface + * @param \Drupal\Core\Entity\EntityTypeManagerInterface * Entity manager service. * @param \Drupal\entity_browser\FieldWidgetDisplayManager $field_display_manager * Field widget display plugin manager. */ - public function __construct(array $configuration, $plugin_id, $plugin_definition, EventDispatcherInterface $event_dispatcher, EntityManagerInterface $entity_manager, FieldWidgetDisplayManager $field_display_manager) { - parent::__construct($configuration, $plugin_id, $plugin_definition, $event_dispatcher, $entity_manager); + public function __construct(array $configuration, $plugin_id, $plugin_definition, EventDispatcherInterface $event_dispatcher, EntityTypeManagerInterface $entity_type_manager, FieldWidgetDisplayManager $field_display_manager) { + parent::__construct($configuration, $plugin_id, $plugin_definition, $event_dispatcher, $entity_type_manager); $this->fieldDisplayManager = $field_display_manager; } @@ -58,7 +57,7 @@ class MultiStepDisplay extends SelectionDisplayBase { $plugin_id, $plugin_definition, $container->get('event_dispatcher'), - $container->get('entity.manager'), + $container->get('entity_type.manager'), $container->get('plugin.manager.entity_browser.field_widget_display') ); } @@ -198,7 +197,7 @@ class MultiStepDisplay extends SelectionDisplayBase { $form['#suffix'] = ''; $entity_types = []; - foreach ($this->entityManager->getDefinitions() as $entity_type_id => $entity_type) { + foreach ($this->entityTypeManager->getDefinitions() as $entity_type_id => $entity_type) { /** @var \Drupal\Core\Entity\EntityTypeInterface $entity_type */ $entity_types[$entity_type_id] = $entity_type->getLabel(); } @@ -216,7 +215,7 @@ class MultiStepDisplay extends SelectionDisplayBase { $displays = []; foreach ($this->fieldDisplayManager->getDefinitions() as $display_plugin_id => $definition) { - $entity_type = $this->entityManager->getDefinition($default_entity_type); + $entity_type = $this->entityTypeManager->getDefinition($default_entity_type); if ($this->fieldDisplayManager->createInstance($display_plugin_id)->isApplicable($entity_type)) { $displays[$display_plugin_id] = $definition['label']; } diff --git a/src/Plugin/EntityBrowser/SelectionDisplay/View.php b/src/Plugin/EntityBrowser/SelectionDisplay/View.php index 74a9990..4e1817d 100644 --- a/src/Plugin/EntityBrowser/SelectionDisplay/View.php +++ b/src/Plugin/EntityBrowser/SelectionDisplay/View.php @@ -41,7 +41,7 @@ class View extends SelectionDisplayBase { // either of those is nonexistent or display not of correct type)? $storage = &$form_state->getStorage(); if (empty($storage['selection_display_view']) || $form_state->isRebuilding()) { - $storage['selection_display_view'] = $this->entityManager + $storage['selection_display_view'] = $this->entityTypeManager ->getStorage('view') ->load($this->configuration['view']) ->getExecutable(); diff --git a/src/Plugin/EntityBrowser/Widget/View.php b/src/Plugin/EntityBrowser/Widget/View.php index eb22f7e..d9eb048 100644 --- a/src/Plugin/EntityBrowser/Widget/View.php +++ b/src/Plugin/EntityBrowser/Widget/View.php @@ -15,7 +15,7 @@ use Symfony\Component\DependencyInjection\ContainerInterface; use Drupal\Core\Session\AccountInterface; use Drupal\Core\Plugin\ContainerFactoryPluginInterface; use Symfony\Component\EventDispatcher\EventDispatcherInterface; -use Drupal\Core\Entity\EntityManagerInterface; +use Drupal\Core\Entity\EntityTypeManagerInterface; /** * Uses a view to provide entity listing in a browser's widget. @@ -54,7 +54,7 @@ class View extends WidgetBase implements ContainerFactoryPluginInterface { $plugin_id, $plugin_definition, $container->get('event_dispatcher'), - $container->get('entity.manager'), + $container->get('entity_type.manager'), $container->get('current_user') ); } @@ -70,11 +70,13 @@ class View extends WidgetBase implements ContainerFactoryPluginInterface { * The plugin implementation definition. * @param \Symfony\Component\EventDispatcher\EventDispatcherInterface $event_dispatcher * Event dispatcher service. + * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager + * The entity type manager. * @param \Drupal\Core\Session\AccountInterface $current_user * The current user. */ - public function __construct(array $configuration, $plugin_id, $plugin_definition, EventDispatcherInterface $event_dispatcher, EntityManagerInterface $entity_manager, AccountInterface $current_user) { - parent::__construct($configuration, $plugin_id, $plugin_definition, $event_dispatcher, $entity_manager); + public function __construct(array $configuration, $plugin_id, $plugin_definition, EventDispatcherInterface $event_dispatcher, EntityTypeManagerInterface $entity_type_manager, AccountInterface $current_user) { + parent::__construct($configuration, $plugin_id, $plugin_definition, $event_dispatcher, $entity_type_manager); $this->currentUser = $current_user; } @@ -89,7 +91,7 @@ class View extends WidgetBase implements ContainerFactoryPluginInterface { $form['#attached']['library'] = ['entity_browser/view']; /** @var \Drupal\views\ViewExecutable $view */ - $view = $this->entityManager + $view = $this->entityTypeManager ->getStorage('view') ->load($this->configuration['view']) ->getExecutable(); @@ -171,7 +173,7 @@ class View extends WidgetBase implements ContainerFactoryPluginInterface { // Make sure we have a type and id present. if (count($parts) == 2) { try { - $storage = $this->entityManager->getStorage($parts[0]); + $storage = $this->entityTypeManager->getStorage($parts[0]); if (!$storage->load($parts[1])) { $message = t('The @type Entity @id does not exist.', [ '@type' => $parts[0], @@ -200,7 +202,7 @@ class View extends WidgetBase implements ContainerFactoryPluginInterface { $entities = []; foreach ($selected_rows as $row) { list($type, $id) = explode(':', $row); - $storage = $this->entityManager->getStorage($type); + $storage = $this->entityTypeManager->getStorage($type); if ($entity = $storage->load($id)) { $entities[] = $entity; } diff --git a/src/Plugin/Field/FieldWidget/EntityReference.php b/src/Plugin/Field/FieldWidget/EntityReference.php index 6cb8fc9..62b8e52 100644 --- a/src/Plugin/Field/FieldWidget/EntityReference.php +++ b/src/Plugin/Field/FieldWidget/EntityReference.php @@ -220,7 +220,7 @@ class EntityReference extends WidgetBase implements ContainerFactoryPluginInterf return [t('No entity browser selected.')]; } else { - if ($browser = $this->entityManager->getStorage('entity_browser')->load($entity_browser_id)) { + if ($browser = $this->entityTypeManager->getStorage('entity_browser')->load($entity_browser_id)) { $summary[] = t('Entity browser: @browser', ['@browser' => $browser->label()]); } else { drupal_set_message(t('Missing entity browser!'), 'error'); diff --git a/src/RouteSubscriber.php b/src/RouteSubscriber.php index d3e0926..26b7663 100644 --- a/src/RouteSubscriber.php +++ b/src/RouteSubscriber.php @@ -7,7 +7,7 @@ namespace Drupal\entity_browser; -use Drupal\Core\Entity\EntityManagerInterface; +use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\Core\Entity\Query\QueryFactory; use Symfony\Component\Routing\RouteCollection; @@ -40,11 +40,15 @@ class RouteSubscriber { /** * Constructs a \Drupal\views\EventSubscriber\RouteSubscriber instance. * - * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager + * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager * The entity manager. + * @param \Drupal\entity_browser\DisplayManager $display_manager + * The display manager. + * @param \Drupal\Core\Entity\Query\QueryFactory $entity_query + * The entity query factory. */ - public function __construct(EntityManagerInterface $entity_manager, DisplayManager $display_manager, QueryFactory $entity_query) { - $this->browserStorage = $entity_manager->getStorage('entity_browser'); + public function __construct(EntityTypeManagerInterface $entity_type_manager, DisplayManager $display_manager, QueryFactory $entity_query) { + $this->browserStorage = $entity_type_manager->getStorage('entity_browser'); $this->displayManager = $display_manager; $this->browserQuery = $entity_query->get('entity_browser'); } diff --git a/src/SelectionDisplayBase.php b/src/SelectionDisplayBase.php index 9bd794f..e0e09d2 100644 --- a/src/SelectionDisplayBase.php +++ b/src/SelectionDisplayBase.php @@ -7,7 +7,7 @@ namespace Drupal\entity_browser; use Drupal\Core\Plugin\PluginBase; -use Drupal\Core\Entity\EntityManagerInterface; +use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Plugin\ContainerFactoryPluginInterface; use Drupal\entity_browser\Events\Events; @@ -39,9 +39,9 @@ abstract class SelectionDisplayBase extends PluginBase implements SelectionDispl /** * Entity manager service. * - * @var \Drupal\Core\Entity\EntityManagerInterface + * @var \Drupal\Core\Entity\EntityTypeManagerInterface */ - protected $entityManager; + protected $entityTypeManager; /** * Constructs widget plugin. @@ -54,13 +54,13 @@ abstract class SelectionDisplayBase extends PluginBase implements SelectionDispl * The plugin implementation definition. * @param \Symfony\Component\EventDispatcher\EventDispatcherInterface $event_dispatcher * Event dispatcher service. - * @param \Drupal\Core\Entity\EntityManagerInterface + * @param \Drupal\Core\Entity\EntityTypeManagerInterface * Entity manager service. */ - public function __construct(array $configuration, $plugin_id, $plugin_definition, EventDispatcherInterface $event_dispatcher, EntityManagerInterface $entity_manager) { + public function __construct(array $configuration, $plugin_id, $plugin_definition, EventDispatcherInterface $event_dispatcher, EntityTypeManagerInterface $entity_manager) { parent::__construct($configuration, $plugin_id, $plugin_definition); $this->eventDispatcher = $event_dispatcher; - $this->entityManager = $entity_manager; + $this->entityTypeManager = $entity_manager; $this->setConfiguration($configuration); } @@ -73,7 +73,7 @@ abstract class SelectionDisplayBase extends PluginBase implements SelectionDispl $plugin_id, $plugin_definition, $container->get('event_dispatcher'), - $container->get('entity.manager') + $container->get('entity_type.manager') ); } diff --git a/src/WidgetBase.php b/src/WidgetBase.php index 22dfa4d..dbffafa 100644 --- a/src/WidgetBase.php +++ b/src/WidgetBase.php @@ -6,8 +6,8 @@ namespace Drupal\entity_browser; +use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\Core\Plugin\PluginBase; -use Drupal\Core\Entity\EntityManagerInterface; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Plugin\ContainerFactoryPluginInterface; use Drupal\entity_browser\Events\EntitySelectionEvent; @@ -57,11 +57,11 @@ abstract class WidgetBase extends PluginBase implements WidgetInterface, Contain protected $eventDispatcher; /** - * Entity manager service. + * Entity type manager service. * - * @var \Drupal\Core\Entity\EntityManagerInterface + * @var \Drupal\Core\Entity\EntityTypeManagerInterface */ - protected $entityManager; + protected $entityTypeManager; /** * Constructs widget plugin. @@ -74,11 +74,13 @@ abstract class WidgetBase extends PluginBase implements WidgetInterface, Contain * The plugin implementation definition. * @param \Symfony\Component\EventDispatcher\EventDispatcherInterface $event_dispatcher * Event dispatcher service. + * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_manager + * The entity type manager service. */ - public function __construct(array $configuration, $plugin_id, $plugin_definition, EventDispatcherInterface $event_dispatcher, EntityManagerInterface $entity_manager) { + public function __construct(array $configuration, $plugin_id, $plugin_definition, EventDispatcherInterface $event_dispatcher, EntityTypeManagerInterface $entity_manager) { parent::__construct($configuration, $plugin_id, $plugin_definition); $this->eventDispatcher = $event_dispatcher; - $this->entityManager = $entity_manager; + $this->entityTypeManager = $entity_manager; $this->setConfiguration($configuration); }