Commit c3c67435 authored by webchick's avatar webchick

Issue #2044583 by jlindsey15, Gábor Hojtsy, Wim Leers, Berdir: Add...

Issue #2044583 by jlindsey15, Gábor Hojtsy, Wim Leers, Berdir: Add EntityChangedInterface to allow entities with 'changed' field to be properly cached.
parent 61e213fe
<?php
/**
* @file
* Contains \Drupal\Core\Entity\EntityChangedInterface.
*/
namespace Drupal\Core\Entity;
/**
* Defines a common interface for entity change timestamp tracking.
*
* This data may be useful for more precise cache invalidation (especially
* on the client side) and concurrent editing locking.
*/
interface EntityChangedInterface {
/**
* Returns the timestamp of the last entity change.
*
* @return int
* The timestamp of the last entity save operation.
*/
public function getChangedTime();
}
......@@ -8,11 +8,12 @@
namespace Drupal\comment;
use Drupal\Core\Entity\ContentEntityInterface;
use Drupal\Core\Entity\EntityChangedInterface;
/**
* Provides an interface defining a comment entity.
*/
interface CommentInterface extends ContentEntityInterface {
interface CommentInterface extends ContentEntityInterface, EntityChangedInterface {
/**
* Returns the permalink URL for this comment.
......
......@@ -460,4 +460,12 @@ public static function baseFieldDefinitions($entity_type) {
);
return $properties;
}
/**
* {@inheritdoc}
*/
public function getChangedTime() {
return $this->changed->value;
}
}
......@@ -8,12 +8,13 @@
namespace Drupal\file;
use Drupal\Core\Entity\ContentEntityInterface;
use Drupal\Core\Entity\EntityChangedInterface;
use Drupal\user\UserInterface;
/**
* Defines getter and setter methods for file entity base fields.
*/
interface FileInterface extends ContentEntityInterface {
interface FileInterface extends ContentEntityInterface, EntityChangedInterface {
/**
* Returns the name of the file.
......@@ -110,14 +111,6 @@ public function setPermanent();
*/
public function setTemporary();
/**
* Returns the timestamp when the file was created.
*
* @return int
* Creation timestamp of the file.
*/
public function getChangedTime();
/**
* Returns the user that owns this file.
*
......
......@@ -7,13 +7,14 @@
namespace Drupal\node;
use Drupal\Core\Entity\EntityChangedInterface;
use Drupal\Core\Entity\ContentEntityInterface;
use Drupal\user\UserInterface;
/**
* Provides an interface defining a node entity.
*/
interface NodeInterface extends ContentEntityInterface {
interface NodeInterface extends ContentEntityInterface, EntityChangedInterface {
/**
* Returns the node type.
......@@ -62,14 +63,6 @@ public function getCreatedTime();
*/
public function setCreatedTime($timestamp);
/**
* Returns the node modification timestamp.
*
* @return int
* Node creation timestamp.
*/
public function getChangedTime();
/**
* Returns the node promotion status.
*
......
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