Commit bbe2af1a authored by webchick's avatar webchick

Issue #2095919 by Berdir: Kill ContentEntityBase::init() .

parent bead76ad
......@@ -11,6 +11,7 @@
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().
*/
......
......@@ -157,8 +157,6 @@ public function __construct(array $values, $entity_type, $bundle = FALSE, $trans
}
}
}
$this->init();
}
/**
......@@ -309,14 +307,6 @@ public function setContext($name = NULL, TypedDataInterface $parent = NULL) {
// 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 @@ public function __sleep() {
return parent::__sleep();
}
/**
* Magic __wakeup() implementation.
*/
public function __wakeup() {
parent::__wakeup();
$this->init();
}
/**
* {@inheritdoc}
*/
......
......@@ -16,13 +16,6 @@
*/
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.
*
......
......@@ -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}
*/
......@@ -175,4 +127,26 @@ public function setOwner(UserInterface $account) {
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;
}
}
......@@ -42,21 +42,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().
*/
......
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