3 namespace Drupal\content_moderation;
5 use Drupal\workflows\StateInterface;
8 * A value object representing a workflow state for content moderation.
10 class ContentModerationState implements StateInterface {
13 * The vanilla state object from the Workflow module.
15 * @var \Drupal\workflows\StateInterface
20 * If entities should be published if in this state.
27 * If entities should be the default revision if in this state.
31 protected $defaultRevision;
34 * ContentModerationState constructor.
36 * Decorates state objects to add methods to determine if an entity should be
37 * published or made the default revision.
39 * @param \Drupal\workflows\StateInterface $state
40 * The vanilla state object from the Workflow module.
41 * @param bool $published
42 * (optional) TRUE if entities should be published if in this state, FALSE
43 * if not. Defaults to FALSE.
44 * @param bool $default_revision
45 * (optional) TRUE if entities should be the default revision if in this
46 * state, FALSE if not. Defaults to FALSE.
48 public function __construct(StateInterface $state, $published = FALSE, $default_revision = FALSE) {
49 $this->state = $state;
50 $this->published = $published;
51 $this->defaultRevision = $default_revision;
55 * Determines if entities should be published if in this state.
59 public function isPublishedState() {
60 return $this->published;
64 * Determines if entities should be the default revision if in this state.
68 public function isDefaultRevisionState() {
69 return $this->defaultRevision;
75 public function id() {
76 return $this->state->id();
82 public function label() {
83 return $this->state->label();
89 public function weight() {
90 return $this->state->weight();
96 public function canTransitionTo($to_state_id) {
97 return $this->state->canTransitionTo($to_state_id);
103 public function getTransitionTo($to_state_id) {
104 return $this->state->getTransitionTo($to_state_id);
110 public function getTransitions() {
111 return $this->state->getTransitions();