Unverified Commit 4a80851b authored by larowlan's avatar larowlan

Issue #2896724 by Eric115, kim.pepper, Sam152, Wim Leers: Create constants for...

Issue #2896724 by Eric115, kim.pepper, Sam152, Wim Leers: Create constants for transition directions.
parent aaefc3f3
......@@ -7,6 +7,7 @@
use Drupal\workflows\State;
use Drupal\workflows\StateInterface;
use Drupal\workflows\Transition;
use Drupal\workflows\TransitionInterface;
use Drupal\workflows\WorkflowInterface;
use Drupal\workflows\WorkflowTypeInterface;
......@@ -328,7 +329,7 @@ public function hasTransition($transition_id) {
/**
* {@inheritdoc}
*/
public function getTransitionsForState($state_id, $direction = 'from') {
public function getTransitionsForState($state_id, $direction = TransitionInterface::DIRECTION_FROM) {
$transition_ids = array_keys(array_filter($this->configuration['transitions'], function ($transition) use ($state_id, $direction) {
return in_array($state_id, (array) $transition[$direction], TRUE);
}));
......
......@@ -18,6 +18,16 @@
*/
const PLUGIN_FORM_KEY = 'transition';
/**
* The transition direction from.
*/
const DIRECTION_FROM = 'from';
/**
* The transition direction to.
*/
const DIRECTION_TO = 'to';
/**
* Gets the transition's ID.
*
......
......@@ -248,13 +248,17 @@ public function getTransitions(array $transition_ids = NULL);
* @param $state_id
* The state to get transitions for.
* @param string $direction
* (optional) The direction of the transition. Defaults to 'from'. Possible
* values are: 'from' and 'to'.
* (optional) The direction of the transition, defaults to
* TransitionInterface::DIRECTION_FROM. Possible values are:
* TransitionInterface::DIRECTION_FROM or TransitionInterface::DIRECTION_TO.
*
* @return array
* The transition IDs for a state for the provided direction.
*
* @see \Drupal\workflows\TransitionInterface::DIRECTION_FROM
* @see \Drupal\workflows\TransitionInterface::DIRECTION_TO
*/
public function getTransitionsForState($state_id, $direction = 'from');
public function getTransitionsForState($state_id, $direction = TransitionInterface::DIRECTION_FROM);
/**
* Gets a transition from state to state.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment