Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added PreValidation and PostAction

  • Loading branch information...
commit 5f63b35dba7d596f0317e9cb5c413585b8c7a6ac 1 parent 84de024
@jeremyFreeAgent authored
Showing with 32 additions and 3 deletions.
  1. +26 −3 Manager/Manager.php
  2. +6 −0 README.md
View
29 Manager/Manager.php
@@ -152,11 +152,10 @@ public function reachStep($stepName, $stepComment = '', $stepAt = null)
$this->getModel()->setWorkflowStepAt(is_null($stepAt) ? time() : $stepAt);
$this->runStepActions($stepName);
+ $this->runActions();
$this->canReachStep = array();
- // TODO : Run global actions;
-
return true;
}
@@ -223,7 +222,7 @@ public function preValidation($stepName)
}
}
- return $preValidationSuccess;
+ return $preValidationResult;
}
public function getValidationErrors($stepName)
@@ -241,11 +240,21 @@ public function getValidations()
return $this->validations;
}
+ public function hasValidations()
+ {
+ return (!empty($this->validations));
+ }
+
public function getAction($action)
{
return $this->container->get($action);
}
+ public function getActions()
+ {
+ return $this->actions;
+ }
+
/**
* [runStepActions description]
* @return [type] [description]
@@ -265,4 +274,18 @@ public function runStepActions()
return true;
}
+
+ public function runActions()
+ {
+ foreach ($this->getActions() as $action) {
+ $action = $this->getAction($action);
+
+ if (false == $action->run($this->getModel())) {
+
+ return false;
+ }
+ }
+
+ return true;
+ }
}
View
6 README.md
@@ -118,3 +118,9 @@ if ($manager->canReachStep('draft')) {
$errors = $manager->getValidationErrors('draft');
}
```
+
+TODOs
+-----
+
+* Better code for Step
+* Better tests
Please sign in to comment.
Something went wrong with that request. Please try again.