class ModerationHandler in Workbench Moderation 8.2
Same name and namespace in other branches
- 8 src/Entity/Handler/ModerationHandler.php \Drupal\workbench_moderation\Entity\Handler\ModerationHandler
Common customizations for most/all entities.
This class is intended primarily as a base class.
Hierarchy
- class \Drupal\workbench_moderation\Entity\Handler\ModerationHandler implements EntityHandlerInterface, ModerationHandlerInterface uses StringTranslationTrait
Expanded class hierarchy of ModerationHandler
1 file declares its use of ModerationHandler
File
- src/
Entity/ Handler/ ModerationHandler.php, line 23 - Contains Drupal\workbench_moderation\Entity\Handler\GenericCustomizations.
Namespace
Drupal\workbench_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) {
// This is *probably* not necessary if configuration is setup correctly,
// but it can't hurt.
$entity
->setNewRevision(TRUE);
$entity
->isDefaultRevision($default_revision);
}
/**
* {@inheritdoc}
*/
public function onBundleModerationConfigurationFormSubmit(ConfigEntityInterface $bundle) {
// The Revisions portion of Entity API is not uniformly applied or consistent.
// Until that's fixed in core, we'll make a best-attempt to apply it to
// the common entity patterns so as to avoid every entity type needing to
// implement this method, although some will still need to do so for now.
// This is the API that should be universal, but isn't yet. See NodeType
// for an example.
if (method_exists($bundle, 'setNewRevision')) {
$bundle
->setNewRevision(TRUE);
}
elseif ($bundle
->get('new_revision') !== NULL) {
$bundle
->set('new_revision', TRUE);
}
elseif ($bundle
->get('revision') !== NULL) {
$bundle
->set('revision', TRUE);
}
$bundle
->save();
return;
}
/**
* {@inheritdoc}
*/
public function enforceRevisionsEntityFormAlter(array &$form, FormStateInterface $form_state, $form_id) {
return;
}
/**
* {@inheritdoc}
*/
public function enforceRevisionsBundleFormAlter(array &$form, FormStateInterface $form_state, $form_id) {
return;
}
}