/** * Tries to figure out the classname for a relationship. * * @param string $key Name of the requested attribute * @param array $array Array to search. * * @return string Name of the class. */ protected static function _getClassNameForRelationship($key, $array) { if (!is_array($array) || !is_array($array[$key])) { throw new Phprojekt_ActiveRecord_Exception("The second parameter must be an array"); } $definition = $array[$key]; if (array_key_exists('classname', $definition)) { $className = $array[$key]['classname']; } elseif (array_key_exists('model', $definition) && array_key_exists('module', $definition)) { $className = Phprojekt_Loader::getModelClassName($definition['module'], $definition['model']); } else { $className = $key; } if (!class_exists($className, true)) { throw new Phprojekt_ActiveRecord_Exception("Cannot instantiate {$className}"); } return $className; }