public function loadFromFile($fname, $configPagePath)
{
Prado::trace("Loading page configuration file {$fname}", 'System.Web.Services.TPageService');
if (empty($fname) || !is_file($fname)) {
return;
}
if (Prado::getApplication()->getConfigurationType() == TApplication::CONFIG_TYPE_PHP) {
$fcontent = (include $fname);
$this->loadFromPhp($fcontent, dirname($fname), $configPagePath);
} else {
$dom = new TXmlDocument();
if ($dom->loadFromFile($fname)) {
$this->loadFromXml($dom, dirname($fname), $configPagePath);
} else {
throw new TConfigurationException('pageserviceconf_file_invalid', $fname);
}
}
}
/** * Applies a page configuration. * @param TPageConfiguration the configuration */ protected function applyConfiguration($config) { // initial page properties (to be set when page runs) $this->_properties = array_merge($this->_properties, $config->getProperties()); $this->getApplication()->getAuthorizationRules()->mergeWith($config->getRules()); $pagePath = $this->getRequestedPagePath(); // external configurations foreach ($config->getExternalConfigurations() as $filePath => $params) { list($configPagePath, $condition) = $params; if ($condition !== true) { $condition = $this->evaluateExpression($condition); } if ($condition) { if (($path = Prado::getPathOfNamespace($filePath, Prado::getApplication()->getConfigurationFileExt())) === null || !is_file($path)) { throw new TConfigurationException('pageservice_includefile_invalid', $filePath); } $c = new TPageConfiguration($pagePath); $c->loadFromFile($path, $configPagePath); $this->applyConfiguration($c); } } }