3 namespace Drupal\content_moderation;
5 use Drupal\Core\Entity\ContentEntityInterface;
6 use Drupal\Core\Entity\EntityInterface;
7 use Drupal\Core\Entity\EntityTypeInterface;
10 * Interface for moderation_information service.
12 interface ModerationInformationInterface {
15 * Determines if an entity is moderated.
17 * @param \Drupal\Core\Entity\EntityInterface $entity
18 * The entity we may be moderating.
21 * TRUE if this entity is moderated, FALSE otherwise.
23 public function isModeratedEntity(EntityInterface $entity);
26 * Determines if an entity type can have moderated entities.
28 * @param \Drupal\Core\Entity\EntityTypeInterface $entity_type
29 * An entity type object.
32 * TRUE if this entity type can have moderated entities, FALSE otherwise.
34 public function canModerateEntitiesOfEntityType(EntityTypeInterface $entity_type);
37 * Determines if an entity type/bundle entities should be moderated.
39 * @param \Drupal\Core\Entity\EntityTypeInterface $entity_type
40 * The entity type definition to check.
41 * @param string $bundle
42 * The bundle to check.
45 * TRUE if an entity type/bundle entities should be moderated, FALSE
48 public function shouldModerateEntitiesOfBundle(EntityTypeInterface $entity_type, $bundle);
51 * Loads the latest revision of a specific entity.
53 * @param string $entity_type_id
55 * @param int $entity_id
58 * @return \Drupal\Core\Entity\ContentEntityInterface|null
59 * The latest entity revision or NULL, if the entity type / entity doesn't
62 public function getLatestRevision($entity_type_id, $entity_id);
65 * Returns the revision ID of the latest revision of the given entity.
67 * @param string $entity_type_id
69 * @param int $entity_id
73 * The revision ID of the latest revision for the specified entity, or
74 * NULL if there is no such entity.
76 public function getLatestRevisionId($entity_type_id, $entity_id);
79 * Returns the revision ID of the default revision for the specified entity.
81 * @param string $entity_type_id
83 * @param int $entity_id
87 * The revision ID of the default revision, or NULL if the entity was
90 public function getDefaultRevisionId($entity_type_id, $entity_id);
93 * Returns the revision translation affected translation of a revision.
95 * @param \Drupal\Core\Entity\ContentEntityInterface $entity
98 * @return \Drupal\Core\Entity\ContentEntityInterface
99 * The revision translation affected translation.
101 public function getAffectedRevisionTranslation(ContentEntityInterface $entity);
104 * Determines if an entity is a latest revision.
106 * @param \Drupal\Core\Entity\ContentEntityInterface $entity
107 * A revisionable content entity.
110 * TRUE if the specified object is the latest revision of its entity,
113 public function isLatestRevision(ContentEntityInterface $entity);
116 * Determines if a pending revision exists for the specified entity.
118 * @param \Drupal\Core\Entity\ContentEntityInterface $entity
119 * The entity which may or may not have a pending revision.
122 * TRUE if this entity has pending revisions available, FALSE otherwise.
124 public function hasPendingRevision(ContentEntityInterface $entity);
127 * Determines if an entity is "live".
129 * A "live" entity revision is one whose latest revision is also the default,
130 * and whose moderation state, if any, is a published state.
132 * @param \Drupal\Core\Entity\ContentEntityInterface $entity
133 * The entity to check.
136 * TRUE if the specified entity is a live revision, FALSE otherwise.
138 public function isLiveRevision(ContentEntityInterface $entity);
141 * Determines if the default revision for the given entity is published.
143 * The default revision is the same as the entity retrieved by "default" from
144 * the storage handler. If the entity is translated, check if any of the
145 * translations are published.
147 * @param \Drupal\Core\Entity\ContentEntityInterface $entity
148 * The entity being saved.
151 * TRUE if the default revision is published. FALSE otherwise.
153 public function isDefaultRevisionPublished(ContentEntityInterface $entity);
156 * Gets the workflow for the given content entity.
158 * @param \Drupal\Core\Entity\ContentEntityInterface $entity
159 * The content entity to get the workflow for.
161 * @return \Drupal\workflows\WorkflowInterface|null
162 * The workflow entity. NULL if there is no workflow.
164 public function getWorkflowForEntity(ContentEntityInterface $entity);
167 * Gets unsupported features for a given entity type.
169 * @param \Drupal\Core\Entity\EntityTypeInterface $entity_type
170 * The entity type to get the unsupported features for.
173 * An array of unsupported features for this entity type.
175 public function getUnsupportedFeatures(EntityTypeInterface $entity_type);