class WorkflowTransitionEvent in State Machine 8
Defines the workflow transition event.
Hierarchy
- class \Drupal\state_machine\Event\WorkflowTransitionEvent extends \Symfony\Component\EventDispatcher\Event
Expanded class hierarchy of WorkflowTransitionEvent
2 files declare their use of WorkflowTransitionEvent
- StateItem.php in src/
Plugin/ Field/ FieldType/ StateItem.php - WorkflowTransitionEventSubscriber.php in tests/
modules/ state_machine_test/ src/ EventSubscriber/ WorkflowTransitionEventSubscriber.php
File
- src/
Event/ WorkflowTransitionEvent.php, line 13
Namespace
Drupal\state_machine\EventView source
class WorkflowTransitionEvent extends Event {
/**
* The transition.
*
* @var \Drupal\state_machine\Plugin\Workflow\WorkflowTransition
*/
protected $transition;
/**
* The workflow.
*
* @var \Drupal\state_machine\Plugin\Workflow\WorkflowInterface
*/
protected $workflow;
/**
* The entity.
*
* @var \Drupal\Core\Entity\ContentEntityInterface
*/
protected $entity;
/**
* The state field name.
*
* @var string
*/
protected $fieldName;
/**
* Constructs a new WorkflowTransitionEvent object.
*
* @param \Drupal\state_machine\Plugin\Workflow\WorkflowTransition $transition
* The transition.
* @param \Drupal\state_machine\Plugin\Workflow\WorkflowInterface $workflow
* The workflow.
* @param \Drupal\Core\Entity\ContentEntityInterface $entity
* The entity.
* @param string $field_name
* The state field name.
*/
public function __construct(WorkflowTransition $transition, WorkflowInterface $workflow, ContentEntityInterface $entity, $field_name) {
$this->transition = $transition;
$this->workflow = $workflow;
$this->entity = $entity;
$this->fieldName = $field_name;
}
/**
* Gets the transition.
*
* @return \Drupal\state_machine\Plugin\Workflow\WorkflowTransition
* The transition.
*/
public function getTransition() {
return $this->transition;
}
/**
* Gets the workflow.
*
* @return \Drupal\state_machine\Plugin\Workflow\WorkflowInterface
* The workflow.
*/
public function getWorkflow() {
return $this->workflow;
}
/**
* Gets the entity.
*
* @return \Drupal\Core\Entity\ContentEntityInterface
* The entity.
*/
public function getEntity() {
return $this->entity;
}
/**
* Gets the state field name.
*
* @return string
* The state field name.
*/
public function getFieldName() {
return $this->fieldName;
}
/**
* Gets the state field.
*
* @return \Drupal\state_machine\Plugin\Field\FieldType\StateItemInterface
* The state field.
*/
public function getField() {
/** @var \Drupal\state_machine\Plugin\Field\FieldType\StateItemInterface $field */
$field = $this->entity
->get($this->fieldName)
->first();
return $field;
}
/**
* Gets the "from" state.
*
* @deprecated in state_machine:8.x-1.0-rc1 and is removed from state_machine:8.x-2.0.
* Use $this->getField()->getOriginalId() instead.
* @see https://www.drupal.org/node/2982709
*
* @return \Drupal\state_machine\Plugin\Workflow\WorkflowState
* The "from" state.
*/
public function getFromState() {
$original_id = $this
->getField()
->getOriginalId();
return $this->workflow
->getState($original_id);
}
/**
* Gets the "to" state.
*
* @deprecated in state_machine:8.x-1.0-rc1 and is removed from state_machine:8.x-2.0.
* Use $this->getTransition->getToState() instead.
* @see https://www.drupal.org/node/2982709
*
* @return \Drupal\state_machine\Plugin\Workflow\WorkflowState
* The "to" state.
*/
public function getToState() {
return $this->transition
->getToState();
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
WorkflowTransitionEvent:: |
protected | property | The entity. | |
WorkflowTransitionEvent:: |
protected | property | The state field name. | |
WorkflowTransitionEvent:: |
protected | property | The transition. | |
WorkflowTransitionEvent:: |
protected | property | The workflow. | |
WorkflowTransitionEvent:: |
public | function | Gets the entity. | |
WorkflowTransitionEvent:: |
public | function | Gets the state field. | |
WorkflowTransitionEvent:: |
public | function | Gets the state field name. | |
WorkflowTransitionEvent:: |
public | function | Gets the "from" state. | |
WorkflowTransitionEvent:: |
public | function | Gets the "to" state. | |
WorkflowTransitionEvent:: |
public | function | Gets the transition. | |
WorkflowTransitionEvent:: |
public | function | Gets the workflow. | |
WorkflowTransitionEvent:: |
public | function | Constructs a new WorkflowTransitionEvent object. |