You are here

class NodeModerationHandler in Workbench Moderation 8

Same name and namespace in other branches
  1. 8.2 src/Entity/Handler/NodeModerationHandler.php \Drupal\workbench_moderation\Entity\Handler\NodeModerationHandler

Customizations for node entities.

Hierarchy

Expanded class hierarchy of NodeModerationHandler

1 file declares its use of NodeModerationHandler
EntityTypeInfo.php in src/EntityTypeInfo.php

File

src/Entity/Handler/NodeModerationHandler.php, line 10

Namespace

Drupal\workbench_moderation\Entity\Handler
View source
class NodeModerationHandler extends ModerationHandler {

  /**
   * {@inheritdoc}
   */
  public function enforceRevisionsEntityFormAlter(array &$form, FormStateInterface $form_state, $form_id) {
    $form['revision']['#disabled'] = TRUE;
    $form['revision']['#default_value'] = TRUE;
    $form['revision']['#description'] = $this
      ->t('Revisions are required.');
  }

  /**
   * {@inheritdoc}
   */
  public function enforceRevisionsBundleFormAlter(array &$form, FormStateInterface $form_state, $form_id) {

    /* @var \Drupal\node\Entity\NodeType $entity */
    $entity = $form_state
      ->getFormObject()
      ->getEntity();
    if ($entity
      ->getThirdPartySetting('workbench_moderation', 'enabled', FALSE)) {

      // Force the revision checkbox on.
      $form['workflow']['options']['#default_value']['revision'] = 'revision';
      $form['workflow']['options']['revision']['#disabled'] = TRUE;
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
ModerationHandler::createInstance public static function Instantiates a new instance of this entity handler. Overrides EntityHandlerInterface::createInstance
ModerationHandler::onBundleModerationConfigurationFormSubmit public function Operates on the bundle definition that has been marked as moderatable. Overrides ModerationHandlerInterface::onBundleModerationConfigurationFormSubmit
ModerationHandler::onPresave public function Work to be done before saving en entity. Overrides ModerationHandlerInterface::onPresave
NodeModerationHandler::enforceRevisionsBundleFormAlter public function Alters bundle forms to enforce revision handling. Overrides ModerationHandler::enforceRevisionsBundleFormAlter
NodeModerationHandler::enforceRevisionsEntityFormAlter public function Alters entity forms to enforce revision handling. Overrides ModerationHandler::enforceRevisionsEntityFormAlter
StringTranslationTrait::$stringTranslation protected property The string translation service. 1
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.