class WorkspacePublishEvent

Same name and namespace in other branches
  1. 10 core/modules/workspaces/src/Event/WorkspacePublishEvent.php \Drupal\workspaces\Event\WorkspacePublishEvent

Defines the workspace publish event.

Hierarchy

  • class \Drupal\Component\EventDispatcher\Event extends \Symfony\Contracts\EventDispatcher\Event

Expanded class hierarchy of WorkspacePublishEvent

2 files declare their use of WorkspacePublishEvent
WorkspaceAssociation.php in core/modules/workspaces/src/WorkspaceAssociation.php
WorkspaceSubscriber.php in core/modules/content_moderation/src/EventSubscriber/WorkspaceSubscriber.php

File

core/modules/workspaces/src/Event/WorkspacePublishEvent.php, line 12

Namespace

Drupal\workspaces\Event
View source
abstract class WorkspacePublishEvent extends Event {
    
    /**
     * The IDs of the entities that are being published.
     */
    protected readonly array $publishedRevisionIds;
    
    /**
     * Whether an event subscriber requested the publishing to be stopped.
     */
    protected bool $publishingStopped = FALSE;
    
    /**
     * The reason why publishing stopped. For use in messages.
     */
    protected string $publishingStoppedReason = '';
    
    /**
     * Constructs a new WorkspacePublishEvent.
     *
     * @param \Drupal\workspaces\WorkspaceInterface $workspace
     *   The workspace.
     * @param array $published_revision_ids
     *   The IDs of the entities that are being published.
     */
    public function __construct(WorkspaceInterface $workspace, array $published_revision_ids) {
        $this->publishedRevisionIds = $published_revision_ids;
    }
    
    /**
     * Gets the workspace.
     *
     * @return \Drupal\workspaces\WorkspaceInterface
     *   The workspace.
     */
    public function getWorkspace() : WorkspaceInterface {
        return $this->workspace;
    }
    
    /**
     * Gets the entity IDs that are being published as part of the workspace.
     *
     * @return array
     *   Returns a multidimensional array where the first level keys are entity
     *   type IDs and the values are an array of entity IDs keyed by revision IDs.
     */
    public function getPublishedRevisionIds() : array {
        return $this->publishedRevisionIds;
    }
    
    /**
     * Determines whether a subscriber requested the publishing to be stopped.
     *
     * @return bool
     *   TRUE if the publishing of the workspace should be stopped, FALSE
     *   otherwise.
     */
    public function isPublishingStopped() : bool {
        return $this->publishingStopped;
    }
    
    /**
     * Signals that the workspace publishing should be aborted.
     *
     * @return $this
     */
    public function stopPublishing() : static {
        $this->publishingStopped = TRUE;
        return $this;
    }
    
    /**
     * Gets the reason for stopping the workspace publication.
     *
     * @return string|\Drupal\Core\StringTranslation\TranslatableMarkup
     *   The reason for stopping the workspace publication or an empty string if
     *   no reason is provided.
     */
    public function getPublishingStoppedReason() : string|TranslatableMarkup {
        return $this->publishingStoppedReason;
    }
    
    /**
     * Sets the reason for stopping the workspace publication.
     *
     * @param string|\Stringable $reason
     *   The reason for stopping the workspace publication.
     *
     * @return $this
     */
    public function setPublishingStoppedReason(string|\Stringable $reason) : static {
        $this->publishingStoppedReason = $reason;
        return $this;
    }

}

Members

Title Sort descending Modifiers Object type Summary
WorkspacePublishEvent::$publishedRevisionIds protected property The IDs of the entities that are being published.
WorkspacePublishEvent::$publishingStopped protected property Whether an event subscriber requested the publishing to be stopped.
WorkspacePublishEvent::$publishingStoppedReason protected property The reason why publishing stopped. For use in messages.
WorkspacePublishEvent::getPublishedRevisionIds public function Gets the entity IDs that are being published as part of the workspace.
WorkspacePublishEvent::getPublishingStoppedReason public function Gets the reason for stopping the workspace publication.
WorkspacePublishEvent::getWorkspace public function Gets the workspace.
WorkspacePublishEvent::isPublishingStopped public function Determines whether a subscriber requested the publishing to be stopped.
WorkspacePublishEvent::setPublishingStoppedReason public function Sets the reason for stopping the workspace publication.
WorkspacePublishEvent::stopPublishing public function Signals that the workspace publishing should be aborted.
WorkspacePublishEvent::__construct public function Constructs a new WorkspacePublishEvent.

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.