From: Chuck Hagenbuch Date: Mon, 28 Sep 2009 18:26:43 +0000 (-0400) Subject: Use addConstraint() in the compound constraint constructor X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=71d21ff66091523028de50ef6e33838cc170c2be;p=horde.git Use addConstraint() in the compound constraint constructor Collapse compound constraints of the same type --- diff --git a/framework/Constraint/lib/Horde/Constraint/Compound.php b/framework/Constraint/lib/Horde/Constraint/Compound.php index 48d80274c..ededf9e34 100644 --- a/framework/Constraint/lib/Horde/Constraint/Compound.php +++ b/framework/Constraint/lib/Horde/Constraint/Compound.php @@ -15,15 +15,27 @@ abstract class Horde_Constraint_Compound implements Horde_Constraint if (! $c instanceof Horde_Constraint) { throw new IllegalArgumentException("$c does not implement Horde_Constraint"); } + $this->addConstraint($c); } - $this->_constraints = $constraints; } public function addConstraint(Horde_Constraint $constraint) { - $this->_constraints[] = $constraint; + $kind = get_class($this); + if ($constrainst instanceof $kind) { + foreach ($constrainst->getConstraints() as $c) { + $this->addConstraint($c); + } + } else { + $this->_constraints[] = $constraint; + } return $this; } + public function getConstraints() + { + return $this->_constraints; + } + abstract public function evaluate($value); }