protected static ObjectType ( string $p_property ) | ||
$p_property | string |
protected static function ObjectType($p_property)
{
// Verify if an object of this type exists
if (array_key_exists($p_property, CampContext::$m_objectTypes)) {
if (strpos(CampContext::$m_objectTypes[$p_property]['class'], '\\') !== false && class_exists(CampContext::$m_objectTypes[$p_property]['class'])) {
return CampContext::$m_objectTypes[$p_property]['class'];
}
return 'Meta' . CampContext::$m_objectTypes[$p_property]['class'];
}
return null;
}
/** * Creates an object of the given type. Returns the created object. * * @param string $p_objectType * @return object */ private function createObject($p_objectType) { $p_objectType = CampContext::TranslateProperty($p_objectType); $classFullPath = $GLOBALS['g_campsiteDir'] . '/template_engine/metaclasses/' . CampContext::ObjectType($p_objectType) . '.php'; if (file_exists($classFullPath)) { require_once $classFullPath; } elseif (class_exists(CampContext::$m_objectTypes[$p_objectType]['class'])) { $className = CampContext::ObjectType($p_objectType); } else { $pluginImplementsClassFullPath = false; foreach (CampPlugin::GetEnabled() as $CampPlugin) { $pluginClassFullPath = $GLOBALS['g_campsiteDir'] . '/' . $CampPlugin->getBasePath() . '/template_engine/metaclasses/' . CampContext::ObjectType($p_objectType) . '.php'; if (file_exists($pluginClassFullPath)) { $pluginImplementsClassFullPath = $pluginClassFullPath; } } if ($pluginImplementsClassFullPath) { require_once $pluginImplementsClassFullPath; } else { throw new InvalidObjectException($p_objectType); } } $className = CampContext::ObjectType($p_objectType); $this->m_objects[$p_objectType] = new $className(); return $this->m_objects[$p_objectType]; }