public function hasRequirement($property, $requirement)
{
if (!array_key_exists($property, $this->_docRequirements)) {
return false;
}
switch ($requirement) {
case 'Document':
case 'DocumentSet':
foreach ($this->_docRequirements[$property] as $requirementSearch => $params) {
$standardClass = 'Shanty_Mongo_' . $requirement;
// Return basic document or document set class if requirement matches
if ($requirementSearch == $requirement) {
return $standardClass;
}
// Find the document class
$matches = array();
preg_match("/^{$requirement}:([A-Za-z][\\w\\-]*)\$/", $requirementSearch, $matches);
if (!empty($matches)) {
if (!class_exists($matches[1])) {
require_once 'Shanty/Mongo/Exception.php';
throw new Shanty_Mongo_Exception("{$requirement} class of '{$matches[1]}' does not exist");
}
if (!is_subclass_of($matches[1], $standardClass)) {
require_once 'Shanty/Mongo/Exception.php';
throw new Shanty_Mongo_Exception("{$requirement} of '{$matches[1]}' sub is not a class of {$standardClass} does not exist");
}
return $matches[1];
}
}
return false;
}
return array_key_exists($requirement, $this->_docRequirements[$property]);
}