diff -u b/core/core.services.yml b/core/core.services.yml --- b/core/core.services.yml +++ b/core/core.services.yml @@ -466,7 +466,7 @@ arguments: ['@app.root', '%container.modules%', '@cache.bootstrap'] module_installer: class: Drupal\Core\Extension\ModuleInstaller - arguments: ['@app.root', '@module_handler', '@kernel', '@config.factory', '@config.installer', '@plugin.cache_clearer', '@router.builder', '@entity.manager', '@stream_wrapper_manager', '@theme_handler', '@logger.channel.modules', '@config.manager', '@keyvalue', '@entity.definition_update_manager'] + arguments: ['@app.root', '@module_handler', '@kernel', '@config.factory', '@config.installer', '@plugin.cache_clearer', '@router.builder', '@stream_wrapper_manager', '@theme_handler', '@logger.channel.modules', '@config.manager', '@keyvalue'] tags: - { name: service_collector, tag: 'module_install.uninstall_validator', call: addUninstallValidator } arguments: ['@app.root', '@module_handler', '@kernel'] diff -u b/core/lib/Drupal/Core/Extension/ModuleInstaller.php b/core/lib/Drupal/Core/Extension/ModuleInstaller.php --- b/core/lib/Drupal/Core/Extension/ModuleInstaller.php +++ b/core/lib/Drupal/Core/Extension/ModuleInstaller.php @@ -92,13 +92,6 @@ protected $routeBuilder; /** - * The entity manager. - * - * @var \Drupal\Core\Entity\EntityManagerInterface - */ - protected $entityManager; - - /** * The stream wrapper manager. * * @var \Drupal\Core\StreamWrapper\StreamWrapperManager @@ -134,13 +127,6 @@ protected $keyValueFactory; /** - * The entity definition update manager. - * - * @var \Drupal\Core\Entity\EntityDefinitionUpdateManagerInterface - */ - protected $entityUpdateManager; - - /** * Constructs a new ModuleInstaller instance. * * @param string $root @@ -157,8 +143,6 @@ * The plugin cache clearer. * @param \Drupal\Core\Routing\RouteBuilderInterface $route_builder * The route builder. - * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager - * The entity manager. * @param \Drupal\Core\StreamWrapper\StreamWrapperManager $stream_wrapper_manager * The stream wrapper manager. * @param \Drupal\Core\Extension\ThemeHandlerInterface $theme_handler @@ -169,13 +153,11 @@ * The config manager. * @param \Drupal\Core\KeyValueStore\KeyValueFactoryInterface $key_value_factory * The key value factory. - * @param \Drupal\Core\Entity\EntityDefinitionUpdateManagerInterface $entity_update_manager - * The entity definition update manager. * * @see \Drupal\Core\DrupalKernel * @see \Drupal\Core\CoreServiceProvider */ - public function __construct($root, ModuleHandlerInterface $module_handler, DrupalKernelInterface $kernel, ConfigFactoryInterface $config_factory, ConfigInstallerInterface $config_installer, CachedDiscoveryClearerInterface $plugin_cache_clearer, RouteBuilderInterface $route_builder, EntityManagerInterface $entity_manager, StreamWrapperManager $stream_wrapper_manager, ThemeHandlerInterface $theme_handler, LoggerInterface $logger, ConfigManagerInterface $config_manager, KeyValueFactoryInterface $key_value_factory, EntityDefinitionUpdateManagerInterface $entity_update_manager) { + public function __construct($root, ModuleHandlerInterface $module_handler, DrupalKernelInterface $kernel, ConfigFactoryInterface $config_factory, ConfigInstallerInterface $config_installer, CachedDiscoveryClearerInterface $plugin_cache_clearer, RouteBuilderInterface $route_builder, StreamWrapperManager $stream_wrapper_manager, ThemeHandlerInterface $theme_handler, LoggerInterface $logger, ConfigManagerInterface $config_manager, KeyValueFactoryInterface $key_value_factory) { $this->root = $root; $this->moduleHandler = $module_handler; $this->kernel = $kernel; @@ -183,13 +165,11 @@ $this->configInstaller = $config_installer; $this->pluginCacheClearer = $plugin_cache_clearer; $this->routeBuilder = $route_builder; - $this->entityManager = $entity_manager; $this->streamWrapperManager = $stream_wrapper_manager; $this->themeHandler = $theme_handler; $this->logger = $logger; $this->configManager = $config_manager; $this->keyValueFactory = $key_value_factory; - $this->entityUpdateManager = $entity_update_manager; } /** @@ -338,21 +318,23 @@ // handler can use this as an opportunity to create the necessary // database tables. // @todo Clean this up in https://www.drupal.org/node/2350111. - foreach ($this->entityManager->getDefinitions() as $entity_type) { + $entity_manager = \Drupal::entityManager(); + $update_manager = \Drupal::entityDefinitionUpdateManager(); + foreach ($entity_manager->getDefinitions() as $entity_type) { if ($entity_type->getProvider() == $module) { - $this->entityUpdateManager->installEntityType($entity_type); + $update_manager->installEntityType($entity_type); } elseif ($entity_type->isSubclassOf(FieldableEntityInterface::CLASS)) { // The module being installed may be adding new fields to existing // entity types. Field definitions for any entity type defined by // the module are handled in the if branch. - foreach ($this->entityManager->getFieldStorageDefinitions($entity_type->id()) as $storage_definition) { + foreach ($entity_manager->getFieldStorageDefinitions($entity_type->id()) as $storage_definition) { if ($storage_definition->getProvider() == $module) { // If the module being installed is also defining a storage key // for the entity type, the entity schema may not exist yet. It // will be created later in that case. try { - $this->entityUpdateManager->installFieldStorageDefinition($storage_definition->getName(), $entity_type->id(), $module, $storage_definition); + $update_manager->installFieldStorageDefinition($storage_definition->getName(), $entity_type->id(), $module, $storage_definition); } catch (EntityStorageException $e) { watchdog_exception('system', $e, 'An error occurred while notifying the creation of the @name field storage definition: "!message" in %function (line %line of %file).', ['@name' => $storage_definition->getName()]); @@ -475,10 +457,11 @@ // Clean up all entity bundles (including fields) of every entity type // provided by the module that is being uninstalled. // @todo Clean this up in https://www.drupal.org/node/2350111. - foreach ($this->entityManager->getDefinitions() as $entity_type_id => $entity_type) { + $entity_manager = \Drupal::entityManager(); + foreach ($entity_manager->getDefinitions() as $entity_type_id => $entity_type) { if ($entity_type->getProvider() == $module) { - foreach (array_keys($this->entityManager->getBundleInfo($entity_type_id)) as $bundle) { - $this->entityManager->onBundleDelete($bundle, $entity_type_id); + foreach (array_keys($entity_manager->getBundleInfo($entity_type_id)) as $bundle) { + $entity_manager->onBundleDelete($bundle, $entity_type_id); } } } @@ -497,9 +480,10 @@ // deleted. For example, a SQL-based storage handler can use this as an // opportunity to drop the corresponding database tables. // @todo Clean this up in https://www.drupal.org/node/2350111. - foreach ($this->entityManager->getDefinitions() as $entity_type) { + $update_manager = \Drupal::entityDefinitionUpdateManager(); + foreach ($entity_manager->getDefinitions() as $entity_type) { if ($entity_type->getProvider() == $module) { - $this->entityUpdateManager->uninstallEntityType($entity_type); + $update_manager->uninstallEntityType($entity_type); } elseif ($entity_type->isSubclassOf(FieldableEntityInterface::CLASS)) { // The module being installed may be adding new fields to existing @@ -507,12 +491,12 @@ // the module are handled in the if branch. $entity_type_id = $entity_type->id(); /** @var \Drupal\Core\Entity\FieldableEntityStorageInterface $storage */ - $storage = $this->entityManager->getStorage($entity_type_id); - foreach ($this->entityManager->getFieldStorageDefinitions($entity_type_id) as $storage_definition) { + $storage = $entity_manager->getStorage($entity_type_id); + foreach ($entity_manager->getFieldStorageDefinitions($entity_type_id) as $storage_definition) { // @todo We need to trigger field purging here. // See https://www.drupal.org/node/2282119. if ($storage_definition->getProvider() == $module && !$storage->countFieldData($storage_definition, TRUE)) { - $this->entityUpdateManager->uninstallFieldStorageDefinition($storage_definition); + $update_manager->uninstallFieldStorageDefinition($storage_definition); } } }