Newer
Older
<?php
namespace Drupal\content_moderation\Entity;
use Drupal\Core\Config\Entity\ConfigEntityBase;
use Drupal\content_moderation\ModerationStateTransitionInterface;
/**
* Defines the Moderation state transition entity.
*
* @ConfigEntityType(
* id = "moderation_state_transition",
* label = @Translation("Moderation state transition"),
* handlers = {
* "list_builder" = "Drupal\content_moderation\ModerationStateTransitionListBuilder",
* "form" = {
* "add" = "Drupal\content_moderation\Form\ModerationStateTransitionForm",
* "edit" = "Drupal\content_moderation\Form\ModerationStateTransitionForm",
* "delete" = "Drupal\content_moderation\Form\ModerationStateTransitionDeleteForm"
* },
Alex Pott
committed
* "route_provider" = {
* "html" = "Drupal\Core\Entity\Routing\DefaultHtmlRouteProvider",
* },
* },
* config_prefix = "state_transition",
* admin_permission = "administer moderation state transitions",
* entity_keys = {
* "id" = "id",
* "label" = "label",
* "uuid" = "uuid",
* "weight" = "weight"
* },
* links = {
Alex Pott
committed
* "add-form" = "/admin/config/workflow/moderation/transitions/add",
* "edit-form" = "/admin/config/workflow/moderation/transitions/{moderation_state_transition}",
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
* "delete-form" = "/admin/config/workflow/moderation/transitions/{moderation_state_transition}/delete",
* "collection" = "/admin/config/workflow/moderation/transitions"
* }
* )
*/
class ModerationStateTransition extends ConfigEntityBase implements ModerationStateTransitionInterface {
/**
* The Moderation state transition ID.
*
* @var string
*/
protected $id;
/**
* The Moderation state transition label.
*
* @var string
*/
protected $label;
/**
* ID of from state.
*
* @var string
*/
protected $stateFrom;
/**
* ID of to state.
*
* @var string
*/
protected $stateTo;
/**
* Relative weight of this transition.
*
* @var int
*/
protected $weight;
/**
* {@inheritdoc}
*/
public function calculateDependencies() {
parent::calculateDependencies();
if ($this->stateFrom) {
$this->addDependency('config', ModerationState::load($this->stateFrom)->getConfigDependencyName());
}
if ($this->stateTo) {
$this->addDependency('config', ModerationState::load($this->stateTo)->getConfigDependencyName());
}
return $this;
}
/**
* {@inheritdoc}
*/
public function getFromState() {
return $this->stateFrom;
}
/**
* {@inheritdoc}
*/
public function getToState() {
return $this->stateTo;
}
/**
* {@inheritdoc}
*/
public function getWeight() {
return $this->weight;
}
}