public final function __set($p_element, $p_value)
{
$p_element = CampContext::TranslateProperty($p_element);
// Verify if an object of this type exists
if (!is_null(CampContext::ObjectType($p_element))) {
try {
if (!is_object($p_value)) {
throw new InvalidObjectException($p_element);
}
$classFullPath = $GLOBALS['g_campsiteDir'] . '/template_engine/metaclasses/' . CampContext::ObjectType($p_element) . '.php';
if (file_exists($classFullPath)) {
require_once $classFullPath;
} elseif (class_exists(CampContext::$m_objectTypes[$p_element]['class'])) {
$className = CampContext::ObjectType($p_element);
} else {
$pluginImplementsClassFullPath = false;
foreach (CampPlugin::GetEnabled() as $CampPlugin) {
$pluginClassFullPath = $GLOBALS['g_campsiteDir'] . '/' . $CampPlugin->getBasePath() . '/template_engine/metaclasses/' . CampContext::ObjectType($p_element) . '.php';
if (file_exists($pluginClassFullPath)) {
$pluginImplementsClassFullPath = $pluginClassFullPath;
}
}
if ($pluginImplementsClassFullPath) {
require_once $pluginImplementsClassFullPath;
} else {
throw new InvalidObjectException($p_element);
}
}
$metaclass = CampContext::ObjectType($p_element);
if (!is_a($p_value, $metaclass)) {
throw new InvalidObjectException($p_element);
}
if (isset($this->m_objects[$p_element]) && !is_null($this->m_objects[$p_element])) {
$oldValue = $this->m_objects[$p_element];
} else {
$oldValue = new $metaclass();
}
if (isset(CampContext::$m_objectTypes[$p_element]['handler'])) {
$setHandler = CampContext::$m_objectTypes[$p_element]['handler'];
$this->{$setHandler}($oldValue, $p_value);
} else {
$this->m_objects[$p_element] = $p_value;
}
return isset($this->m_objects[$p_element]) ? $this->m_objects[$p_element] : null;
} catch (InvalidObjectException $e) {
$this->trigger_invalid_object_error($e->getClassName());
return null;
}
}
// Verify if a property with this name exists
if (is_array($this->m_properties) && array_key_exists($p_element, $this->m_properties)) {
return $this->m_properties[$p_element] = $p_value;
}
// No object of this type of property with this name exist.
$this->trigger_invalid_property_error($p_element);
return null;
}