Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Added PreValidation and PostAction

  • Loading branch information...
commit 5f63b35dba7d596f0317e9cb5c413585b8c7a6ac 1 parent 84de024
Jérémy Romey authored

Showing 2 changed files with 32 additions and 3 deletions. Show diff stats Hide diff stats

  1. +26 3 Manager/Manager.php
  2. +6 0 README.md
29 Manager/Manager.php
@@ -152,11 +152,10 @@ public function reachStep($stepName, $stepComment = '', $stepAt = null)
152 152 $this->getModel()->setWorkflowStepAt(is_null($stepAt) ? time() : $stepAt);
153 153
154 154 $this->runStepActions($stepName);
  155 + $this->runActions();
155 156
156 157 $this->canReachStep = array();
157 158
158   - // TODO : Run global actions;
159   -
160 159 return true;
161 160 }
162 161
@@ -223,7 +222,7 @@ public function preValidation($stepName)
223 222 }
224 223 }
225 224
226   - return $preValidationSuccess;
  225 + return $preValidationResult;
227 226 }
228 227
229 228 public function getValidationErrors($stepName)
@@ -241,11 +240,21 @@ public function getValidations()
241 240 return $this->validations;
242 241 }
243 242
  243 + public function hasValidations()
  244 + {
  245 + return (!empty($this->validations));
  246 + }
  247 +
244 248 public function getAction($action)
245 249 {
246 250 return $this->container->get($action);
247 251 }
248 252
  253 + public function getActions()
  254 + {
  255 + return $this->actions;
  256 + }
  257 +
249 258 /**
250 259 * [runStepActions description]
251 260 * @return [type] [description]
@@ -265,4 +274,18 @@ public function runStepActions()
265 274
266 275 return true;
267 276 }
  277 +
  278 + public function runActions()
  279 + {
  280 + foreach ($this->getActions() as $action) {
  281 + $action = $this->getAction($action);
  282 +
  283 + if (false == $action->run($this->getModel())) {
  284 +
  285 + return false;
  286 + }
  287 + }
  288 +
  289 + return true;
  290 + }
268 291 }
6 README.md
Source Rendered
@@ -118,3 +118,9 @@ if ($manager->canReachStep('draft')) {
118 118 $errors = $manager->getValidationErrors('draft');
119 119 }
120 120 ```
  121 +
  122 +TODOs
  123 +-----
  124 +
  125 +* Better code for Step
  126 +* Better tests

0 comments on commit 5f63b35

Please sign in to comment.
Something went wrong with that request. Please try again.