Commit 45e0ca45 authored by webchick's avatar webchick

Issue #1877638 by fago, Gaelan, YesCT, das-peter, tim.plunkett, smiletrl:...

Issue #1877638 by fago, Gaelan, YesCT, das-peter, tim.plunkett, smiletrl: Rename getOriginalEntity() and remove duplicated functions from ConfigEntityBase.
parent e0a111a8
......@@ -8,7 +8,6 @@
namespace Drupal\Core\Config\Entity;
use Drupal\Core\Entity\Entity;
use Drupal\Core\TypedData\ContextAwareInterface;
/**
* Defines a base configuration entity class.
......@@ -162,54 +161,4 @@ public function getExportProperties() {
}
return $properties;
}
/**
* Implements Drupal\Core\Entity\EntityInterface::getBCEntity().
*/
public function getBCEntity() {
return $this;
}
/**
* Implements Drupal\Core\Entity\EntityInterface::getOriginalEntity().
*/
public function getOriginalEntity() {
return $this;
}
/**
* Implements \Drupal\Core\TypedData\ContextAwareInterface::getName().
*/
public function getName() {
return NULL;
}
/**
* Implements \Drupal\Core\TypedData\ContextAwareInterface::getRoot().
*/
public function getRoot() {
return $this;
}
/**
* Implements \Drupal\Core\TypedData\ContextAwareInterface::getPropertyPath().
*/
public function getPropertyPath() {
return '';
}
/**
* Implements \Drupal\Core\TypedData\ContextAwareInterface::getParent().
*/
public function getParent() {
return NULL;
}
/**
* Implements \Drupal\Core\TypedData\ContextAwareInterface::setContext().
*/
public function setContext($name = NULL, ContextAwareInterface $parent = NULL) {
// As entities are always the root of the tree, we do not need to set any
// context.
}
}
......@@ -276,7 +276,7 @@ public function save(EntityInterface $entity) {
$transaction = db_transaction();
try {
// Ensure we are dealing with the actual entity.
$entity = $entity->getOriginalEntity();
$entity = $entity->getNGEntity();
// Sync the changes made in the fields array to the internal values array.
$entity->updateOriginalValues();
......@@ -504,7 +504,7 @@ public function delete(array $entities) {
try {
// Ensure we are dealing with the actual entities.
foreach ($entities as $id => $entity) {
$entities[$id] = $entity->getOriginalEntity();
$entities[$id] = $entity->getNGEntity();
}
$this->preDelete($entities);
......
......@@ -399,9 +399,9 @@ public function getBCEntity() {
}
/**
* Implements \Drupal\Core\Entity\EntityInterface::getOriginalEntity().
* Implements \Drupal\Core\Entity\EntityInterface::getNGEntity().
*/
public function getOriginalEntity() {
public function getNGEntity() {
return $this;
}
......
......@@ -66,9 +66,9 @@ function __construct(EntityNG $decorated, array &$definitions) {
}
/**
* Overrides Entity::getOriginalEntity().
* Overrides Entity::getNGEntity().
*/
public function getOriginalEntity() {
public function getNGEntity() {
return $this->decorated;
}
......
......@@ -206,7 +206,7 @@ public function getExportProperties();
* @return \Drupal\Core\Entity\EntityInterface
* The backward compatible entity.
*
* @see \Drupal\Core\Entity\EntityInterface::getOriginalEntity()
* @see \Drupal\Core\Entity\EntityInterface::getNGEntity()
*/
public function getBCEntity();
......@@ -218,7 +218,7 @@ public function getBCEntity();
*
* @see \Drupal\Core\Entity\EntityInterface::getBCEntity()
*/
public function getOriginalEntity();
public function getNGEntity();
/**
* Returns the translation support status.
......
......@@ -1428,7 +1428,7 @@ function field_attach_view(EntityInterface $entity, EntityDisplay $display, $lan
$null = NULL;
$output = field_invoke_method('view', $target_function, $entity, $null, $null, $options);
// Remove the BC layer now.
$entity = $entity->getOriginalEntity();
$entity = $entity->getNGEntity();
// Let other modules alter the renderable array.
$view_mode = $display->originalViewMode;
......
......@@ -82,7 +82,7 @@ function testMultilingualNodeForm() {
$this->drupalPost('node/add/page', $edit, t('Save'));
// Check that the node exists in the database.
$node = $this->drupalGetNodeByTitle($edit[$title_key])->getOriginalEntity();
$node = $this->drupalGetNodeByTitle($edit[$title_key])->getNGEntity();
$this->assertTrue($node, 'Node found in database.');
$this->assertTrue($node->language()->langcode == $langcode && $node->body->value == $body_value, 'Field language correctly set.');
......@@ -94,7 +94,7 @@ function testMultilingualNodeForm() {
'langcode' => $langcode,
);
$this->drupalPost(NULL, $edit, t('Save'));
$node = $this->drupalGetNodeByTitle($edit[$title_key], TRUE)->getOriginalEntity();
$node = $this->drupalGetNodeByTitle($edit[$title_key], TRUE)->getNGEntity();
$this->assertTrue($node, 'Node found in database.');
$this->assertTrue($node->language()->langcode == $langcode && $node->body->value == $body_value, 'Field language correctly changed.');
......
......@@ -259,7 +259,7 @@ protected function getFormSubmitAction(EntityInterface $entity) {
*/
protected function getTranslation(EntityInterface $entity, $langcode) {
// @todo remove once EntityBCDecorator is gone.
$entity = $entity->getOriginalEntity();
$entity = $entity->getNGEntity();
return $entity instanceof EntityNG ? $entity->getTranslation($langcode, FALSE) : $entity;
}
......
......@@ -611,7 +611,7 @@ function translation_entity_form_alter(array &$form, array &$form_state) {
// Handle fields shared between translations when there is at least one
// translation available or a new one is being created.
if (!$entity->isNew() && (!isset($translations[$form_langcode]) || count($translations) > 1)) {
$entity = $entity->getOriginalEntity();
$entity = $entity->getNGEntity();
if ($entity instanceof EntityNG) {
foreach ($entity->getPropertyDefinitions() as $property_name => $definition) {
if (isset($form[$property_name])) {
......
......@@ -238,7 +238,7 @@ function translation_entity_edit_page(EntityInterface $entity, Language $languag
function translation_entity_prepare_translation(EntityInterface $entity, Language $source, Language $target) {
// @todo Unify field and property handling.
$instances = field_info_instances($entity->entityType(), $entity->bundle());
$entity = $entity->getOriginalEntity();
$entity = $entity->getNGEntity();
if ($entity instanceof EntityNG) {
$source_translation = $entity->getTranslation($source->langcode);
$target_translation = $entity->getTranslation($target->langcode);
......
......@@ -984,10 +984,10 @@ public function getBCEntity() {
}
/**
* Implements Drupal\Core\Entity\EntityInterface::getOriginalEntity().
* Implements \Drupal\Core\Entity\EntityInterface::getNGEntity().
*/
public function getOriginalEntity() {
return $this->storage->getOriginalEntity();
public function getNGEntity() {
return $this->storage->getNGEntity();
}
/**
......
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