diff -r 5b37998e522e -r 162c1de6545a web/lib/Zend/Tool/Project/Profile/Resource/SearchConstraints.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/lib/Zend/Tool/Project/Profile/Resource/SearchConstraints.php Fri Mar 11 15:05:35 2011 +0100 @@ -0,0 +1,117 @@ +addConstraint($options); + } elseif (is_array($options)) { + $this->setOptions($options); + } + } + + /** + * setOptions() + * + * @param array $option + * @return Zend_Tool_Project_Profile_Resource_SearchConstraints + */ + public function setOptions(Array $option) + { + foreach ($option as $optionName => $optionValue) { + if (is_int($optionName)) { + $this->addConstraint($optionValue); + } elseif (is_string($optionName)) { + $this->addConstraint(array('name' => $optionName, 'params' => $optionValue)); + } + } + + return $this; + } + + /** + * addConstraint() + * + * @param string|array $constraint + * @return Zend_Tool_Project_Profile_Resource_SearchConstraints + */ + public function addConstraint($constraint) + { + if (is_string($constraint)) { + $name = $constraint; + $params = array(); + } elseif (is_array($constraint)) { + $name = $constraint['name']; + $params = $constraint['params']; + } + + $constraint = $this->_makeConstraint($name, $params); + + array_push($this->_constraints, $constraint); + return $this; + } + + /** + * getConstraint() + * + * @return ArrayObject + */ + public function getConstraint() + { + return array_shift($this->_constraints); + } + + /** + * _makeConstraint + * + * @param string $name + * @param mixed $params + * @return ArrayObject + */ + protected function _makeConstraint($name, $params) + { + $value = array('name' => $name, 'params' => $params); + return new ArrayObject($value, ArrayObject::ARRAY_AS_PROPS); + } + +} \ No newline at end of file