From bbe2af1a2882b449e8dc21c975d759e4e23f29ba Mon Sep 17 00:00:00 2001 From: webchick Date: Mon, 24 Mar 2014 22:14:20 -0700 Subject: [PATCH] Issue #2095919 by Berdir: Kill ContentEntityBase::init() . --- .../Core/Config/Entity/ConfigEntityBase.php | 8 +++ .../Drupal/Core/Entity/ContentEntityBase.php | 19 ----- core/lib/Drupal/Core/Entity/Entity.php | 7 -- .../Drupal/entity_test/Entity/EntityTest.php | 70 ++++++------------- .../entity_test/Entity/EntityTestRev.php | 15 ---- 5 files changed, 30 insertions(+), 89 deletions(-) diff --git a/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php b/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php index 492876a7912..f69a52be26f 100644 --- a/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php +++ b/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php @@ -11,6 +11,7 @@ use Drupal\Component\Utility\String; use Drupal\Core\Entity\Entity; use Drupal\Core\Config\ConfigDuplicateUUIDException; use Drupal\Core\Entity\EntityStorageControllerInterface; +use Drupal\Core\Language\Language; /** * Defines a base configuration entity class. @@ -78,6 +79,13 @@ abstract class ConfigEntityBase extends Entity implements ConfigEntityInterface */ protected $dependencies = array(); + /** + * The language code of the entity's default language. + * + * @var string + */ + public $langcode = Language::LANGCODE_NOT_SPECIFIED; + /** * Overrides Entity::__construct(). */ diff --git a/core/lib/Drupal/Core/Entity/ContentEntityBase.php b/core/lib/Drupal/Core/Entity/ContentEntityBase.php index f63b1a061d9..0d2bd1f644c 100644 --- a/core/lib/Drupal/Core/Entity/ContentEntityBase.php +++ b/core/lib/Drupal/Core/Entity/ContentEntityBase.php @@ -157,8 +157,6 @@ abstract class ContentEntityBase extends Entity implements \IteratorAggregate, C } } } - - $this->init(); } /** @@ -309,14 +307,6 @@ abstract class ContentEntityBase extends Entity implements \IteratorAggregate, C // to set any parent or name. } - /** - * Initialize the object. Invoked upon construction and wake up. - */ - protected function init() { - // We unset all defined properties, so magic getters apply. - unset($this->langcode); - } - /** * Clear entity translation object cache to remove stale references. */ @@ -343,15 +333,6 @@ abstract class ContentEntityBase extends Entity implements \IteratorAggregate, C return parent::__sleep(); } - - /** - * Magic __wakeup() implementation. - */ - public function __wakeup() { - parent::__wakeup(); - $this->init(); - } - /** * {@inheritdoc} */ diff --git a/core/lib/Drupal/Core/Entity/Entity.php b/core/lib/Drupal/Core/Entity/Entity.php index 2bddb375672..6899c67eadb 100644 --- a/core/lib/Drupal/Core/Entity/Entity.php +++ b/core/lib/Drupal/Core/Entity/Entity.php @@ -16,13 +16,6 @@ use Drupal\Core\Session\AccountInterface; */ abstract class Entity extends DependencySerialization implements EntityInterface { - /** - * The language code of the entity's default language. - * - * @var string - */ - public $langcode = Language::LANGCODE_NOT_SPECIFIED; - /** * The entity type. * diff --git a/core/modules/system/tests/modules/entity_test/lib/Drupal/entity_test/Entity/EntityTest.php b/core/modules/system/tests/modules/entity_test/lib/Drupal/entity_test/Entity/EntityTest.php index 357b77ec347..1f93df13d71 100644 --- a/core/modules/system/tests/modules/entity_test/lib/Drupal/entity_test/Entity/EntityTest.php +++ b/core/modules/system/tests/modules/entity_test/lib/Drupal/entity_test/Entity/EntityTest.php @@ -48,54 +48,6 @@ use Drupal\user\UserInterface; */ class EntityTest extends ContentEntityBase implements EntityOwnerInterface { - /** - * The entity ID. - * - * @var \Drupal\Core\Field\FieldItemListInterface - */ - public $id; - - /** - * The entity UUID. - * - * @var \Drupal\Core\Field\FieldItemListInterface - */ - public $uuid; - - /** - * The bundle of the test entity. - * - * @var \Drupal\Core\Field\FieldItemListInterface - */ - public $type; - - /** - * The name of the test entity. - * - * @var \Drupal\Core\Field\FieldItemListInterface - */ - public $name; - - /** - * The associated user. - * - * @var \Drupal\Core\Field\FieldItemListInterface - */ - public $user_id; - - /** - * Initialize the object. Invoked upon construction and wake up. - */ - protected function init() { - parent::init(); - // We unset all defined properties, so magic getters apply. - unset($this->id); - unset($this->uuid); - unset($this->name); - unset($this->user_id); - unset($this->type); - } - /** * {@inheritdoc} */ @@ -175,4 +127,26 @@ class EntityTest extends ContentEntityBase implements EntityOwnerInterface { return $this; } + /** + * Sets the name. + * + * @param string $name + * Name of the entity. + * + * @return $this + */ + public function setName($name) { + $this->set('name', $name); + return $this; + } + + /** + * Returns the name. + * + * @return string + */ + public function getName() { + return $this->get('name')->value; + } + } diff --git a/core/modules/system/tests/modules/entity_test/lib/Drupal/entity_test/Entity/EntityTestRev.php b/core/modules/system/tests/modules/entity_test/lib/Drupal/entity_test/Entity/EntityTestRev.php index 61753d9c849..d14ad59bc9a 100644 --- a/core/modules/system/tests/modules/entity_test/lib/Drupal/entity_test/Entity/EntityTestRev.php +++ b/core/modules/system/tests/modules/entity_test/lib/Drupal/entity_test/Entity/EntityTestRev.php @@ -42,21 +42,6 @@ use Drupal\entity_test\Entity\EntityTest; */ class EntityTestRev extends EntityTest { - /** - * The entity revision id. - * - * @var \Drupal\Core\Field\FieldItemListInterface - */ - public $revision_id; - - /** - * {@inheritdoc} - */ - public function init() { - parent::init(); - unset($this->revision_id); - } - /** * Implements Drupal\Core\Entity\EntityInterface::getRevisionId(). */