diff --git a/core/lib/Drupal/Core/Entity/Entity.php b/core/lib/Drupal/Core/Entity/Entity.php index d86f6c7..edb91ec 100644 --- a/core/lib/Drupal/Core/Entity/Entity.php +++ b/core/lib/Drupal/Core/Entity/Entity.php @@ -355,9 +355,7 @@ public function getTranslationLanguages($include_default = TRUE) { * Implements \Drupal\Core\Entity\EntityInterface::save(). */ public function save() { - $return = \Drupal::entityManager()->getStorageController($this->entityType)->save($this); - $this->changed(); - return $return; + return \Drupal::entityManager()->getStorageController($this->entityType)->save($this); } /** @@ -366,7 +364,6 @@ public function save() { public function delete() { if (!$this->isNew()) { \Drupal::entityManager()->getStorageController($this->entityType)->delete(array($this->id() => $this)); - $this->changed(); } } @@ -558,6 +555,7 @@ public function preSave(EntityStorageControllerInterface $storage_controller) { * {@inheritdoc} */ public function postSave(EntityStorageControllerInterface $storage_controller, $update = TRUE) { + $this->changed(); } /** @@ -582,6 +580,9 @@ public static function preDelete(EntityStorageControllerInterface $storage_contr * {@inheritdoc} */ public static function postDelete(EntityStorageControllerInterface $storage_controller, array $entities) { + foreach ($entities as $entity) { + $entity->changed(); + } } /** @@ -648,40 +649,40 @@ public static function baseFieldDefinitions($entity_type) { /** * {@inheritdoc} */ - public function relatedEntities() { - $relationships = array(); + public function referencedEntities() { + $referenced_entities = array(); // @todo Remove when all entities are converted to EntityNG. if (!$this->getPropertyDefinitions()) { - return $relationships; + return $referenced_entities; } - // Gather a list of related entities. + // Gather a list of referenced entities. foreach ($this->getProperties() as $name => $definition) { $field_items = $this->get($name); foreach ($field_items as $offset => $field_item) { if ($field_item instanceof EntityReferenceItem && $entity = $field_item->entity) { - $relationships[] = $entity; + $referenced_entities[] = $entity; } } } - return $relationships; + return $referenced_entities; } /** * {@inheritdoc} */ public function changed() { - $related_entity_ids = array( + $referenced_entity_ids = array( $this->entityType() => array($this->id() => TRUE), ); - foreach ($this->relatedEntities() as $related_entity) { - $related_entity_ids[$related_entity->entityType()][$related_entity->id()] = TRUE; + foreach ($this->referencedEntities() as $referenced_entity) { + $referenced_entity_ids[$referenced_entity->entityType()][$referenced_entity->id()] = TRUE; } - foreach ($related_entity_ids as $entity_type => $entity_ids) { + foreach ($referenced_entity_ids as $entity_type => $entity_ids) { if (\Drupal::entityManager()->hasController($entity_type, 'render')) { \Drupal::entityManager()->getRenderController($entity_type)->resetCache(array_keys($entity_ids)); } diff --git a/core/lib/Drupal/Core/Entity/EntityBCDecorator.php b/core/lib/Drupal/Core/Entity/EntityBCDecorator.php index 0ff8fd0..ef27bcb 100644 --- a/core/lib/Drupal/Core/Entity/EntityBCDecorator.php +++ b/core/lib/Drupal/Core/Entity/EntityBCDecorator.php @@ -631,7 +631,7 @@ public static function baseFieldDefinitions($entity_type) { * * @return array */ - public function relatedEntities() { + public function referencedEntities() { return array(); } diff --git a/core/lib/Drupal/Core/Entity/EntityInterface.php b/core/lib/Drupal/Core/Entity/EntityInterface.php index 28ad393..50b45f6 100644 --- a/core/lib/Drupal/Core/Entity/EntityInterface.php +++ b/core/lib/Drupal/Core/Entity/EntityInterface.php @@ -348,7 +348,7 @@ public static function baseFieldDefinitions($entity_type); * @return array * An array of entities. */ - public function relatedEntities(); + public function referencedEntities(); /** * Acts on an entity after it was saved or deleted. diff --git a/core/modules/views_ui/lib/Drupal/views_ui/ViewUI.php b/core/modules/views_ui/lib/Drupal/views_ui/ViewUI.php index 4a4d896..d33d375 100644 --- a/core/modules/views_ui/lib/Drupal/views_ui/ViewUI.php +++ b/core/modules/views_ui/lib/Drupal/views_ui/ViewUI.php @@ -1250,8 +1250,8 @@ public static function baseFieldDefinitions($entity_type) { /** * {@inheritdoc} */ - public function relatedEntities() { - return $this->storage->relatedEntities(); + public function referencedEntities() { + return $this->storage->referencedEntities(); } /**