class ModerationHandler
Same name in other branches
- 9 core/modules/content_moderation/src/Entity/Handler/ModerationHandler.php \Drupal\content_moderation\Entity\Handler\ModerationHandler
- 10 core/modules/content_moderation/src/Entity/Handler/ModerationHandler.php \Drupal\content_moderation\Entity\Handler\ModerationHandler
- 11.x core/modules/content_moderation/src/Entity/Handler/ModerationHandler.php \Drupal\content_moderation\Entity\Handler\ModerationHandler
Common customizations for most/all entities.
This class is intended primarily as a base class.
@internal
Hierarchy
- class \Drupal\content_moderation\Entity\Handler\ModerationHandler implements \Drupal\content_moderation\Entity\Handler\ModerationHandlerInterface, \Drupal\Core\Entity\EntityHandlerInterface uses \Drupal\Core\StringTranslation\StringTranslationTrait
Expanded class hierarchy of ModerationHandler
3 files declare their use of ModerationHandler
- EntityTypeInfo.php in core/
modules/ content_moderation/ src/ EntityTypeInfo.php - EntityTypeInfoTest.php in core/
modules/ content_moderation/ tests/ src/ Kernel/ EntityTypeInfoTest.php - ModerationInformationTest.php in core/
modules/ content_moderation/ tests/ src/ Unit/ ModerationInformationTest.php
File
-
core/
modules/ content_moderation/ src/ Entity/ Handler/ ModerationHandler.php, line 20
Namespace
Drupal\content_moderation\Entity\HandlerView source
class ModerationHandler implements ModerationHandlerInterface, EntityHandlerInterface {
use StringTranslationTrait;
/**
* {@inheritdoc}
*/
public static function createInstance(ContainerInterface $container, EntityTypeInterface $entity_type) {
return new static();
}
/**
* {@inheritdoc}
*/
public function onPresave(ContentEntityInterface $entity, $default_revision, $published_state) {
// When entities are syncing, content moderation should not force a new
// revision to be created and should not update the default status of a
// revision. This is useful if changes are being made to entities or
// revisions which are not part of editorial updates triggered by normal
// content changes.
if (!$entity->isSyncing()) {
$entity->setNewRevision(TRUE);
$entity->isDefaultRevision($default_revision);
}
// Update publishing status if it can be updated and if it needs updating.
if ($entity instanceof EntityPublishedInterface && $entity->isPublished() !== $published_state) {
$published_state ? $entity->setPublished() : $entity->setUnpublished();
}
}
/**
* {@inheritdoc}
*/
public function enforceRevisionsEntityFormAlter(array &$form, FormStateInterface $form_state, $form_id) {
}
/**
* {@inheritdoc}
*/
public function enforceRevisionsBundleFormAlter(array &$form, FormStateInterface $form_state, $form_id) {
}
}
Members
Title Sort descending | Modifiers | Object type | Summary | Overriden Title | Overrides |
---|---|---|---|---|---|
ModerationHandler::createInstance | public static | function | Instantiates a new instance of this entity handler. | Overrides EntityHandlerInterface::createInstance | 1 |
ModerationHandler::enforceRevisionsBundleFormAlter | public | function | Alters bundle forms to enforce revision handling. | Overrides ModerationHandlerInterface::enforceRevisionsBundleFormAlter | 2 |
ModerationHandler::enforceRevisionsEntityFormAlter | public | function | Alters entity forms to enforce revision handling. | Overrides ModerationHandlerInterface::enforceRevisionsEntityFormAlter | 2 |
ModerationHandler::onPresave | public | function | Operates on moderated content entities preSave(). | Overrides ModerationHandlerInterface::onPresave | |
StringTranslationTrait::$stringTranslation | protected | property | The string translation service. | ||
StringTranslationTrait::formatPlural | protected | function | Formats a string containing a count of items. | ||
StringTranslationTrait::getNumberOfPlurals | protected | function | Returns the number of plurals supported by a given language. | ||
StringTranslationTrait::getStringTranslation | protected | function | Gets the string translation service. | ||
StringTranslationTrait::setStringTranslation | public | function | Sets the string translation service to use. | 2 | |
StringTranslationTrait::t | protected | function | Translates a string to the current language or to a given language. |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.