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

8.0.x
webchick 2014-03-24 22:14:20 -07:00
parent bead76ad5b
commit bbe2af1a28
5 changed files with 30 additions and 89 deletions

View File

@ -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().
*/

View File

@ -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}
*/

View File

@ -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.
*

View File

@ -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;
}
}

View File

@ -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().
*/