core/lib/Drupal/Core/Entity/ContentEntityBase.php | 13 +------------ core/lib/Drupal/Core/Entity/Entity.php | 19 ++----------------- .../Config/Entity/ConfigEntityBaseUnitTest.php | 20 ++++++++++---------- .../Drupal/Tests/Core/Entity/EntityUnitTest.php | 2 +- 4 files changed, 14 insertions(+), 40 deletions(-) diff --git a/core/lib/Drupal/Core/Entity/ContentEntityBase.php b/core/lib/Drupal/Core/Entity/ContentEntityBase.php index d09c412..b81e1eb 100644 --- a/core/lib/Drupal/Core/Entity/ContentEntityBase.php +++ b/core/lib/Drupal/Core/Entity/ContentEntityBase.php @@ -129,13 +129,6 @@ protected $isDefaultRevision = TRUE; /** - * The typed data manager. - * - * @var \Drupal\Core\TypedData\TypedDataManager - */ - protected $typedDataManager; - - /** * Overrides Entity::__construct(). */ public function __construct(array $values, $entity_type, $bundle = FALSE, $translations = array()) { @@ -174,11 +167,7 @@ public function __construct(array $values, $entity_type, $bundle = FALSE, $trans * @return \Drupal\Core\TypedData\TypedDataManager */ protected function typedDataManager() { - if (!$this->typedDataManager) { - $this->typedDataManager = \Drupal::typedDataManager(); - } - - return $this->typedDataManager; + return \Drupal::typedDataManager(); } /** diff --git a/core/lib/Drupal/Core/Entity/Entity.php b/core/lib/Drupal/Core/Entity/Entity.php index 824ab53..1723789 100644 --- a/core/lib/Drupal/Core/Entity/Entity.php +++ b/core/lib/Drupal/Core/Entity/Entity.php @@ -24,13 +24,6 @@ public $langcode = Language::LANGCODE_NOT_SPECIFIED; /** - * The entity manager. - * - * @var \Drupal\Core\Entity\EntityManagerInterface - */ - protected $entityManager; - - /** * The UUID generator. * * @var \Drupal\Component\Uuid\UuidInterface @@ -88,11 +81,7 @@ public function __construct(array $values, $entity_type) { * @return \Drupal\Core\Entity\EntityManagerInterface */ protected function entityManager() { - if (!$this->entityManager) { - $this->entityManager = \Drupal::entityManager(); - } - - return $this->entityManager; + return \Drupal::entityManager(); } /** @@ -101,11 +90,7 @@ protected function entityManager() { * @return \Drupal\Core\Language\LanguageManagerInterface */ protected function languageManager() { - if (!$this->languageManager) { - $this->languageManager = \Drupal::languageManager(); - } - - return $this->languageManager; + return \Drupal::languageManager(); } /** diff --git a/core/tests/Drupal/Tests/Core/Config/Entity/ConfigEntityBaseUnitTest.php b/core/tests/Drupal/Tests/Core/Config/Entity/ConfigEntityBaseUnitTest.php index 771af60..c288d27 100644 --- a/core/tests/Drupal/Tests/Core/Config/Entity/ConfigEntityBaseUnitTest.php +++ b/core/tests/Drupal/Tests/Core/Config/Entity/ConfigEntityBaseUnitTest.php @@ -107,7 +107,7 @@ public function setUp() { */ public function testGetOriginalId() { $id = $this->randomName(); - $this->assertSame(spl_object_hash($this->entity), spl_object_hash($this->entity->setOriginalId($id))); + $this->assertSame($this->entity, $this->entity->setOriginalId($id)); $this->assertSame($id, $this->entity->getOriginalId()); } @@ -116,7 +116,7 @@ public function testGetOriginalId() { */ public function testIsNew() { $this->assertFalse($this->entity->isNew()); - $this->assertSame(spl_object_hash($this->entity), spl_object_hash($this->entity->enforceIsNew())); + $this->assertSame($this->entity, $this->entity->enforceIsNew()); $this->assertTrue($this->entity->isNew()); $this->entity->enforceIsNew(FALSE); $this->assertFalse($this->entity->isNew()); @@ -130,7 +130,7 @@ public function testGet() { $name = $this->randomName(); $value = $this->randomName(); $this->assertNull($this->entity->get($name)); - $this->assertSame(spl_object_hash($this->entity), spl_object_hash($this->entity->set($name, $value))); + $this->assertSame($this->entity, $this->entity->set($name, $value)); $this->assertSame($value, $this->entity->get($name)); } @@ -140,7 +140,7 @@ public function testGet() { */ public function testSetStatus() { $this->assertTrue($this->entity->status()); - $this->assertSame(spl_object_hash($this->entity), spl_object_hash($this->entity->setStatus(FALSE))); + $this->assertSame($this->entity, $this->entity->setStatus(FALSE)); $this->assertFalse($this->entity->status()); $this->entity->setStatus(TRUE); $this->assertTrue($this->entity->status()); @@ -152,7 +152,7 @@ public function testSetStatus() { */ public function testEnable() { $this->entity->setStatus(FALSE); - $this->assertSame(spl_object_hash($this->entity), spl_object_hash($this->entity->enable())); + $this->assertSame($this->entity, $this->entity->enable()); $this->assertTrue($this->entity->status()); } @@ -162,7 +162,7 @@ public function testEnable() { */ public function testDisable() { $this->entity->setStatus(TRUE); - $this->assertSame(spl_object_hash($this->entity), spl_object_hash($this->entity->disable())); + $this->assertSame($this->entity, $this->entity->disable()); $this->assertFalse($this->entity->status()); } @@ -172,7 +172,7 @@ public function testDisable() { */ public function testIsSyncing() { $this->assertFalse($this->entity->isSyncing()); - $this->assertSame(spl_object_hash($this->entity), spl_object_hash($this->entity->setSyncing(TRUE))); + $this->assertSame($this->entity, $this->entity->setSyncing(TRUE)); $this->assertTrue($this->entity->isSyncing()); $this->entity->setSyncing(FALSE); $this->assertFalse($this->entity->isSyncing()); @@ -191,7 +191,7 @@ public function testCreateDuplicate() { /** @var \Drupal\Core\Config\Entity\ConfigEntityInterface $duplicate */ $duplicate = $this->entity->createDuplicate(); $this->assertInstanceOf('\Drupal\Core\Entity\Entity', $duplicate); - $this->assertNotSame(spl_object_hash($this->entity), spl_object_hash($duplicate)); + $this->assertNotSame($this->entity, $duplicate); $this->assertNull($duplicate->id()); $this->assertNull($duplicate->getOriginalId()); $this->assertNull($duplicate->uuid()); @@ -216,12 +216,12 @@ public function testSort() { $list = array($entity_a, $entity_b); // Suppress errors because of https://bugs.php.net/bug.php?id=50688. @usort($list, '\Drupal\Core\Config\Entity\ConfigEntityBase::sort'); - $this->assertSame(spl_object_hash($entity_b), spl_object_hash($list[0])); + $this->assertSame($entity_b, $list[0]); $entity_a->weight = 0; $entity_b->weight = 1; // Suppress errors because of https://bugs.php.net/bug.php?id=50688. @usort($list, array($entity_a, 'sort')); - $this->assertSame(spl_object_hash($entity_a), spl_object_hash($list[0])); + $this->assertSame($entity_a, $list[0]); } /** diff --git a/core/tests/Drupal/Tests/Core/Entity/EntityUnitTest.php b/core/tests/Drupal/Tests/Core/Entity/EntityUnitTest.php index df10310..2918af7 100644 --- a/core/tests/Drupal/Tests/Core/Entity/EntityUnitTest.php +++ b/core/tests/Drupal/Tests/Core/Entity/EntityUnitTest.php @@ -137,7 +137,7 @@ public function testIsNew() { * @covers ::enforceIsNew */ public function testEnforceIsNew() { - $this->assertSame(spl_object_hash($this->entity), spl_object_hash($this->entity->enforceIsNew())); + $this->assertSame($this->entity, $this->entity->enforceIsNew()); } /**