ModerationInformationInterface.php 5.3 KB

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