当前位置: 首页>>代码示例>>PHP>>正文


PHP AgaviToolkit类代码示例

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


在下文中一共展示了AgaviToolkit类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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 <skerr@mojavi.org>
  * @author     Dominik del Bondio <ddb@bitxtender.com>
  * @author     David Zülke <david.zuelke@bitextender.com>
  * @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 <felix.gilcher@bitextender.com>
  * @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 <dz@bitxtender.com>
  * @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 <dz@bitxtender.com>
  * @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


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