summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNathaniel Catchpole2018-08-24 06:23:48 (GMT)
committerNathaniel Catchpole2018-08-24 06:23:54 (GMT)
commitf78fb96a2e2b995c7647ce9ee5dc71a9b618fe3d (patch)
treeab79a2f900971b8dbaa147cb8f274d41471bb5f2
parentf208a93005027d178fe982c77b61264b39b80048 (diff)
Issue #2894261 by alexpott, Berdir, Sam152, deepakaryan1988, larowlan, andypost: Deprecated service entity.manager needs to be replaced with entity_type.manager in ContentEntityForm
(cherry picked from commit 077e23071262cb5841b4abb3c5ca00cb51df9ef5)
-rw-r--r--core/lib/Drupal/Core/Entity/ContentEntityForm.php1
-rw-r--r--core/tests/Drupal/Tests/Core/Entity/ContentEntityFormTest.php7
2 files changed, 7 insertions, 1 deletions
diff --git a/core/lib/Drupal/Core/Entity/ContentEntityForm.php b/core/lib/Drupal/Core/Entity/ContentEntityForm.php
index 7aa0669..75bde9f 100644
--- a/core/lib/Drupal/Core/Entity/ContentEntityForm.php
+++ b/core/lib/Drupal/Core/Entity/ContentEntityForm.php
@@ -56,6 +56,7 @@ class ContentEntityForm extends EntityForm implements ContentEntityFormInterface
public function __construct(EntityRepositoryInterface $entity_repository, EntityTypeBundleInfoInterface $entity_type_bundle_info = NULL, TimeInterface $time = NULL) {
if ($entity_repository instanceof EntityManagerInterface) {
@trigger_error('Passing the entity.manager service to ContentEntityForm::__construct() is deprecated in Drupal 8.6.0 and will be removed before Drupal 9.0.0. Pass the entity.repository service instead. See https://www.drupal.org/node/2549139.', E_USER_DEPRECATED);
+ $this->entityManager = $entity_repository;
}
$this->entityRepository = $entity_repository;
$this->entityTypeBundleInfo = $entity_type_bundle_info ?: \Drupal::service('entity_type.bundle.info');
diff --git a/core/tests/Drupal/Tests/Core/Entity/ContentEntityFormTest.php b/core/tests/Drupal/Tests/Core/Entity/ContentEntityFormTest.php
index d4f8845..66a5978 100644
--- a/core/tests/Drupal/Tests/Core/Entity/ContentEntityFormTest.php
+++ b/core/tests/Drupal/Tests/Core/Entity/ContentEntityFormTest.php
@@ -22,7 +22,12 @@ class ContentEntityFormTest extends UnitTestCase {
$entity_manager = $this->prophesize(EntityManagerInterface::class)->reveal();
$entity_type_bundle_info = $this->prophesize(EntityTypeBundleInfoInterface::class)->reveal();
$time = $this->prophesize(TimeInterface::class)->reveal();
- new ContentEntityForm($entity_manager, $entity_type_bundle_info, $time);
+ $form = new ContentEntityForm($entity_manager, $entity_type_bundle_info, $time);
+
+ $reflected_form = new \ReflectionClass($form);
+ $entity_manager_property = $reflected_form->getProperty('entityManager');
+ $entity_manager_property->setAccessible(TRUE);
+ $this->assertTrue($entity_manager_property->getValue($form) === $entity_manager);
}
}