protected function importZendNamespace() { if (is_null(Prado::getPathOfAlias('Zend'))) { $zendBase = !is_null($this->_ZF) ? $this->_ZF . '.*' : 'Application.index.*'; $path = !is_null($this->_ZF) ? $this->_ZF . '.Zend.*' : 'Application.index.Zend.*'; Prado::using($zendBase); Prado::setPathOfAlias('Zend', Prado::getPathOfNamespace($path)); } }
public function testSetTransformPathAsNamespace() { if (Prado::getPathOfAlias('UnitTest') === null) { Prado::setPathOfAlias('UnitTest', dirname(__FILE__) . '/data'); } $expected = $this->transformPath; $transform = new TXmlTransform(); $transform->setTransformPath('UnitTest.hello'); $this->assertEquals($expected, $transform->getTransformPath()); }
function __construct($root, $app_dir = '.') { $this->_root = $root; Prado::setPathOfAlias('Tests', $root); if ($app_dir === null) { $app_dir = '.'; } $app = new TShellApplication($app_dir); $app->run(); }
public function applyConfiguration($config, $withinService = false) { if ($config->getIsEmpty()) { return; } foreach ($config->getAliases() as $alias => $path) { Prado::setPathOfAlias($alias, $path); } foreach ($config->getUsings() as $using) { Prado::using($using); } if (!$withinService) { foreach ($config->getProperties() as $name => $value) { $this->setSubProperty($name, $value); } } if (empty($this->_services)) { $this->_services = array($this->getPageServiceID() => array('TPageService', array(), null)); } foreach ($config->getParameters() as $id => $parameter) { if (is_array($parameter)) { $component = Prado::createComponent($parameter[0]); foreach ($parameter[1] as $name => $value) { $component->setSubProperty($name, $value); } $this->_parameters->add($id, $component); } else { $this->_parameters->add($id, $parameter); } } $modules = array(); foreach ($config->getModules() as $id => $moduleConfig) { if (!is_string($id)) { $id = '_module' . count($this->_lazyModules); } $this->_lazyModules[$id] = $moduleConfig; if ($module = $this->internalLoadModule($id)) { $modules[] = $module; } } foreach ($modules as $module) { $module[0]->init($module[1]); } foreach ($config->getServices() as $serviceID => $serviceConfig) { $this->_services[$serviceID] = $serviceConfig; } foreach ($config->getExternalConfigurations() as $filePath => $condition) { if ($condition !== true) { $condition = $this->evaluateExpression($condition); } if ($condition) { if (($path = Prado::getPathOfNamespace($filePath, $this->getConfigurationFileExt())) === null || !is_file($path)) { throw new TConfigurationException('application_includefile_invalid', $filePath); } $cn = $this->getApplicationConfigurationClass(); $c = new $cn(); $c->loadFromFile($path); $this->applyConfiguration($c, $withinService); } } }
/** * Applies an application configuration. * @param TApplicationConfiguration the configuration * @param boolean whether the configuration is specified within a service. */ public function applyConfiguration($config, $withinService = false) { if ($config->getIsEmpty()) { return; } // set path aliases and using namespaces foreach ($config->getAliases() as $alias => $path) { Prado::setPathOfAlias($alias, $path); } foreach ($config->getUsings() as $using) { Prado::using($using); } // set application properties if (!$withinService) { foreach ($config->getProperties() as $name => $value) { $this->setSubProperty($name, $value); } } if (empty($this->_services)) { $this->_services = array($this->getPageServiceID() => array('TPageService', array(), null)); } // load parameters foreach ($config->getParameters() as $id => $parameter) { if (is_array($parameter)) { $component = Prado::createComponent($parameter[0]); foreach ($parameter[1] as $name => $value) { $component->setSubProperty($name, $value); } $this->_parameters->add($id, $component); } else { $this->_parameters->add($id, $parameter); } } // load and init modules specified in app config $modules = array(); foreach ($config->getModules() as $id => $moduleConfig) { Prado::trace("Loading module {$id} ({$moduleConfig[0]})", 'System.TApplication'); list($moduleClass, $initProperties, $configElement) = $moduleConfig; $module = Prado::createComponent($moduleClass); if (!is_string($id)) { $id = '_module' . count($this->_modules); $initProperties['id'] = $id; } $this->setModule($id, $module); foreach ($initProperties as $name => $value) { $module->setSubProperty($name, $value); } $modules[] = array($module, $configElement); } foreach ($modules as $module) { $module[0]->init($module[1]); } // load service foreach ($config->getServices() as $serviceID => $serviceConfig) { $this->_services[$serviceID] = $serviceConfig; } // external configurations foreach ($config->getExternalConfigurations() as $filePath => $condition) { if ($condition !== true) { $condition = $this->evaluateExpression($condition); } if ($condition) { if (($path = Prado::getPathOfNamespace($filePath, self::CONFIG_FILE_EXT)) === null || !is_file($path)) { throw new TConfigurationException('application_includefile_invalid', $filePath); } $c = new TApplicationConfiguration(); $c->loadFromFile($path); $this->applyConfiguration($c, $withinService); } } }