You are here

class ConfigEntityRevisionsModerationHandler in Config Entity Revisions 8

Same name and namespace in other branches
  1. 8.2 src/Entity/Handler/ConfigEntityRevisionsModerationHandler.php \Drupal\config_entity_revisions\Entity\Handler\ConfigEntityRevisionsModerationHandler
  2. 1.x src/Entity/Handler/ConfigEntityRevisionsModerationHandler.php \Drupal\config_entity_revisions\Entity\Handler\ConfigEntityRevisionsModerationHandler

Customizations for config_entity_revisions entities.

Hierarchy

Expanded class hierarchy of ConfigEntityRevisionsModerationHandler

File

src/Entity/Handler/ConfigEntityRevisionsModerationHandler.php, line 19
Contains Drupal\config_entity_revisions\Entity\Handler\ConfigEntityRevisionsModerationHandler.

Namespace

Drupal\config_entity_revisions\Entity\Handler
View source
class ConfigEntityRevisionsModerationHandler extends ModerationHandler {

  /**
   * The moderation information service.
   *
   * @var ModerationInformationInterface
   */
  protected $moderationInfo;

  /**
   * NodeModerationHandler constructor.
   *
   * @param ModerationInformationInterface $moderation_info
   *   The moderation information service.
   */
  public function __construct(ModerationInformationInterface $moderation_info) {
    $this->moderationInfo = $moderation_info;
  }

  /**
   * {@inheritdoc}
   */
  public static function createInstance(ContainerInterface $container, EntityTypeInterface $entity_type) {
    return new static($container
      ->get('content_moderation.moderation_information'));
  }

  /**
   * {@inheritdoc}
   */
  public function onPresave(ContentEntityInterface $entity, $default_revision, $published_state) {

    // Updating an existing revision?
    if (!$entity
      ->isNewRevision()) {
      return;
    }
    $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();
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
ConfigEntityRevisionsModerationHandler::$moderationInfo protected property The moderation information service.
ConfigEntityRevisionsModerationHandler::createInstance public static function Instantiates a new instance of this entity handler. Overrides ModerationHandler::createInstance
ConfigEntityRevisionsModerationHandler::onPresave public function Operates on moderated content entities preSave(). Overrides ModerationHandler::onPresave
ConfigEntityRevisionsModerationHandler::__construct public function NodeModerationHandler constructor.
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
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.