Version 1
[yaffs-website] / web / core / modules / workflows / tests / modules / workflow_type_test / src / DecoratedState.php
1 <?php
2
3 namespace Drupal\workflow_type_test;
4
5 use Drupal\workflows\StateInterface;
6
7 /**
8  * A value object representing a workflow state.
9  */
10 class DecoratedState implements StateInterface {
11
12   /**
13    * The vanilla state object from the Workflow module.
14    *
15    * @var \Drupal\workflows\StateInterface
16    */
17   protected $state;
18
19   /**
20    * Extra information added to state.
21    *
22    * @var string
23    */
24   protected $extra;
25
26   /**
27    * DecoratedState constructor.
28    *
29    * @param \Drupal\workflows\StateInterface $state
30    *   The vanilla state object from the Workflow module.
31    * @param string $extra
32    *   (optional) Extra information stored on the state. Defaults to ''.
33    */
34   public function __construct(StateInterface $state, $extra = '') {
35     $this->state = $state;
36     $this->extra = $extra;
37   }
38
39   /**
40    * Gets the extra information stored on the state.
41    *
42    * @return string
43    */
44   public function getExtra() {
45     return $this->extra;
46   }
47
48   /**
49    * {@inheritdoc}
50    */
51   public function id() {
52     return $this->state->id();
53   }
54
55   /**
56    * {@inheritdoc}
57    */
58   public function label() {
59     return $this->state->label();
60   }
61
62   /**
63    * {@inheritdoc}
64    */
65   public function weight() {
66     return $this->state->weight();
67   }
68
69   /**
70    * {@inheritdoc}
71    */
72   public function canTransitionTo($to_state_id) {
73     return $this->state->canTransitionTo($to_state_id);
74   }
75
76   /**
77    * {@inheritdoc}
78    */
79   public function getTransitionTo($to_state_id) {
80     return $this->state->getTransitionTo($to_state_id);
81   }
82
83   /**
84    * {@inheritdoc}
85    */
86   public function getTransitions() {
87     return $this->state->getTransitions();
88   }
89
90 }