diff --git a/core/lib/Drupal/Core/Entity/EntityNG.php b/core/lib/Drupal/Core/Entity/EntityNG.php index 3567572..c0080aa 100644 --- a/core/lib/Drupal/Core/Entity/EntityNG.php +++ b/core/lib/Drupal/Core/Entity/EntityNG.php @@ -60,6 +60,28 @@ class EntityNG extends Entity { */ protected $compatibilityMode = FALSE; + /** + * Overrides Entity::__construct(). + */ + public function __construct(array $values, $entity_type) { + parent::__construct($values, $entity_type); + $this->init(); + } + + /** + * Initialize the object. Invoked upon construction and wake up. + */ + protected function init() { + // We unset all defined properties, so magic getters apply. + unset($this->langcode); + } + + /** + * Magic __wakeup() implemenation. + */ + public function __wakeup() { + $this->init(); + } /** * Overrides Entity::id(). diff --git a/core/modules/comment/lib/Drupal/comment/Comment.php b/core/modules/comment/lib/Drupal/comment/Comment.php index 6b4658c..aed7639 100644 --- a/core/modules/comment/lib/Drupal/comment/Comment.php +++ b/core/modules/comment/lib/Drupal/comment/Comment.php @@ -159,14 +159,6 @@ class Comment extends EntityNG implements ContentEntityInterface { ); /** - * Overrides Entity::__construct(). - */ - public function __construct(array $values, $entity_type) { - parent::__construct($values, $entity_type); - $this->init(); - } - - /** * Initialize the object. Invoked upon construction and wake up. */ protected function init() { @@ -191,13 +183,6 @@ protected function init() { } /** - * Magic __wakeup() implemenation. - */ - public function __wakeup() { - $this->init(); - } - - /** * Implements Drupal\Core\Entity\EntityInterface::id(). */ public function id() { diff --git a/core/modules/system/tests/modules/entity_test/lib/Drupal/entity_test/EntityTest.php b/core/modules/system/tests/modules/entity_test/lib/Drupal/entity_test/EntityTest.php index 17e8470..dc6e203 100644 --- a/core/modules/system/tests/modules/entity_test/lib/Drupal/entity_test/EntityTest.php +++ b/core/modules/system/tests/modules/entity_test/lib/Drupal/entity_test/EntityTest.php @@ -43,14 +43,12 @@ class EntityTest extends EntityNG { public $user_id; /** - * Overrides Entity::__construct(). + * Initialize the object. Invoked upon construction and wake up. */ - public function __construct(array $values, $entity_type) { - parent::__construct($values, $entity_type); - + protected function init() { // We unset all defined properties, so magic getters apply. - unset($this->id); unset($this->langcode); + unset($this->id); unset($this->uuid); unset($this->name); unset($this->user_id); diff --git a/core/modules/views/lib/Drupal/views/Tests/Comment/DefaultViewRecentComments.php b/core/modules/views/lib/Drupal/views/Tests/Comment/DefaultViewRecentComments.php index 73ddfe0..67aefe5 100644 --- a/core/modules/views/lib/Drupal/views/Tests/Comment/DefaultViewRecentComments.php +++ b/core/modules/views/lib/Drupal/views/Tests/Comment/DefaultViewRecentComments.php @@ -78,12 +78,12 @@ public function setUp() { // Create some comments and attach them to the created node. for ($i = 0; $i < $this->masterDisplayResults; $i++) { $comment = entity_create('comment', array()); - $comment->uid = 0; - $comment->nid = $this->node->nid; - $comment->subject = 'Test comment ' . $i; - $comment->node_type = 'comment_node_' . $this->node->type; - $comment->comment_body[LANGUAGE_NOT_SPECIFIED][0]['value'] = 'Test body ' . $i; - $comment->comment_body[LANGUAGE_NOT_SPECIFIED][0]['format'] = 'full_html'; + $comment->uid->value = 0; + $comment->nid->value = $this->node->nid; + $comment->subject->value = 'Test comment ' . $i; + $comment->node_type->value = 'comment_node_' . $this->node->type; + $comment->comment_body->value = 'Test body ' . $i; + $comment->comment_body->format = 'full_html'; comment_save($comment); } @@ -108,10 +108,10 @@ public function testBlockDisplay() { ); $expected_result = array(); foreach (array_values($this->commentsCreated) as $key => $comment) { - $expected_result[$key]['nid'] = $comment->nid; - $expected_result[$key]['subject'] = $comment->subject; - $expected_result[$key]['cid'] = $comment->cid; - $expected_result[$key]['changed'] = $comment->changed; + $expected_result[$key]['nid'] = $comment->nid->value; + $expected_result[$key]['subject'] = $comment->subject->value; + $expected_result[$key]['cid'] = $comment->cid->value; + $expected_result[$key]['changed'] = $comment->changed->value->getTimestamp(); } $this->assertIdenticalResultset($view, $expected_result, $map); @@ -140,11 +140,11 @@ public function testPageDisplay() { ); $expected_result = array(); foreach (array_values($this->commentsCreated) as $key => $comment) { - $expected_result[$key]['nid'] = $comment->nid; - $expected_result[$key]['subject'] = $comment->subject; - $expected_result[$key]['changed'] = $comment->changed; - $expected_result[$key]['created'] = $comment->created; - $expected_result[$key]['cid'] = $comment->cid; + $expected_result[$key]['nid'] = $comment->nid->value; + $expected_result[$key]['subject'] = $comment->subject->value; + $expected_result[$key]['changed'] = $comment->changed->value->getTimestamp(); + $expected_result[$key]['created'] = $comment->created->value->getTimestamp(); + $expected_result[$key]['cid'] = $comment->cid->value; } $this->assertIdenticalResultset($view, $expected_result, $map);