summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLee Rowlands2017-10-12 05:42:43 (GMT)
committerLee Rowlands2017-10-12 05:42:43 (GMT)
commit4a80851b41188f86de0ae59de85ecdb15058f666 (patch)
tree933b61f1370554e2e4abe16334d436ee67fb1a77
parentaaefc3f3c1dad5e76a3a5493fc65667f601659d5 (diff)
Issue #2896724 by Eric115, kim.pepper, Sam152, Wim Leers: Create constants for transition directions.
-rw-r--r--core/modules/workflows/src/Plugin/WorkflowTypeBase.php3
-rw-r--r--core/modules/workflows/src/TransitionInterface.php10
-rw-r--r--core/modules/workflows/src/WorkflowTypeInterface.php10
3 files changed, 19 insertions, 4 deletions
diff --git a/core/modules/workflows/src/Plugin/WorkflowTypeBase.php b/core/modules/workflows/src/Plugin/WorkflowTypeBase.php
index a898253..32ade73 100644
--- a/core/modules/workflows/src/Plugin/WorkflowTypeBase.php
+++ b/core/modules/workflows/src/Plugin/WorkflowTypeBase.php
@@ -7,6 +7,7 @@ use Drupal\Core\Plugin\PluginWithFormsTrait;
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 @@ abstract class WorkflowTypeBase extends PluginBase implements WorkflowTypeInterf
/**
* {@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);
}));
diff --git a/core/modules/workflows/src/TransitionInterface.php b/core/modules/workflows/src/TransitionInterface.php
index ae3f023..83e6bda 100644
--- a/core/modules/workflows/src/TransitionInterface.php
+++ b/core/modules/workflows/src/TransitionInterface.php
@@ -19,6 +19,16 @@ interface TransitionInterface {
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.
*
* @return string
diff --git a/core/modules/workflows/src/WorkflowTypeInterface.php b/core/modules/workflows/src/WorkflowTypeInterface.php
index 5ef843b..7509e7c 100644
--- a/core/modules/workflows/src/WorkflowTypeInterface.php
+++ b/core/modules/workflows/src/WorkflowTypeInterface.php
@@ -248,13 +248,17 @@ interface WorkflowTypeInterface extends PluginWithFormsInterface, DerivativeInsp
* @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.