Shanty_Mongo_Document::loadRequirements PHP 메소드

loadRequirements() 공개 메소드

Load the requirements as validators or filters for a given property, and cache them as validators or filters, respectively.
public loadRequirements ( String $property ) : boolean
$property String Name of property
리턴 boolean whether or not cache was used.
    public function loadRequirements($property)
    {
        if (isset($this->_validators[$property]) || isset($this->_filters[$property])) {
            return true;
        }
        $validators = new Zend_Validate();
        $filters = new Zend_Filter();
        if (!isset($this->_docRequirements[$property])) {
            $this->_filters[$property] = $filters;
            $this->_validators[$property] = $validators;
            return false;
        }
        foreach ($this->_docRequirements[$property] as $requirement => $options) {
            $req = Shanty_Mongo::retrieveRequirement($requirement, $options);
            if ($req instanceof Zend_Validate_Interface) {
                $validators->addValidator($req);
            } else {
                if ($req instanceof Zend_Filter_Interface) {
                    $filters->addFilter($req);
                }
            }
        }
        $this->_filters[$property] = $filters;
        $this->_validators[$property] = $validators;
        return false;
    }