Unverified Commit 408c540c authored by alexpott's avatar alexpott
Browse files

Issue #2886622 by Berdir, martin107, Mile23, tim.plunkett, mikelutz,...

Issue #2886622 by Berdir, martin107, Mile23, tim.plunkett, mikelutz, jonathan1055: Deprecate all EntityManager methods with E_USER_DEPRECATED
parent d397f60c
......@@ -108,7 +108,7 @@ public function __construct(array $configuration, $plugin_id, $plugin_definition
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
return new static($configuration, $plugin_id, $plugin_definition,
$container->get('token'),
$container->get('entity.manager'),
$container->get('entity_type.manager'),
$container->get('logger.factory')->get('action'),
$container->get('plugin.manager.mail'),
$container->get('language_manager'),
......
......@@ -24,7 +24,7 @@ class EntityViewController implements ContainerInjectionInterface {
/**
* The entity type manager.
*
* @var \Drupal\Core\Entity\EntityManagerInterface
* @var \Drupal\Core\Entity\EntityTypeManagerInterface
*/
protected $entityTypeManager;
......
......@@ -19,8 +19,8 @@
* display settings, or just replicate the settings of the 'default' form mode,
* thus reducing the amount of form display configurations to keep track of.
*
* @see \Drupal\Core\Entity\EntityManagerInterface::getAllFormModes()
* @see \Drupal\Core\Entity\EntityManagerInterface::getFormModes()
* @see \Drupal\Core\Entity\EntityDisplayRepositoryInterface::getAllFormModes()
* @see \Drupal\Core\Entity\EntityDisplayRepositoryInterface::getFormModes()
*
* @ConfigEntityType(
* id = "entity_form_mode",
......
......@@ -13,10 +13,11 @@
* perform complex or long-running logic in response to the change. For
* example, a SQL-based storage handler may need to update the database schema.
*
* To support this, \Drupal\Core\Entity\EntityManagerInterface has methods to
* retrieve the last installed definitions as well as the definitions specified
* by the current codebase. It also has create/update/delete methods to bring
* the former up to date with the latter.
* To support this,
* \Drupal\Core\Entity\EntityLastInstalledSchemaRepositoryInterface has methods
* to retrieve the last installed definitions as well as the definitions
* specified by the current codebase. It also has create/update/delete methods
* to bring the former up to date with the latter.
*
* However, it is not the responsibility of the entity manager to decide how to
* report the differences or when to apply each update. This interface is for
......
......@@ -16,7 +16,7 @@ class EntityDeleteMultipleAccessCheck implements AccessInterface {
/**
* The entity type manager.
*
* @var \Drupal\Core\Entity\EntityManagerInterface
* @var \Drupal\Core\Entity\EntityTypeManagerInterface
*/
protected $entityTypeManager;
......
......@@ -13,9 +13,6 @@
* Deprecated in Drupal 8.0.0, will be removed before Drupal 9.0.0. We cannot
* use the deprecated PHPDoc tag because this service class is still used in
* legacy code paths. Symfony would fail test cases with deprecation warnings.
*
* @todo Enforce the deprecation of each method once
* https://www.drupal.org/node/2578361 is in.
*/
class EntityManager implements EntityManagerInterface, ContainerAwareInterface {
......@@ -52,6 +49,7 @@ public function clearCachedDefinitions() {
* @see https://www.drupal.org/node/2549139
*/
public function getDefinition($entity_type_id, $exception_on_invalid = TRUE) {
@trigger_error('EntityManagerInterface::getDefinition() is deprecated in drupal:8.0.0 and is removed from drupal:9.0.0. Use \Drupal\Core\Entity\EntityTypeManager::getDefinition() instead. See https://www.drupal.org/node/2549139', E_USER_DEPRECATED);
return $this->container->get('entity_type.manager')->getDefinition($entity_type_id, $exception_on_invalid);
}
......@@ -65,6 +63,7 @@ public function getDefinition($entity_type_id, $exception_on_invalid = TRUE) {
* @see https://www.drupal.org/node/2549139
*/
public function hasHandler($entity_type_id, $handler_type) {
@trigger_error('EntityManagerInterface::hasHandler() is deprecated in drupal:8.0.0 and is removed from drupal:9.0.0. Use \Drupal\Core\Entity\EntityTypeManager::hasHandler() instead. See https://www.drupal.org/node/2549139', E_USER_DEPRECATED);
return $this->container->get('entity_type.manager')->hasHandler($entity_type_id, $handler_type);
}
......@@ -77,6 +76,7 @@ public function hasHandler($entity_type_id, $handler_type) {
* @see https://www.drupal.org/node/2549139
*/
public function getStorage($entity_type_id) {
@trigger_error('EntityManagerInterface::getStorage() is deprecated in drupal:8.0.0 and is removed from drupal:9.0.0. Use \Drupal\Core\Entity\EntityTypeManager::getStorage() instead. See https://www.drupal.org/node/2549139', E_USER_DEPRECATED);
return $this->container->get('entity_type.manager')->getStorage($entity_type_id);
}
......@@ -90,6 +90,7 @@ public function getStorage($entity_type_id) {
* @see https://www.drupal.org/node/2549139
*/
public function getListBuilder($entity_type_id) {
@trigger_error('EntityManagerInterface::getListBuilder() is deprecated in drupal:8.0.0 and is removed from drupal:9.0.0. Use \Drupal\Core\Entity\EntityTypeManager::getListBuilder() instead. See https://www.drupal.org/node/2549139', E_USER_DEPRECATED);
return $this->container->get('entity_type.manager')->getListBuilder($entity_type_id);
}
......@@ -103,6 +104,7 @@ public function getListBuilder($entity_type_id) {
* @see https://www.drupal.org/node/2549139
*/
public function getFormObject($entity_type_id, $operation) {
@trigger_error('EntityManagerInterface::getFormObject() is deprecated in drupal:8.0.0 and is removed from drupal:9.0.0. Use \Drupal\Core\Entity\EntityTypeManager::getFormObject() instead. See https://www.drupal.org/node/2549139', E_USER_DEPRECATED);
return $this->container->get('entity_type.manager')->getFormObject($entity_type_id, $operation);
}
......@@ -116,6 +118,7 @@ public function getFormObject($entity_type_id, $operation) {
* @see https://www.drupal.org/node/2549139
*/
public function getRouteProviders($entity_type_id) {
@trigger_error('EntityManagerInterface::getRouteProviders() is deprecated in drupal:8.0.0 and is removed from drupal:9.0.0. Use \Drupal\Core\Entity\EntityTypeManager::getRouteProviders() instead. See https://www.drupal.org/node/2549139', E_USER_DEPRECATED);
return $this->container->get('entity_type.manager')->getRouteProviders($entity_type_id);
}
......@@ -129,6 +132,7 @@ public function getRouteProviders($entity_type_id) {
* @see https://www.drupal.org/node/2549139
*/
public function getViewBuilder($entity_type_id) {
@trigger_error('EntityManagerInterface::getViewBuilder() is deprecated in drupal:8.0.0 and is removed from drupal:9.0.0. Use \Drupal\Core\Entity\EntityTypeManager::getViewBuilder() instead. See https://www.drupal.org/node/2549139', E_USER_DEPRECATED);
return $this->container->get('entity_type.manager')->getViewBuilder($entity_type_id);
}
......@@ -142,6 +146,7 @@ public function getViewBuilder($entity_type_id) {
* @see https://www.drupal.org/node/2549139
*/
public function getAccessControlHandler($entity_type_id) {
@trigger_error('EntityManagerInterface::getAccessControlHandler() is deprecated in drupal:8.0.0 and is removed from drupal:9.0.0. Use \Drupal\Core\Entity\EntityTypeManager::getAccessControlHandler() instead. See https://www.drupal.org/node/2549139', E_USER_DEPRECATED);
return $this->container->get('entity_type.manager')->getAccessControlHandler($entity_type_id);
}
......@@ -154,6 +159,7 @@ public function getAccessControlHandler($entity_type_id) {
* @see https://www.drupal.org/node/2549139
*/
public function getHandler($entity_type_id, $handler_type) {
@trigger_error('EntityManagerInterface::getHandler() is deprecated in drupal:8.0.0 and is removed from drupal:9.0.0. Use \Drupal\Core\Entity\EntityTypeManager::getHandler() instead. See https://www.drupal.org/node/2549139', E_USER_DEPRECATED);
return $this->container->get('entity_type.manager')->getHandler($entity_type_id, $handler_type);
}
......@@ -167,6 +173,7 @@ public function getHandler($entity_type_id, $handler_type) {
* @see https://www.drupal.org/node/2549139
*/
public function createHandlerInstance($class, EntityTypeInterface $definition = NULL) {
@trigger_error('EntityManagerInterface::createHandlerInstance() is deprecated in drupal:8.0.0 and is removed from drupal:9.0.0. Use \Drupal\Core\Entity\EntityTypeManager::createHandlerInstance() instead. See https://www.drupal.org/node/2549139', E_USER_DEPRECATED);
return $this->container->get('entity_type.manager')->createHandlerInstance($class, $definition);
}
......@@ -807,6 +814,7 @@ public function getLastInstalledFieldStorageDefinitions($entity_type_id) {
* @see https://www.drupal.org/node/2549139
*/
public function getDefinitions() {
@trigger_error('EntityManagerInterface::getDefinitions() is deprecated in drupal:8.0.0 and is removed from drupal:9.0.0. Use \Drupal\Core\Entity\EntityTypeManager::getDefinitions() instead. See https://www.drupal.org/node/2549139', E_USER_DEPRECATED);
return $this->container->get('entity_type.manager')->getDefinitions();
}
......@@ -820,6 +828,7 @@ public function getDefinitions() {
* @see https://www.drupal.org/node/2549139
*/
public function hasDefinition($plugin_id) {
@trigger_error('EntityManagerInterface::hasDefinition() is deprecated in drupal:8.0.0 and is removed from drupal:9.0.0. Use \Drupal\Core\Entity\EntityTypeManager::hasDefinition() instead. See https://www.drupal.org/node/2549139', E_USER_DEPRECATED);
return $this->container->get('entity_type.manager')->hasDefinition($plugin_id);
}
......
......@@ -17,7 +17,7 @@ final class EntityTypeEvents {
* @Event
*
* @see \Drupal\Core\Entity\EntityTypeEvent
* @see \Drupal\Core\Entity\EntityManager::onEntityTypeCreate()
* @see \Drupal\Core\Entity\EntityTypeListenerInterface::onEntityTypeCreate()
* @see \Drupal\Core\Entity\EntityTypeEventSubscriberTrait
* @see \Drupal\views\EventSubscriber\ViewsEntitySchemaSubscriber::onEntityTypeCreate()
*
......@@ -35,7 +35,7 @@ final class EntityTypeEvents {
* @Event
*
* @see \Drupal\Core\Entity\EntityTypeEvent
* @see \Drupal\Core\Entity\EntityManager::onEntityTypeUpdate()
* @see \Drupal\Core\Entity\EntityTypeListenerInterface::onEntityTypeUpdate()
* @see \Drupal\Core\Entity\EntityTypeEventSubscriberTrait
* @see \Drupal\views\EventSubscriber\ViewsEntitySchemaSubscriber::onEntityTypeUpdate()
*
......@@ -53,7 +53,7 @@ final class EntityTypeEvents {
* @Event
*
* @see \Drupal\Core\Entity\EntityTypeEvent
* @see \Drupal\Core\Entity\EntityManager::onEntityTypeDelete()
* @see \Drupal\Core\Entity\EntityTypeListenerInterface::onEntityTypeDelete()
* @see \Drupal\Core\Entity\EntityTypeEventSubscriberTrait
* @see \Drupal\views\EventSubscriber\ViewsEntitySchemaSubscriber::onEntityTypeDelete()
*
......
......@@ -49,7 +49,7 @@ interface FieldableEntityInterface extends EntityInterface {
* An array of base field definitions for the entity type, keyed by field
* name.
*
* @see \Drupal\Core\Entity\EntityManagerInterface::getFieldDefinitions()
* @see \Drupal\Core\Entity\EntityFieldManagerInterface::getFieldDefinitions()
* @see \Drupal\Core\Entity\FieldableEntityInterface::bundleFieldDefinitions()
*/
public static function baseFieldDefinitions(EntityTypeInterface $entity_type);
......@@ -85,7 +85,7 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type);
* @return \Drupal\Core\Field\FieldDefinitionInterface[]
* An array of bundle field definitions, keyed by field name.
*
* @see \Drupal\Core\Entity\EntityManagerInterface::getFieldDefinitions()
* @see \Drupal\Core\Entity\EntityFieldManagerInterface::getFieldDefinitions()
* @see \Drupal\Core\Entity\FieldableEntityInterface::baseFieldDefinitions()
*
* @todo WARNING: This method will be changed in
......@@ -121,7 +121,7 @@ public function getFieldDefinition($name);
* @return \Drupal\Core\Field\FieldDefinitionInterface[]
* An array of field definitions, keyed by field name.
*
* @see \Drupal\Core\Entity\EntityManagerInterface::getFieldDefinitions()
* @see \Drupal\Core\Entity\EntityFieldManagerInterface::getFieldDefinitions()
*/
public function getFieldDefinitions();
......
......@@ -51,7 +51,7 @@ class DefaultSelection extends SelectionPluginBase implements ContainerFactoryPl
/**
* The entity type manager service.
*
* @var \Drupal\Core\Entity\EntityManagerInterface
* @var \Drupal\Core\Entity\EntityTypeManagerInterface
*/
protected $entityTypeManager;
......
......@@ -33,7 +33,7 @@ class DefaultHtmlRouteProvider implements EntityRouteProviderInterface, EntityHa
/**
* The entity type manager.
*
* @var \Drupal\Core\Entity\EntityManagerInterface
* @var \Drupal\Core\Entity\EntityTypeManagerInterface
*/
protected $entityTypeManager;
......
......@@ -582,7 +582,7 @@
* @code
* $view_builder = \Drupal::entityTypeManager()->getViewBuilder('your_entity_type');
* // Or if you have a $container variable:
* $view_builder = $container->get('entity.manager')->getViewBuilder('your_entity_type');
* $view_builder = $container->get('entity_type.manager')->getViewBuilder('your_entity_type');
* @endcode
* Then, to build and render the entity:
* @code
......@@ -1940,7 +1940,7 @@ function hook_entity_bundle_field_info_alter(&$fields, \Drupal\Core\Entity\Entit
*
* @see hook_entity_field_storage_info_alter()
* @see \Drupal\Core\Field\FieldStorageDefinitionInterface
* @see \Drupal\Core\Entity\EntityManagerInterface::getFieldStorageDefinitions()
* @see \Drupal\Core\Entity\EntityFieldManagerInterface::getFieldStorageDefinitions()
*/
function hook_entity_field_storage_info(\Drupal\Core\Entity\EntityTypeInterface $entity_type) {
if (\Drupal::entityTypeManager()->getStorage($entity_type->id()) instanceof DynamicallyFieldableEntityStorageInterface) {
......@@ -2176,7 +2176,7 @@ function hook_entity_extra_field_info() {
*
* @param array $info
* The array structure is identical to that of the return value of
* \Drupal\Core\Entity\EntityManagerInterface::getExtraFields().
* \Drupal\Core\Entity\EntityFieldManagerInterface::getExtraFields().
*
* @see hook_entity_extra_field_info()
*/
......
......@@ -17,10 +17,10 @@ interface ModuleUninstallValidatorInterface {
* Example implementation:
* @code
* public function validate($module) {
* $entity_types = $this->entityManager->getDefinitions();
* $entity_types = $this->entityTypeManager->getDefinitions();
* $reasons = array();
* foreach ($entity_types as $entity_type) {
* if ($module == $entity_type->getProvider() && $entity_type instanceof ContentEntityTypeInterface && $this->entityManager->getStorage($entity_type->id())->hasData()) {
* if ($module == $entity_type->getProvider() && $entity_type instanceof ContentEntityTypeInterface && $this->entityTypeManager->getStorage($entity_type->id())->hasData()) {
* $reasons[] = $this->t('There is content for the entity type: @entity_type', array('@entity_type' => $entity_type->getLabel()));
* }
* }
......
......@@ -17,7 +17,7 @@ final class FieldStorageDefinitionEvents {
* @Event
*
* @see \Drupal\Core\Field\FieldStorageDefinitionEvent
* @see \Drupal\Core\Entity\EntityManager::onFieldStorageDefinitionCreate()
* @see \Drupal\Core\Field\FieldStorageDefinitionListener::onFieldStorageDefinitionCreate
* @see \Drupal\Core\Field\FieldStorageDefinitionEventSubscriberTrait
*
* @var string
......@@ -34,7 +34,7 @@ final class FieldStorageDefinitionEvents {
* @Event
*
* @see \Drupal\Core\Field\FieldStorageDefinitionEvent
* @see \Drupal\Core\Entity\EntityManager::onFieldStorageDefinitionUpdate()
* @see \Drupal\Core\Field\FieldStorageDefinitionListener::onFieldStorageDefinitionUpdate()
* @see \Drupal\Core\Field\FieldStorageDefinitionEventSubscriberTrait
*
* @var string
......@@ -51,7 +51,7 @@ final class FieldStorageDefinitionEvents {
* @Event
*
* @see \Drupal\Core\Field\FieldStorageDefinitionEvent
* @see \Drupal\Core\Entity\EntityManager::onFieldStorageDefinitionDelete()
* @see \Drupal\Core\Field\FieldStorageDefinitionListener::onFieldStorageDefinitionDelete()
* @see \Drupal\Core\Field\FieldStorageDefinitionEventSubscriberTrait
*
* @var string
......
......@@ -82,7 +82,7 @@ public static function create(ContainerInterface $container, array $configuratio
$configuration['view_mode'],
$configuration['third_party_settings'],
$container->get('date.formatter'),
$container->get('entity.manager')->getStorage('date_format')
$container->get('entity_type.manager')->getStorage('date_format')
);
}
......
......@@ -93,7 +93,7 @@ public static function create(ContainerInterface $container) {
return new static(
$container->get('app.root'),
$container->get('site.path'),
$container->get('entity.manager')->getStorage('user'),
$container->get('entity_type.manager')->getStorage('user'),
$container->get('state'),
$container->get('module_installer'),
$container->get('country_manager')
......
......@@ -42,7 +42,7 @@ public function __construct(EntityStorageInterface $storage) {
*/
public static function create(ContainerInterface $container) {
return new static(
$container->get('entity.manager')->getStorage('action')
$container->get('entity_type.manager')->getStorage('action')
);
}
......
......@@ -27,7 +27,7 @@ public function testEmptyActionList() {
// Ensure the empty text appears on the action list page.
/** @var $storage \Drupal\Core\Entity\EntityStorageInterface */
$storage = $this->container->get('entity.manager')->getStorage('action');
$storage = $this->container->get('entity_type.manager')->getStorage('action');
$actions = $storage->loadMultiple();
$storage->delete($actions);
$this->drupalGet('/admin/config/system/actions');
......
......@@ -49,7 +49,7 @@ public function __construct(FeedStorageInterface $feed_storage, ClientInterface
*/
public static function create(ContainerInterface $container) {
return new static(
$container->get('entity.manager')->getStorage('aggregator_feed'),
$container->get('entity_type.manager')->getStorage('aggregator_feed'),
$container->get('http_client')
);
}
......
......@@ -50,7 +50,12 @@ public function __construct(array $configuration, $plugin_id, $plugin_definition
* {@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'));
return new static(
$configuration,
$plugin_id,
$plugin_definition,
$container->get('entity_type.manager')
);
}
/**
......
......@@ -69,7 +69,7 @@ public function testOverviewPage() {
// Check if the fields in the table match with what's expected.
$link = $this->xpath('//table/tbody/tr//td[1]/a');
$this->assertEquals($feed->label(), $link[0]->getText());
$count = $this->container->get('entity.manager')->getStorage('aggregator_item')->getItemCount($feed);
$count = $this->container->get('entity_type.manager')->getStorage('aggregator_item')->getItemCount($feed);
$td = $this->xpath('//table/tbody/tr//td[2]');
$this->assertEquals(\Drupal::translation()->formatPlural($count, '1 item', '@count items'), $td[0]->getText());
......@@ -80,7 +80,7 @@ public function testOverviewPage() {
// Check if the fields in the table match with what's expected.
$link = $this->xpath('//table/tbody/tr//td[1]/a');
$this->assertEquals($feed->label(), $link[0]->getText());
$count = $this->container->get('entity.manager')->getStorage('aggregator_item')->getItemCount($feed);
$count = $this->container->get('entity_type.manager')->getStorage('aggregator_item')->getItemCount($feed);
$td = $this->xpath('//table/tbody/tr//td[2]');
$this->assertEquals(\Drupal::translation()->formatPlural($count, '1 item', '@count items'), $td[0]->getText());
}
......
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