Skip to content
Browse files

Added preValidation

  • Loading branch information...
1 parent e78bbf2 commit 84de024ad9c098e80191c9938faba33d8e314fdd @jeremyFreeAgent committed Jun 14, 2012
Showing with 28 additions and 18 deletions.
  1. +28 −18 Manager/Manager.php
View
46 Manager/Manager.php
@@ -181,24 +181,10 @@ public function canReachStep($stepName)
if ($currentStep->hasPossibleNextStep($stepToReach->getName())) {
- // TODO : check this !
- // $preValidationSuccess = true;
- // if ($this->hasValidations()) {
- // foreach ($this->getValidations() as $validation) {
- // $validation = $this->getValidation($validation);
-
- // try {
- // $validation->validate($this->getModel());
- // } catch (ValidationException $e) {
- // $this->validationErrors[$stepToReach->getName()][] = $e->getMessage();
- // $preValidationSuccess = false;
- // }
- // }
- // }
-
- // if ($preValidationSuccess) {
- if (!$stepToReach->hasValidations()) {
+ $preValidationResult = $this->preValidation($stepToReach->getName());
+ if ($preValidationResult) {
+ if (!$stepToReach->hasValidations()) {
$this->canReachStep[$stepToReach->getName()] = true;
} else {
foreach ($stepToReach->getValidations() as $validation) {
@@ -213,14 +199,33 @@ public function canReachStep($stepName)
}
}
}
- // }
+ }
}
}
}
return $this->canReachStep[$stepName];
}
+ public function preValidation($stepName)
+ {
+ $preValidationResult = true;
+ if ($this->hasValidations()) {
+ foreach ($this->getValidations() as $validation) {
+ $validation = $this->getValidation($validation);
+
+ try {
+ $validation->validate($this->getModel());
+ } catch (ValidationException $e) {
+ $this->validationErrors[$stepName][] = $e->getMessage();
+ $preValidationResult = false;
+ }
+ }
+ }
+
+ return $preValidationSuccess;
+ }
+
public function getValidationErrors($stepName)
{
return (array_key_exists($stepName, $this->validationErrors)) ? $this->validationErrors[$stepName] : array();
@@ -231,6 +236,11 @@ public function getValidation($validation)
return $this->container->get($validation);
}
+ public function getValidations()
+ {
+ return $this->validations;
+ }
+
public function getAction($action)
{
return $this->container->get($action);

0 comments on commit 84de024

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