ModerationHandler
class ModerationHandler implements ModerationHandlerInterface, EntityHandlerInterface (View source)
| internal |
Common customizations for most/all entities.
This class is intended primarily as a base class.
Traits
Wrapper methods for \Drupal\Core\StringTranslation\TranslationInterface.
Properties
| protected TranslationInterface | $stringTranslation | The string translation service. |
from StringTranslationTrait |
Methods
Translates a string to the current language or to a given language.
Formats a string containing a count of items.
Returns the number of plurals supported by a given language.
Gets the string translation service.
Instantiates a new instance of this entity handler.
Operates on moderated content entities preSave().
Alters entity forms to enforce revision handling.
Alters bundle forms to enforce revision handling.
Details
protected TranslatableMarkup
t(string $string, array $args = [], array $options = [])
Translates a string to the current language or to a given language.
See \Drupal\Core\StringTranslation\TranslatableMarkup::__construct() for important security information and usage guidelines.
In order for strings to be localized, make them available in one of the ways supported by the
protected
formatPlural($count, $singular, $plural, array $args = [], array $options = [])
Formats a string containing a count of items.
protected
getNumberOfPlurals($langcode = NULL)
Returns the number of plurals supported by a given language.
protected TranslationInterface
getStringTranslation()
Gets the string translation service.
$this
setStringTranslation(TranslationInterface $translation)
Sets the string translation service to use.
static EntityHandlerInterface
createInstance(ContainerInterface $container, EntityTypeInterface $entity_type)
Instantiates a new instance of this entity handler.
This is a factory method that returns a new instance of this object. The factory should pass any needed dependencies into the constructor of this object, but not the container itself. Every call to this method must return a new instance of this object; that is, it may not implement a singleton.
bool
isModeratedEntity(ContentEntityInterface $entity)
Determines if an entity should be moderated.
At the workflow level, moderation is enabled or disabled for entire entity types or bundles. After a bundle has been enabled, there maybe be further decisions each entity type may make to evaluate if a given entity is appropriate to be included in a moderation workflow. The handler is only consulted after the user has configured the associated entity type and bundle to be included in a moderation workflow.
Returning FALSE will remove the moderation state field widget from the associated entity form and opt out of all moderation related entity semantics, such as creating new revisions and changing the publishing status of a revision.
onPresave(ContentEntityInterface $entity, bool $default_revision, bool $published_state)
Operates on moderated content entities preSave().
enforceRevisionsEntityFormAlter(array $form, FormStateInterface $form_state, string $form_id)
Alters entity forms to enforce revision handling.
enforceRevisionsBundleFormAlter(array $form, FormStateInterface $form_state, string $form_id)
Alters bundle forms to enforce revision handling.