@@ -33,22 +33,69 @@ public function getFunctions()
33
33
new \Twig_SimpleFunction ('workflow_can ' , array ($ this , 'canTransition ' )),
34
34
new \Twig_SimpleFunction ('workflow_transitions ' , array ($ this , 'getEnabledTransitions ' )),
35
35
new \Twig_SimpleFunction ('workflow_has_marked_place ' , array ($ this , 'hasMarkedPlace ' )),
36
+ new \Twig_SimpleFunction ('workflow_places ' , array ($ this , 'getMarkedPlaces ' )),
36
37
);
37
38
}
38
39
39
- public function canTransition ($ object , $ transition , $ name = null )
40
+ /**
41
+ * Returns true if the transition is enabled.
42
+ *
43
+ * @param object $subject A subject
44
+ * @param string $transitionName A transition
45
+ * @param string $name A workflow name
46
+ *
47
+ * @return bool true if the transition is enabled
48
+ */
49
+ public function canTransition ($ subject , $ transition , $ name = null )
40
50
{
41
- return $ this ->workflowRegistry ->get ($ object , $ name )->can ($ object , $ transition );
51
+ return $ this ->workflowRegistry ->get ($ subject , $ name )->can ($ subject , $ transition );
42
52
}
43
53
44
- public function getEnabledTransitions ($ object , $ name = null )
54
+ /**
55
+ * Returns all enabled transitions.
56
+ *
57
+ * @param object $subject A subject
58
+ * @param string $name A workflow name
59
+ *
60
+ * @return Transition[] All enabled transitions
61
+ */
62
+ public function getEnabledTransitions ($ subject , $ name = null )
45
63
{
46
- return $ this ->workflowRegistry ->get ($ object , $ name )->getEnabledTransitions ($ object );
64
+ return $ this ->workflowRegistry ->get ($ subject , $ name )->getEnabledTransitions ($ subject );
47
65
}
48
66
49
- public function hasMarkedPlace ($ object , $ place , $ name = null )
67
+ /**
68
+ * Returns true if the place is marked.
69
+ *
70
+ * @param object $subject A subject
71
+ * @param string $transitionName A transition
72
+ * @param string $name A workflow name
73
+ *
74
+ * @return bool true if the transition is enabled
75
+ */
76
+ public function hasMarkedPlace ($ subject , $ place , $ name = null )
50
77
{
51
- return $ this ->workflowRegistry ->get ($ object , $ name )->getMarking ($ object )->has ($ place );
78
+ return $ this ->workflowRegistry ->get ($ subject , $ name )->getMarking ($ subject )->has ($ place );
79
+ }
80
+
81
+ /**
82
+ * Returns all places.
83
+ *
84
+ * @param object $subject A subject
85
+ * @param string $placesNameOnly If true, returns only places name. If false returns the raw representation
86
+ * @param string $name A workflow name
87
+ *
88
+ * @return string[]|int[]
89
+ */
90
+ public function getMarkedPlaces ($ subject , $ placesNameOnly = true , $ name = null )
91
+ {
92
+ $ places = $ this ->workflowRegistry ->get ($ subject , $ name )->getMarking ($ subject )->getPlaces ();
93
+
94
+ if ($ placesNameOnly ) {
95
+ return array_keys ($ places );
96
+ }
97
+
98
+ return $ places ;
52
99
}
53
100
54
101
public function getName ()
0 commit comments