1 | <?php |
||
21 | abstract class FrontEndWorkflowController extends Controller |
||
22 | { |
||
23 | protected $transitionID; |
||
24 | protected $contextObj; |
||
25 | |||
26 | /** |
||
27 | * The title to be displayed on the page |
||
28 | * @var string |
||
29 | */ |
||
30 | public $Title; |
||
31 | |||
32 | |||
33 | /** |
||
34 | * @return string ClassName of object that Workflow is applied to |
||
35 | */ |
||
36 | abstract public function getContextType(); |
||
37 | |||
38 | /** |
||
39 | * @return object Context Object |
||
40 | */ |
||
41 | public function getContextObject() |
||
42 | { |
||
43 | if (!$this->contextObj) { |
||
44 | if ($id = $this->getContextID()) { |
||
45 | $cType = $this->getContextType(); |
||
46 | $cObj = DataObject::get_by_id($cType, $id); |
||
47 | if ($cObj) { |
||
48 | $this->contextObj = $cObj->canView() ? $cObj : null; |
||
49 | } |
||
50 | } |
||
51 | } |
||
52 | return $this->contextObj; |
||
53 | } |
||
54 | |||
55 | /** |
||
56 | * @return int ID of Context Object |
||
57 | */ |
||
58 | protected function getContextID() |
||
59 | { |
||
60 | $id = $this->contextObj ? $this->contextObj->ID : null; |
||
61 | if (!$id) { |
||
|
|||
62 | if ($this->request->param('ID')) { |
||
63 | $id = (int) $this->request->param('ID'); |
||
64 | } elseif ($this->request->requestVar('ID')) { |
||
65 | $id = (int) $this->request->requestVar('ID'); |
||
66 | } |
||
67 | } |
||
68 | return $id; |
||
69 | } |
||
70 | |||
71 | /** |
||
72 | * Specifies the Workflow Definition to be used, |
||
73 | * ie. retrieve from SiteConfig - or wherever it's defined |
||
74 | * |
||
75 | * @return WorkflowDefinition |
||
76 | */ |
||
77 | abstract public function getWorkflowDefinition(); |
||
78 | |||
79 | /** |
||
80 | * Handle the Form Action |
||
81 | * - FrontEndWorkflowForm contains the logic for this |
||
82 | * |
||
83 | * @param SS_HTTPRequest $request |
||
84 | * @todo - is this even required??? |
||
85 | */ |
||
86 | public function handleAction($request, $action) |
||
90 | |||
91 | /** |
||
92 | * Create the Form containing: |
||
93 | * - fields from the Context Object |
||
94 | * - required fields from the Context Object |
||
95 | * - Actions from the connected WorkflowTransitions |
||
96 | * |
||
97 | * @return Form |
||
98 | */ |
||
99 | public function Form() |
||
135 | |||
136 | /** |
||
137 | * @return WorkflowTransition |
||
138 | */ |
||
139 | public function getCurrentTransition() |
||
147 | |||
148 | /** |
||
149 | * Save the Form Data to the defined Context Object |
||
150 | * |
||
151 | * @param array $data |
||
152 | * @param Form $form |
||
153 | * @param SS_HTTPRequest $request |
||
154 | * @throws Exception |
||
155 | */ |
||
156 | public function doFrontEndAction(array $data, Form $form, HTTPRequest $request) |
||
197 | |||
198 | /** |
||
199 | * checks to see if there is a title set on the current workflow action |
||
200 | * uses that or falls back to controller->Title |
||
201 | */ |
||
202 | public function Title() |
||
215 | } |
||
216 |
In PHP, under loose comparison (like
==
, or!=
, orswitch
conditions), values of different types might be equal.For
integer
values, zero is a special case, in particular the following results might be unexpected: