X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=web%2Fcore%2Flib%2FDrupal%2FCore%2FEntity%2FQuery%2FQueryBase.php;h=5c94b444789dd873c55235c2371978fdcb2dc54e;hp=ed3d12b2c857316c0f95d8d821a93735151c8b43;hb=9917807b03b64faf00f6a1f29dcb6eafc454efa5;hpb=aea91e65e895364e460983b890e295aa5d5540a5 diff --git a/web/core/lib/Drupal/Core/Entity/Query/QueryBase.php b/web/core/lib/Drupal/Core/Entity/Query/QueryBase.php index ed3d12b2c..5c94b4447 100644 --- a/web/core/lib/Drupal/Core/Entity/Query/QueryBase.php +++ b/web/core/lib/Drupal/Core/Entity/Query/QueryBase.php @@ -108,6 +108,13 @@ abstract class QueryBase implements QueryInterface { */ protected $allRevisions = FALSE; + /** + * Flag indicating whether to query the latest revision. + * + * @var bool + */ + protected $latestRevision = FALSE; + /** * The query pager data. * @@ -252,6 +259,22 @@ abstract class QueryBase implements QueryInterface { */ public function currentRevision() { $this->allRevisions = FALSE; + $this->latestRevision = FALSE; + return $this; + } + + /** + * Queries the latest revision. + * + * The latest revision is the most recent revision of an entity. This will be + * either the default revision, or a pending revision if one exists and it is + * newer than the default. + * + * @return $this + */ + public function latestRevision() { + $this->allRevisions = TRUE; + $this->latestRevision = TRUE; return $this; } @@ -260,6 +283,7 @@ abstract class QueryBase implements QueryInterface { */ public function allRevisions() { $this->allRevisions = TRUE; + $this->latestRevision = FALSE; return $this; } @@ -348,14 +372,14 @@ abstract class QueryBase implements QueryInterface { * {@inheritdoc} */ public function hasAllTags() { - return !(boolean)array_diff(func_get_args(), array_keys($this->alterTags)); + return !(boolean) array_diff(func_get_args(), array_keys($this->alterTags)); } /** * {@inheritdoc} */ public function hasAnyTag() { - return (boolean)array_intersect(func_get_args(), array_keys($this->alterTags)); + return (boolean) array_intersect(func_get_args(), array_keys($this->alterTags)); } /**