Go to the documentation of this file.00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00018 abstract class RegulatedForm extends PlainForm
00019 {
00020 protected $rules = array();
00021 protected $violated = array();
00022
00027 public function addRule($name, LogicalObject $rule)
00028 {
00029 Assert::isString($name);
00030
00031 $this->rules[$name] = $rule;
00032
00033 return $this;
00034 }
00035
00040 public function dropRuleByName($name)
00041 {
00042 if (isset($this->rules[$name])) {
00043 unset($this->rules[$name]);
00044 return $this;
00045 }
00046
00047 throw new MissingElementException(
00048 "no such rule with '{$name}' name"
00049 );
00050 }
00051
00052 public function ruleExists($name)
00053 {
00054 return isset($this->rules[$name]);
00055 }
00056
00060 public function checkRules()
00061 {
00062 foreach ($this->rules as $name => $logicalObject) {
00063 if (!$logicalObject->toBoolean($this))
00064 $this->violated[$name] = Form::WRONG;
00065 }
00066
00067 return $this;
00068 }
00069 }
00070 ?>