Patched to Drupal 8.4.8 level. See https://www.drupal.org/sa-core-2018-004 and patch...
[yaffs-website] / web / core / modules / content_moderation / src / ModerationInformationInterface.php
1 <?php
2
3 namespace Drupal\content_moderation;
4
5 use Drupal\Core\Entity\ContentEntityInterface;
6 use Drupal\Core\Entity\EntityInterface;
7 use Drupal\Core\Entity\EntityTypeInterface;
8
9 /**
10  * Interface for moderation_information service.
11  */
12 interface ModerationInformationInterface {
13
14   /**
15    * Determines if an entity is moderated.
16    *
17    * @param \Drupal\Core\Entity\EntityInterface $entity
18    *   The entity we may be moderating.
19    *
20    * @return bool
21    *   TRUE if this entity is moderated, FALSE otherwise.
22    */
23   public function isModeratedEntity(EntityInterface $entity);
24
25   /**
26    * Determines if an entity type can have moderated entities.
27    *
28    * @param \Drupal\Core\Entity\EntityTypeInterface $entity_type
29    *   An entity type object.
30    *
31    * @return bool
32    *   TRUE if this entity type can have moderated entities, FALSE otherwise.
33    */
34   public function canModerateEntitiesOfEntityType(EntityTypeInterface $entity_type);
35
36   /**
37    * Determines if an entity type/bundle entities should be moderated.
38    *
39    * @param \Drupal\Core\Entity\EntityTypeInterface $entity_type
40    *   The entity type definition to check.
41    * @param string $bundle
42    *   The bundle to check.
43    *
44    * @return bool
45    *   TRUE if an entity type/bundle entities should be moderated, FALSE
46    *   otherwise.
47    */
48   public function shouldModerateEntitiesOfBundle(EntityTypeInterface $entity_type, $bundle);
49
50   /**
51    * Loads the latest revision of a specific entity.
52    *
53    * @param string $entity_type_id
54    *   The entity type ID.
55    * @param int $entity_id
56    *   The entity ID.
57    *
58    * @return \Drupal\Core\Entity\ContentEntityInterface|null
59    *   The latest entity revision or NULL, if the entity type / entity doesn't
60    *   exist.
61    */
62   public function getLatestRevision($entity_type_id, $entity_id);
63
64   /**
65    * Returns the revision ID of the latest revision of the given entity.
66    *
67    * @param string $entity_type_id
68    *   The entity type ID.
69    * @param int $entity_id
70    *   The entity ID.
71    *
72    * @return int
73    *   The revision ID of the latest revision for the specified entity, or
74    *   NULL if there is no such entity.
75    */
76   public function getLatestRevisionId($entity_type_id, $entity_id);
77
78   /**
79    * Returns the revision ID of the default revision for the specified entity.
80    *
81    * @param string $entity_type_id
82    *   The entity type ID.
83    * @param int $entity_id
84    *   The entity ID.
85    *
86    * @return int
87    *   The revision ID of the default revision, or NULL if the entity was
88    *   not found.
89    */
90   public function getDefaultRevisionId($entity_type_id, $entity_id);
91
92   /**
93    * Returns the revision translation affected translation of a revision.
94    *
95    * @param \Drupal\Core\Entity\ContentEntityInterface $entity
96    *   The content entity.
97    *
98    * @return \Drupal\Core\Entity\ContentEntityInterface
99    *   The revision translation affected translation.
100    */
101   public function getAffectedRevisionTranslation(ContentEntityInterface $entity);
102
103   /**
104    * Determines if pending revisions are allowed.
105    *
106    * @internal
107    *
108    * @param \Drupal\Core\Entity\ContentEntityInterface $entity
109    *   The content entity.
110    *
111    * @return bool
112    *   If pending revisions are allowed.
113    */
114   public function isPendingRevisionAllowed(ContentEntityInterface $entity);
115
116   /**
117    * Determines if an entity is a latest revision.
118    *
119    * @param \Drupal\Core\Entity\ContentEntityInterface $entity
120    *   A revisionable content entity.
121    *
122    * @return bool
123    *   TRUE if the specified object is the latest revision of its entity,
124    *   FALSE otherwise.
125    */
126   public function isLatestRevision(ContentEntityInterface $entity);
127
128   /**
129    * Determines if a pending revision exists for the specified entity.
130    *
131    * @param \Drupal\Core\Entity\ContentEntityInterface $entity
132    *   The entity which may or may not have a pending revision.
133    *
134    * @return bool
135    *   TRUE if this entity has pending revisions available, FALSE otherwise.
136    */
137   public function hasPendingRevision(ContentEntityInterface $entity);
138
139   /**
140    * Determines if an entity is "live".
141    *
142    * A "live" entity revision is one whose latest revision is also the default,
143    * and whose moderation state, if any, is a published state.
144    *
145    * @param \Drupal\Core\Entity\ContentEntityInterface $entity
146    *   The entity to check.
147    *
148    * @return bool
149    *   TRUE if the specified entity is a live revision, FALSE otherwise.
150    */
151   public function isLiveRevision(ContentEntityInterface $entity);
152
153   /**
154    * Determines if the default revision for the given entity is published.
155    *
156    * The default revision is the same as the entity retrieved by "default" from
157    * the storage handler. If the entity is translated, check if any of the
158    * translations are published.
159    *
160    * @param \Drupal\Core\Entity\ContentEntityInterface $entity
161    *   The entity being saved.
162    *
163    * @return bool
164    *   TRUE if the default revision is published. FALSE otherwise.
165    */
166   public function isDefaultRevisionPublished(ContentEntityInterface $entity);
167
168   /**
169    * Gets the workflow for the given content entity.
170    *
171    * @param \Drupal\Core\Entity\ContentEntityInterface $entity
172    *   The content entity to get the workflow for.
173    *
174    * @return \Drupal\workflows\WorkflowInterface|null
175    *   The workflow entity. NULL if there is no workflow.
176    */
177   public function getWorkflowForEntity(ContentEntityInterface $entity);
178
179 }