diff --git a/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php b/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php index e8dcff4..5aa1798 100644 --- a/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php +++ b/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php @@ -10,6 +10,7 @@ use Drupal\Core\Entity\Entity; use Drupal\Core\Entity\EntityStorageControllerInterface; use Drupal\Core\Config\ConfigDuplicateUUIDException; +use Drupal\Core\Language\Language; /** * Defines a base configuration entity class. @@ -50,6 +51,13 @@ private $isSyncing = FALSE; /** + * The language code of the entity's default language. + * + * @var string + */ + public $langcode = Language::LANGCODE_NOT_SPECIFIED; + + /** * Overrides Entity::__construct(). */ public function __construct(array $values, $entity_type) { diff --git a/core/lib/Drupal/Core/Entity/ContentEntityBase.php b/core/lib/Drupal/Core/Entity/ContentEntityBase.php index f0855ef..e0889d0 100644 --- a/core/lib/Drupal/Core/Entity/ContentEntityBase.php +++ b/core/lib/Drupal/Core/Entity/ContentEntityBase.php @@ -157,8 +157,6 @@ public function __construct(array $values, $entity_type, $bundle = FALSE, $trans } } } - - $this->init(); } /** @@ -305,14 +303,6 @@ public function setContext($name = NULL, TypedDataInterface $parent = NULL) { } /** - * 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. */ protected function clearTranslationCache() { @@ -341,14 +331,6 @@ public function __sleep() { return array_keys(get_object_vars($this)); } - - /** - * Magic __wakeup() implementation. - */ - public function __wakeup() { - $this->init(); - } - /** * {@inheritdoc} */ diff --git a/core/lib/Drupal/Core/Entity/Entity.php b/core/lib/Drupal/Core/Entity/Entity.php index 5d70510..a9ba82a 100644 --- a/core/lib/Drupal/Core/Entity/Entity.php +++ b/core/lib/Drupal/Core/Entity/Entity.php @@ -16,13 +16,6 @@ abstract class Entity implements EntityInterface { /** - * The language code of the entity's default language. - * - * @var string - */ - public $langcode = Language::LANGCODE_NOT_SPECIFIED; - - /** * The entity type. * * @var string 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 72acdf2..30ed7ce 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 @@ 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} */ public static function preCreate(EntityStorageControllerInterface $storage_controller, array &$values) { @@ -174,4 +126,23 @@ public function setOwner(UserInterface $account) { return $this; } + /** + * Sets the name. + * + * @param string $name + * Name of the entity. + */ + public function setName($name) { + $this->set('name', $name); + } + + /** + * 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 5ab2561..90cdb30 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 @@ -41,21 +41,6 @@ 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(). */ public function getRevisionId() {