• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP AgaviToolkit类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中AgaviToolkit的典型用法代码示例。如果您正苦于以下问题:PHP AgaviToolkit类的具体用法?PHP AgaviToolkit怎么用?PHP AgaviToolkit使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了AgaviToolkit类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: main

 /**
  * Executes this task.
  */
 public function main()
 {
     if ($this->path === null) {
         throw new BuildException('The path attribute must be specified');
     }
     $check = new AgaviModuleFilesystemCheck();
     $check->setConfigDirectory($this->project->getProperty('module.config.directory'));
     $check->setPath($this->path->getAbsolutePath());
     if (!$check->check()) {
         throw new BuildException('The path attribute must be a valid module base directory');
     }
     /* We don't know whether the module is configured or not here, so load the
      * values we want properly. */
     $this->tryLoadAgavi();
     $this->tryBootstrapAgavi();
     require_once AgaviConfigCache::checkConfig(sprintf('%s/%s/module.xml', $this->path->getAbsolutePath(), (string) $this->project->getProperty('module.config.directory')));
     $actionPath = AgaviToolkit::expandVariables(AgaviToolkit::expandDirectives(AgaviConfig::get(sprintf('modules.%s.agavi.action.path', strtolower($this->path->getName())), '%core.module_dir%/${moduleName}/actions/${actionName}Action.class.php')), array('moduleName' => $this->path->getName()));
     $pattern = '#^' . AgaviToolkit::expandVariables(str_replace('\\$\\{actionName\\}', '${actionName}', preg_quote($actionPath, '#')), array('actionName' => '(?P<action_name>.*?)')) . '$#';
     $iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($this->path->getAbsolutePath()));
     for (; $iterator->valid(); $iterator->next()) {
         $rdi = $iterator->getInnerIterator();
         if ($rdi->isDot() || !$rdi->isFile()) {
             continue;
         }
         $file = $rdi->getPathname();
         if (preg_match($pattern, $file, $matches)) {
             $this->log(str_replace(DIRECTORY_SEPARATOR, '.', $matches['action_name']));
         }
     }
 }
开发者ID:horros,项目名称:agavi,代码行数:33,代码来源:AgaviDisplayactionsTask.php


示例2: initialize

 public function initialize(AgaviContext $ctx, array $parameters = array())
 {
     parent::initialize($ctx, $parameters);
     $this->dqlViews = (include AgaviConfigCache::checkConfig(AgaviToolkit::expandDirectives('%core.module_dir%/Api/config/views.xml')));
     $this->view = $parameters["view"];
     $this->viewParameters = isset($parameters["parameters"]) ? $parameters["parameters"] : array();
     $this->validateTarget();
     $connection = $this->defaultConnection;
     if (isset($parameters["connection"])) {
         $connection = $parameters["connection"];
     }
     if ($this->view["connection"]) {
         $connection = $this->view["connection"];
     }
     AppKitLogger::verbose("Switching to connection %s", $connection);
     $db = $this->getContext()->getDatabaseManager()->getDatabase($connection);
     $this->useRetained = $db->useRetained();
     $this->connection = $ctx->getDatabaseConnection($connection);
     if ($this->connection != "icinga") {
         $ctx->getModel("DBALMetaManager", "Api")->switchIcingaDatabase($connection);
     }
     $this->user = $this->getContext()->getUser()->getNsmUser();
     $this->parseBaseDQL();
     $this->parseCustomVariables();
     $this->parseDQLExtensions();
     $this->parseDependencies();
 }
开发者ID:philippjenni,项目名称:icinga-web,代码行数:27,代码来源:ApiDQLViewModel.class.php


示例3: execute

 public function execute(AgaviXmlConfigDomDocument $document)
 {
     $data = array();
     $prefix = "org.icinga.";
     $document->setDefaultNamespace(self::XML_NAMESPACE, 'settings');
     foreach ($document->getConfigurationElements() as $cfg) {
         foreach ($cfg->get('settings') as $setting) {
             $localPrefix = $prefix;
             // let's see if this buddy has a <settings> parent with valuable information
             if ($setting->parentNode->localName == 'settings') {
                 if ($setting->parentNode->hasAttribute('prefix')) {
                     $localPrefix = $setting->parentNode->getAttribute('prefix');
                 }
             }
             $settingName = $localPrefix . $setting->getAttribute('name');
             if ($setting->hasAgaviParameters()) {
                 $data[$settingName] = $setting->getAgaviParameters();
             } else {
                 $data[$settingName] = AgaviToolkit::literalize($setting->getValue());
             }
         }
     }
     $code = 'AgaviConfig::fromArray(' . var_export($data, true) . ');';
     return $this->generate($code, $document->documentURI);
 }
开发者ID:philippjenni,项目名称:icinga-web,代码行数:25,代码来源:AppKitSubSettingConfigHandler.class.php


示例4: importModuleXML

 private function importModuleXML($accessLocation)
 {
     $config = (include AgaviConfigCache::checkConfig(AgaviToolkit::expandDirectives($accessLocation)));
     $this->instances = array_merge_recursive($this->instances, $config["instances"]);
     $this->defaults = array_merge_recursive($this->defaults, $config["defaults"]);
     $this->hosts = array_merge_recursive($this->hosts, $config["hosts"]);
 }
开发者ID:philippjenni,项目名称:icinga-web,代码行数:7,代码来源:AccessConfigHandler.class.php


示例5: parseRoutesAndFiles

 protected function parseRoutesAndFiles(AgaviRouting $routing, $routes, &$data)
 {
     $controller = $this->context->getController();
     $request = $this->context->getRequest();
     foreach ($routes as $route) {
         $outputTypes = array();
         $routeName = $route->getAttribute('name');
         if ($routeName !== '*' && is_null($routing->getRoute($routeName))) {
             throw new AgaviConfigurationException('Route name "' . $routeName . '" does not exist or is not correct.');
         }
         if ($route->hasAttribute('output_type')) {
             foreach (explode(' ', $route->getAttribute('output_type')) as $ot) {
                 if ($controller->getOutputType($ot)) {
                     $outputTypes[] = $ot;
                 }
             }
         } else {
             $outputTypes[] = $controller->getOutputType()->getName();
             // Defaults to HTML
         }
         foreach ($route->get('filelist') as $filelist) {
             $metatype = $filelist->getAttribute('metatype');
             foreach ($filelist->getElementsByTagName('file') as $file) {
                 foreach ($outputTypes as $ot) {
                     if ($file->hasAttribute('name')) {
                         $data[$routeName][$ot][$metatype][$file->getAttribute('name')] = AgaviToolkit::expandDirectives($file->getValue());
                     } else {
                         $data[$routeName][$ot][$metatype][] = AgaviToolkit::expandDirectives($file->getValue());
                     }
                 }
             }
         }
     }
 }
开发者ID:Rendez,项目名称:agavi-snippets,代码行数:34,代码来源:StaticFilesConfigHandler.class.php


示例6: execute

 /**
  * Execute this configuration handler.
  *
  * @param      AgaviXmlConfigDomDocument The document to parse.
  *
  * @return     string Data to be written to a cache file.
  *
  * @throws     <b>AgaviParseException</b> If a requested configuration file is
  *                                        improperly formatted.
  *
  * @author     Sean Kerr <[email protected]>
  * @author     Dominik del Bondio <[email protected]>
  * @author     David Zülke <[email protected]>
  * @since      0.9.0
  */
 public function execute(AgaviXmlConfigDomDocument $document)
 {
     // set up our default namespace
     $document->setDefaultNamespace(self::XML_NAMESPACE, 'compile');
     $config = $document->documentURI;
     $data = array();
     // let's do our fancy work
     foreach ($document->getConfigurationElements() as $configuration) {
         if (!$configuration->has('compiles')) {
             continue;
         }
         foreach ($configuration->get('compiles') as $compileFile) {
             $file = trim($compileFile->getValue());
             $file = AgaviToolkit::expandDirectives($file);
             $file = self::replacePath($file);
             $file = realpath($file);
             if (!is_readable($file)) {
                 // file doesn't exist
                 $error = 'Configuration file "%s" specifies nonexistent ' . 'or unreadable file "%s"';
                 $error = sprintf($error, $config, $compileFile->getValue());
                 throw new AgaviParseException($error);
             }
             if (AgaviConfig::get('core.debug', false)) {
                 // debug mode, just require() the files, makes for nicer stack traces
                 $contents = 'require(' . var_export($file, true) . ');';
             } else {
                 // no debug mode, so make things fast
                 $contents = $this->formatFile(file_get_contents($file));
             }
             // append file data
             $data[$file] = $contents;
         }
     }
     return $this->generate($data, $config);
 }
开发者ID:horros,项目名称:agavi,代码行数:50,代码来源:AgaviCompileConfigHandler.class.php


示例7: loadModuleFiles

 private function loadModuleFiles($tm, &$files)
 {
     $default = $tm->getDefaultDomain();
     $translator = $tm->getDomainTranslator($default, AgaviTranslationManager::MESSAGE);
     $locale = $tm->getCurrentLocale();
     $domains = array();
     if ($translator instanceof AppKitGettextTranslator) {
         $basePath = $translator->getDomainPathPattern();
         $modules = scandir(AgaviToolkit::literalize("%core.module_dir%"));
         foreach ($modules as $m) {
             if ($m != '.' && $m != '..') {
                 $domains[] = $m;
             }
         }
         foreach ($domains as $domain) {
             $path = AgaviToolkit::expandVariables($basePath, array('domain' => $domain));
             foreach (AgaviLocale::getLookupPath($tm->getCurrentLocale()->getIdentifier()) as $prefix) {
                 $result = $this->loadFile($path, $prefix, $files);
                 if ($result) {
                     $files[$domain] = $result;
                 }
             }
         }
     }
 }
开发者ID:philippjenni,项目名称:icinga-web,代码行数:25,代码来源:initI18nSuccessView.class.php


示例8: validate

 /**
  * Validates the input.
  * 
  * @return     bool The value is a valid boolean
  * 
  * @author     Felix Gilcher <[email protected]>
  * @since      1.0.4
  */
 protected function validate()
 {
     $value =& $this->getData($this->getArgument());
     $origValue = $value;
     if (is_bool($value)) {
         // noop
     } elseif (1 === $value || '1' === $value) {
         $value = true;
     } elseif (0 === $value || '0' === $value) {
         $value = false;
     } elseif (is_string($value)) {
         $value = AgaviToolkit::literalize($value);
     }
     if (is_bool($value)) {
         // we don't cast if the value is exported.
         // caution, AgaviValidator::export does the test for empty
         // strings, null and false values, so we can't use
         // hasParameter here
         if ($this->getParameter('export')) {
             $value = $origValue;
         } else {
             $this->export($value);
         }
         return true;
     }
     $value = $origValue;
     $this->throwError('type');
     return false;
 }
开发者ID:philippjenni,项目名称:icinga-web,代码行数:37,代码来源:AgaviBooleanValidator.class.php


示例9: loadConfig

 public static function loadConfig()
 {
     if (self::$configLoaded) {
         return;
     }
     self::$config = (include AgaviConfigCache::checkConfig(AgaviToolkit::expandDirectives('%core.module_dir%/Api/config/access.xml')));
     self::$configLoaded = true;
 }
开发者ID:philippjenni,项目名称:icinga-web,代码行数:8,代码来源:AccessConfig.class.php


示例10: initialize

 /**
  * Load Propel config
  * 
  * @param      AgaviDatabaseManager The database manager of this instance.
  * @param      array                An assoc array of initialization params.
  *
  * @author     David Zülke <[email protected]>
  * @since      0.10.0
  */
 public function initialize(AgaviDatabaseManager $databaseManager, array $parameters = array())
 {
     parent::initialize($databaseManager, $parameters);
     $configPath = AgaviToolkit::expandDirectives($this->getParameter('config'));
     $datasource = $this->getParameter('datasource', null);
     $use_as_default = $this->getParameter('use_as_default', false);
     $config = (require $configPath);
     if ($datasource === null || $datasource == 'default') {
         if (isset($config['propel']['datasources']['default'])) {
             $datasource = $config['propel']['datasources']['default'];
         } elseif (isset($config['datasources']['default'])) {
             $datasource = $config['datasources']['default'];
         } else {
             throw new AgaviDatabaseException('No datasource given for Propel connection, and no default datasource specified in runtime configuration file.');
         }
     }
     if (!class_exists('Propel')) {
         include 'propel/Propel.php';
     }
     if (!Propel::isInit()) {
         Propel::init($configPath);
     }
     $is13 = version_compare(Propel::VERSION, '1.4', '<');
     // grab the configuration values and inject possibly defined overrides for this data source
     if ($is13) {
         // old-style config array; PropelConfiguration was added after 1.3.0, http://trac.agavi.org/ticket/1195
         $config = Propel::getConfiguration();
         $config['datasources'][$datasource]['adapter'] = $this->getParameter('overrides[adapter]', $config['datasources'][$datasource]['adapter']);
         $config['datasources'][$datasource]['connection'] = array_merge($config['datasources'][$datasource]['connection'], $this->getParameter('overrides[connection]', array()));
         // also the autoload classes
         $config['datasources'][$datasource]['classes'] = array_merge($config['datasources'][$datasource]['classes'], $this->getParameter('overrides[classes]', array()));
         // and init queries
         if (!isset($config['datasources'][$datasource]['connection']['settings']['queries']['query'])) {
             $config['datasources'][$datasource]['connection']['settings']['queries']['query'] = array();
         }
         // array cast because "query" might be a string if just one init query was given, http://trac.agavi.org/ticket/1194
         $config['datasources'][$datasource]['connection']['settings']['queries']['query'] = array_merge((array) $config['datasources'][$datasource]['connection']['settings']['queries']['query'], (array) $this->getParameter('init_queries'));
         // set the new config
         Propel::setConfiguration($config);
     } else {
         $config = Propel::getConfiguration(PropelConfiguration::TYPE_OBJECT);
         $overrides = (array) $this->getParameter('overrides');
         // set override values
         foreach ($overrides as $key => $value) {
             $config->setParameter($key, $value);
         }
         // handle init queries in a cross-adapter fashion (they all support the "init_queries" param)
         $queries = (array) $config->getParameter('datasources.' . $datasource . '.connection.settings.queries.query', array());
         // yes... it's one array, [connection][settings][queries][query], with all the init queries from the config, so we append to that
         $queries = array_merge($queries, (array) $this->getParameter('init_queries'));
         $config->setParameter('datasources.' . $datasource . '.connection.settings.queries.query', $queries);
     }
     if (true === $this->getParameter('enable_instance_pooling')) {
         Propel::enableInstancePooling();
     } elseif (false === $this->getParameter('enable_instance_pooling')) {
         Propel::disableInstancePooling();
     }
 }
开发者ID:horros,项目名称:agavi,代码行数:67,代码来源:AgaviPropelDatabase.class.php


示例11: initialize

 public function initialize(AgaviContext $context, array $parameters = array())
 {
     parent::initialize($context, $parameters);
     $this->config = (include AgaviConfigCache::checkConfig(AgaviToolkit::expandDirectives('%core.module_dir%/Api/config/icingaCommands.xml')));
     $this->user = $context->getUser();
     if ($this->user->getNsmUser()->hasTarget('IcingaCommandRestrictions')) {
         $this->filterCommandsByUser($this->config);
     }
 }
开发者ID:philippjenni,项目名称:icinga-web,代码行数:9,代码来源:CommandInfoModel.class.php


示例12: bootstrap

 /**
  * Startup the Agavi core
  *
  * @param      string environment the environment to use for this session.
  *
  * @author     David Zülke <[email protected]>
  * @since      0.11.0
  */
 public static function bootstrap($environment = null)
 {
     // set up our __autoload
     spl_autoload_register(array('AgaviAutoloader', 'loadClass'));
     try {
         if ($environment === null) {
             // no env given? let's read one from core.environment
             $environment = AgaviConfig::get('core.environment');
         } elseif (AgaviConfig::has('core.environment') && AgaviConfig::isReadonly('core.environment')) {
             // env given, but core.environment is read-only? then we must use that instead and ignore the given setting
             $environment = AgaviConfig::get('core.environment');
         }
         if ($environment === null) {
             // still no env? oh man...
             throw new AgaviException('You must supply an environment name to Agavi::bootstrap() or set the name of the default environment to be used in the configuration directive "core.environment".');
         }
         // finally set the env to what we're really using now.
         AgaviConfig::set('core.environment', $environment, true, true);
         AgaviConfig::set('core.debug', false, false);
         if (!AgaviConfig::has('core.app_dir')) {
             throw new AgaviException('Configuration directive "core.app_dir" not defined, terminating...');
         }
         // define a few filesystem paths
         AgaviConfig::set('core.cache_dir', AgaviConfig::get('core.app_dir') . '/cache', false, true);
         AgaviConfig::set('core.config_dir', AgaviConfig::get('core.app_dir') . '/config', false, true);
         AgaviConfig::set('core.system_config_dir', AgaviConfig::get('core.agavi_dir') . '/config/defaults', false, true);
         AgaviConfig::set('core.lib_dir', AgaviConfig::get('core.app_dir') . '/lib', false, true);
         AgaviConfig::set('core.model_dir', AgaviConfig::get('core.app_dir') . '/models', false, true);
         AgaviConfig::set('core.module_dir', AgaviConfig::get('core.app_dir') . '/modules', false, true);
         AgaviConfig::set('core.template_dir', AgaviConfig::get('core.app_dir') . '/templates', false, true);
         AgaviConfig::set('core.cldr_dir', AgaviConfig::get('core.agavi_dir') . '/translation/data', false, true);
         // autoloads first (will trigger the compilation of config_handlers.xml)
         $autoload = AgaviConfig::get('core.config_dir') . '/autoload.xml';
         if (!is_readable($autoload)) {
             $autoload = AgaviConfig::get('core.system_config_dir') . '/autoload.xml';
         }
         AgaviConfigCache::load($autoload);
         // load base settings
         AgaviConfigCache::load(AgaviConfig::get('core.config_dir') . '/settings.xml');
         // clear our cache if the conditions are right
         if (AgaviConfig::get('core.debug')) {
             AgaviToolkit::clearCache();
             // load base settings
             AgaviConfigCache::load(AgaviConfig::get('core.config_dir') . '/settings.xml');
         }
         $compile = AgaviConfig::get('core.config_dir') . '/compile.xml';
         if (!is_readable($compile)) {
             $compile = AgaviConfig::get('core.system_config_dir') . '/compile.xml';
         }
         // required classes for the framework
         AgaviConfigCache::load($compile);
     } catch (Exception $e) {
         AgaviException::render($e);
     }
 }
开发者ID:horros,项目名称:agavi,代码行数:63,代码来源:Agavi.class.php


示例13: main

 /**
  * Executes the task.
  */
 public function main()
 {
     if ($this->property === null) {
         throw new BuildException('The property attribute must be specified');
     }
     if ($this->string === null) {
         throw new BuildException('The string attribute must be specified');
     }
     $result = str_replace('/', '_', AgaviToolkit::canonicalName($this->string));
     $this->project->setUserProperty($this->property, $result);
 }
开发者ID:horros,项目名称:agavi,代码行数:14,代码来源:AgaviTransformviewclassbaseTask.php


示例14: testCheckConfig

 public function testCheckConfig()
 {
     $config = AgaviConfig::get('core.config_dir') . DIRECTORY_SEPARATOR . 'autoload.xml';
     $config = AgaviToolkit::normalizePath($config);
     $expected = AgaviConfigCache::getCacheName($config);
     if (file_exists($expected)) {
         unlink($expected);
     }
     $cacheName = AgaviConfigCache::checkConfig($config);
     $this->assertEquals($expected, $cacheName);
     $this->assertFileExists($cacheName);
 }
开发者ID:horros,项目名称:agavi,代码行数:12,代码来源:AgaviConfigCacheTest.php


示例15: testConfigHandlersConfigHandler

 public function testConfigHandlersConfigHandler()
 {
     $hf = AgaviToolkit::normalizePath(AgaviConfig::get('core.config_dir') . '/routing.xml');
     $CHCH = new AgaviConfigHandlersConfigHandler();
     $document = $this->parseConfiguration(AgaviConfig::get('core.config_dir') . '/tests/config_handlers.xml', AgaviConfig::get('core.agavi_dir') . '/config/xsl/config_handlers.xsl');
     $file = $this->getIncludeFile($CHCH->execute($document));
     $handlers = (include $file);
     unlink($file);
     $this->assertCount(1, $handlers);
     $this->assertTrue(isset($handlers[$hf]));
     $this->assertSame('CHCHTestHandler', $handlers[$hf]['class']);
     $this->assertSame(AgaviConfig::get('core.agavi_dir') . '/config/xsd/routing.xsd', $handlers[$hf]['validations']['single']['transformations_after']['xml_schema'][0]);
     $this->assertSame(array('foo' => 'bar', 'dir' => AgaviConfig::get('core.agavi_dir')), $handlers[$hf]['parameters']);
 }
开发者ID:horros,项目名称:agavi,代码行数:14,代码来源:AgaviConfigHandlersConfigHandlerTest.php


示例16: createEngineInstance

 /**
  * Create an instance of PHPTAL and initialize it correctly.
  *
  * @return     PHPTAL The PHPTAL instance.
  *
  * @author     David Zülke <[email protected]>
  * @since      1.0.2
  */
 protected function createEngineInstance()
 {
     $phptalPhpCodeDestination = AgaviConfig::get('core.cache_dir') . DIRECTORY_SEPARATOR . AgaviPhptalRenderer::COMPILE_DIR . DIRECTORY_SEPARATOR . AgaviPhptalRenderer::COMPILE_SUBDIR . DIRECTORY_SEPARATOR;
     // we keep this for < 1.2
     if (!defined('PHPTAL_PHP_CODE_DESTINATION')) {
         define('PHPTAL_PHP_CODE_DESTINATION', $phptalPhpCodeDestination);
     }
     AgaviToolkit::mkdir($phptalPhpCodeDestination, fileperms(AgaviConfig::get('core.cache_dir')), true);
     if (!class_exists('PHPTAL')) {
         require 'PHPTAL.php';
     }
     $phptal = new PHPTAL();
     if (version_compare(PHPTAL_VERSION, '1.2', 'ge')) {
         $phptal->setPhpCodeDestination($phptalPhpCodeDestination);
     }
     return $phptal;
 }
开发者ID:philippjenni,项目名称:icinga-web,代码行数:25,代码来源:AgaviPhptalRenderer.class.php


示例17: execute

 /**
  * Execute this configuration handler.
  *
  * @param      AgaviXmlConfigDomDocument The document to parse.
  *
  * @return     string Data to be written to a cache file.
  *
  * @throws     <b>AgaviParseException</b> If a requested configuration file is
  *                                        improperly formatted.
  *
  * @author     David Zülke <[email protected]>
  * @since      0.9.0
  */
 public function execute(AgaviXmlConfigDomDocument $document)
 {
     // set up our default namespace
     $document->setDefaultNamespace(self::XML_NAMESPACE, 'module');
     // remember the config file path
     $config = $document->documentURI;
     $enabled = false;
     $prefix = 'modules.${moduleName}.';
     $data = array();
     // loop over <configuration> elements
     foreach ($document->getConfigurationElements() as $configuration) {
         $module = $configuration->getChild('module');
         if (!$module) {
             continue;
         }
         // enabled flag is treated separately
         $enabled = (bool) AgaviToolkit::literalize($module->getAttribute('enabled'));
         // loop over <setting> elements; there can be many of them
         foreach ($module->get('settings') as $setting) {
             $localPrefix = $prefix;
             // let's see if this buddy has a <settings> parent with valuable information
             if ($setting->parentNode->localName == 'settings') {
                 if ($setting->parentNode->hasAttribute('prefix')) {
                     $localPrefix = $setting->parentNode->getAttribute('prefix');
                 }
             }
             $settingName = $localPrefix . $setting->getAttribute('name');
             if ($setting->hasAgaviParameters()) {
                 $data[$settingName] = $setting->getAgaviParameters();
             } else {
                 $data[$settingName] = AgaviToolkit::literalize($setting->getValue());
             }
         }
     }
     $code = array();
     $code[] = '$lcModuleName = strtolower($moduleName);';
     $code[] = 'AgaviConfig::set(AgaviToolkit::expandVariables(' . var_export($prefix . 'enabled', true) . ', array(\'moduleName\' => $lcModuleName)), ' . var_export($enabled, true) . ', true, true);';
     if (count($data)) {
         $code[] = '$moduleConfig = ' . var_export($data, true) . ';';
         $code[] = '$moduleConfigKeys = array_keys($moduleConfig);';
         $code[] = 'foreach($moduleConfigKeys as &$value) $value = AgaviToolkit::expandVariables($value, array(\'moduleName\' => $lcModuleName));';
         $code[] = '$moduleConfig = array_combine($moduleConfigKeys, $moduleConfig);';
         $code[] = 'AgaviConfig::fromArray($moduleConfig);';
     }
     return $this->generate($code, $config);
 }
开发者ID:horros,项目名称:agavi,代码行数:59,代码来源:AgaviModuleConfigHandler.class.php


示例18: execute

 /**
  * Execute this configuration handler.
  *
  * @param      AgaviXmlConfigDomDocument The document to handle.
  *
  * @return     string Data to be written to a cache file.
  *
  * @throws     <b>AgaviUnreadableException</b> If a requested configuration
  *                                             file does not exist or is not
  *                                             readable.
  * @throws     <b>AgaviParseException</b> If a requested configuration file is
  *                                        improperly formatted.
  *
  * @author     Dominik del Bondio <[email protected]>
  * @author     Noah Fontes <[email protected]>
  * @author     David Zülke <[email protected]>
  * @since      0.11.0
  */
 public function execute(AgaviXmlConfigDomDocument $document)
 {
     // set up our default namespace
     $document->setDefaultNamespace(self::XML_NAMESPACE, 'config_handlers');
     // init our data arrays
     $handlers = array();
     foreach ($document->getConfigurationElements() as $configuration) {
         if (!$configuration->has('handlers')) {
             continue;
         }
         // let's do our fancy work
         foreach ($configuration->get('handlers') as $handler) {
             $pattern = $handler->getAttribute('pattern');
             $category = AgaviToolkit::normalizePath(AgaviToolkit::expandDirectives($pattern));
             $class = $handler->getAttribute('class');
             $transformations = array(AgaviXmlConfigParser::STAGE_SINGLE => array(), AgaviXmlConfigParser::STAGE_COMPILATION => array());
             if ($handler->has('transformations')) {
                 foreach ($handler->get('transformations') as $transformation) {
                     $path = AgaviToolkit::literalize($transformation->getValue());
                     $for = $transformation->getAttribute('for', AgaviXmlConfigParser::STAGE_SINGLE);
                     $transformations[$for][] = $path;
                 }
             }
             $validations = array(AgaviXmlConfigParser::STAGE_SINGLE => array(AgaviXmlConfigParser::STEP_TRANSFORMATIONS_BEFORE => array(AgaviXmlConfigParser::VALIDATION_TYPE_RELAXNG => array(), AgaviXmlConfigParser::VALIDATION_TYPE_SCHEMATRON => array(), AgaviXmlConfigParser::VALIDATION_TYPE_XMLSCHEMA => array()), AgaviXmlConfigParser::STEP_TRANSFORMATIONS_AFTER => array(AgaviXmlConfigParser::VALIDATION_TYPE_RELAXNG => array(), AgaviXmlConfigParser::VALIDATION_TYPE_SCHEMATRON => array(), AgaviXmlConfigParser::VALIDATION_TYPE_XMLSCHEMA => array())), AgaviXmlConfigParser::STAGE_COMPILATION => array(AgaviXmlConfigParser::STEP_TRANSFORMATIONS_BEFORE => array(AgaviXmlConfigParser::VALIDATION_TYPE_RELAXNG => array(), AgaviXmlConfigParser::VALIDATION_TYPE_SCHEMATRON => array(), AgaviXmlConfigParser::VALIDATION_TYPE_XMLSCHEMA => array()), AgaviXmlConfigParser::STEP_TRANSFORMATIONS_AFTER => array(AgaviXmlConfigParser::VALIDATION_TYPE_RELAXNG => array(), AgaviXmlConfigParser::VALIDATION_TYPE_SCHEMATRON => array(), AgaviXmlConfigParser::VALIDATION_TYPE_XMLSCHEMA => array())));
             if ($handler->has('validations')) {
                 foreach ($handler->get('validations') as $validation) {
                     $path = AgaviToolkit::literalize($validation->getValue());
                     $type = null;
                     if (!$validation->hasAttribute('type')) {
                         $type = $this->guessValidationType($path);
                     } else {
                         $type = $validation->getAttribute('type');
                     }
                     $for = $validation->getAttribute('for', AgaviXmlConfigParser::STAGE_SINGLE);
                     $step = $validation->getAttribute('step', AgaviXmlConfigParser::STEP_TRANSFORMATIONS_AFTER);
                     $validations[$for][$step][$type][] = $path;
                 }
             }
             $handlers[$category] = isset($handlers[$category]) ? $handlers[$category] : array('parameters' => array());
             $handlers[$category] = array('class' => $class, 'parameters' => $handler->getAgaviParameters($handlers[$category]['parameters']), 'transformations' => $transformations, 'validations' => $validations);
         }
     }
     $data = array('return ' . var_export($handlers, true));
     return $this->generate($data, $document->documentURI);
 }
开发者ID:philippjenni,项目名称:icinga-web,代码行数:63,代码来源:AgaviConfigHandlersConfigHandler.class.php


示例19: getValidatorXMLForAction

 /**
  * Fetches the Validation xml for the action/module combination and returns it as
  * an DOMDocument
  *
  * @param    string  The module name
  * @param    string  The action to get the validation xml for
  * @return   AgaviXmlConfigDomDocument
  *
  * @author   Jannis Moßhammer<[email protected]>
  * @throws   AgaviConfigurationException     when module or action does not exist
  */
 protected function getValidatorXMLForAction($module, $action)
 {
     // get Module path
     $path = AgaviToolkit::literalize('%core.module_dir%') . "/" . $module;
     if (!file_exists(AgaviToolkit::normalizePath($path))) {
         throw new AgaviConfigurationException("Couldn't find module " . $module);
     }
     // get Validation file
     $actionPath = str_replace(".", "/", $action);
     $xml = $path . "/validate/" . $actionPath . ".xml";
     if (!file_exists(AgaviToolkit::normalizePath($path))) {
         throw new AgaviConfigurationException("Couldn't find validation file for " . $action);
     }
     $dom = new AgaviXmlConfigDomDocument();
     $dom->load(AgaviToolKit::normalizePath($xml));
     //TODO: Validate xml
     return $dom;
 }
开发者ID:philippjenni,项目名称:icinga-web,代码行数:29,代码来源:AppKitApiProviderParser.class.php


示例20: getResourceStreamIdentifier

 /**
  * Get the full, resolved stream location name to the template resource.
  *
  * @return     string A PHP stream resource identifier.
  *
  * @throws     AgaviException If the template could not be found.
  *
  * @author     David Zülke <[email protected]>
  * @since      0.11.0
  */
 public function getResourceStreamIdentifier()
 {
     $template = $this->getParameter('template');
     if ($template === null) {
         // no template set, we return null so nothing gets rendered
         return null;
     }
     $args = array();
     if (AgaviConfig::get('core.use_translation')) {
         // i18n is enabled, build a list of sprintf args with the locale identifier
         foreach (AgaviLocale::getLookupPath($this->context->getTranslationManager()->getCurrentLocaleIdentifier()) as $identifier) {
             $args[] = array('locale' => $identifier);
         }
     }
     if (empty($args)) {
         $args[] = array();
         // add one empty arg to always trigger target lookups (even if i18n is disabled etc.)
     }
     $scheme = $this->getParameter('scheme');
     // FIXME: a simple workaround for broken ubuntu and debian packages (fixed already), we can remove that for final 0.11
     if ($scheme != 'file' && !in_array($scheme, stream_get_wrappers())) {
         throw new AgaviException('Unknown stream wrapper "' . $scheme . '", must be one of "' . implode('", "', stream_get_wrappers()) . '".');
     }
     $check = $this->getParameter('check');
     $attempts = array();
     // try each of the patterns
     foreach ((array) $this->getParameter('targets', array()) as $pattern) {
         // try pattern with each argument list
         foreach ($args as $arg) {
             $target = AgaviToolkit::expandVariables($pattern, array_merge(array_filter($this->getParameters(), 'is_scalar'), array_filter($this->getParameters(), 'is_null'), $arg));
             // FIXME (should they fix it): don't add file:// because suhosin's include whitelist is empty by default, does not contain 'file' as allowed uri scheme
             if ($scheme != 'file') {
                 $target = $scheme . '://' . $target;
             }
             if (!$check || is_readable($target)) {
                 return $target;
             }
             $attempts[] = $target;
         }
     }
     // no template found, time to throw an exception
     throw new AgaviException('Template "' . $template . '" could not be found. Paths tried:' . "\n" . implode("\n", $attempts));
 }
开发者ID:horros,项目名称:agavi,代码行数:53,代码来源:AgaviStreamTemplateLayer.class.php



注:本文中的AgaviToolkit类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Agenda类代码示例发布时间:2022-05-23
下一篇:
PHP AgaviRequestDataHolder类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap