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


PHP AgaviToolkit::evaluateModuleDirective方法代码示例

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


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

示例1: execute

 /**
  * Execute this filter.
  *
  * @param      AgaviFilterChain        The filter chain.
  * @param      AgaviExecutionContainer The current execution container.
  *
  * @throws     <b>AgaviInitializationException</b> If an error occurs during
  *                                                 View initialization.
  * @throws     <b>AgaviViewException</b>           If an error occurs while
  *                                                 executing the View.
  *
  * @author     David Zülke <dz@bitxtender.com>
  * @author     Felix Gilcher <felix.gilcher@bitextender.com>
  * @author     Sean Kerr <skerr@mojavi.org>
  * @since      0.9.0
  */
 public function execute(AgaviFilterChain $filterChain, AgaviExecutionContainer $container)
 {
     // $lm = $this->context->getLoggerManager();
     // get the context, controller and validator manager
     $controller = $this->context->getController();
     // get the current action information
     $actionName = $container->getActionName();
     $moduleName = $container->getModuleName();
     // the action instance
     $actionInstance = $container->getActionInstance();
     $request = $this->context->getRequest();
     $isCacheable = false;
     $cachingDotXml = AgaviToolkit::evaluateModuleDirective($moduleName, 'agavi.cache.path', array('moduleName' => $moduleName, 'actionName' => $actionName));
     if ($this->getParameter('enable_caching', true) && is_readable($cachingDotXml)) {
         // $lm->log('Caching enabled, configuration file found, loading...');
         // no _once please!
         include AgaviConfigCache::checkConfig($cachingDotXml, $this->context->getName());
     }
     $isActionCached = false;
     if ($isCacheable) {
         try {
             $groups = $this->determineGroups($config['groups'], $container);
             $actionGroups = array_merge($groups, array(self::ACTION_CACHE_ID));
         } catch (AgaviUncacheableException $e) {
             // a group callback threw an exception. that means we're not allowed t cache
             $isCacheable = false;
         }
         if ($isCacheable) {
             // this is not wrapped in the try/catch block above as it might throw an exception itself
             $isActionCached = $this->checkCache(array_merge($groups, array(self::ACTION_CACHE_ID)), $config['lifetime']);
             if (!$isActionCached) {
                 // cacheable, but action is not cached. notify our callback so it can prevent the stampede that follows
                 $this->startedCacheCreationCallback(self::CACHE_CALLBACK_ACTION_NOT_CACHED, $actionGroups, $config, $container);
             }
         }
     } else {
         // $lm->log('Action is not cacheable!');
     }
     if ($isActionCached) {
         // $lm->log('Action is cached, loading...');
         // cache/dir/4-8-15-16-23-42 contains the action cache
         try {
             $actionCache = $this->readCache($actionGroups);
             // and restore action attributes
             $actionInstance->setAttributes($actionCache['action_attributes']);
         } catch (AgaviException $e) {
             // cacheable, but action is not cached. notify our callback so it can prevent the stampede that follows
             $this->startedCacheCreationCallback(self::CACHE_CALLBACK_ACTION_CACHE_GONE, $actionGroups, $config, $container);
             $isActionCached = false;
         }
     }
     $isViewCached = false;
     $rememberTheView = null;
     while (true) {
         if (!$isActionCached) {
             $actionCache = array();
             // $lm->log('Action not cached, executing...');
             // execute the Action and get the View to execute
             list($actionCache['view_module'], $actionCache['view_name']) = $container->runAction();
             // check if we've just run the action again after a previous cache read revealed that the view is not cached for this output type and we need to go back to square one due to the lack of action attribute caching configuration...
             // if yes: is the view module/name that we got just now different from what was in the cache?
             if (isset($rememberTheView) && $actionCache != $rememberTheView) {
                 // yup. clear it!
                 $ourClass = get_class($this);
                 call_user_func(array($ourClass, 'clearCache'), $groups);
             }
             // check if the returned view is cacheable
             if ($isCacheable && is_array($config['views']) && !in_array(array('module' => $actionCache['view_module'], 'name' => $actionCache['view_name']), $config['views'], true)) {
                 $isCacheable = false;
                 $this->abortedCacheCreationCallback(self::CACHE_CALLBACK_VIEW_NOT_CACHEABLE, $actionGroups, $config, $container);
                 // so that view is not cacheable? okay then:
                 // check if we've just run the action again after a previous cache read revealed that the view is not cached for this output type and we need to go back to square one due to the lack of action attribute caching configuration...
                 // 'cause then we need to flush all those existing caches - obviously, that data is stale now, as we learned, since we are not allowed to cache anymore for the view that was returned now
                 if (isset($rememberTheView)) {
                     // yup. clear it!
                     $ourClass = get_class($this);
                     call_user_func(array($ourClass, 'clearCache'), $groups);
                 }
                 // $lm->log('Returned View is not cleared for caching, setting cacheable status to false.');
             } else {
                 // $lm->log('Returned View is cleared for caching, proceeding...');
             }
             $actionAttributes = $actionInstance->getAttributes();
         }
//.........这里部分代码省略.........
开发者ID:philippjenni,项目名称:icinga-web,代码行数:101,代码来源:AgaviExecutionFilter.class.php

示例2: normalizeViewName

 /**
  * normalizes a viewname according to the configured rules
  * 
  * Please do not use this method, it exists only for internal 
  * purposes and will be removed ASAP. You have been warned
  * 
  * @param      string the short view name
  * 
  * @return     string the full view name
  * 
  * @author     Felix Gilcher <felix.gilcher@bitextender.com>
  * @since      1.0.0
  */
 protected function normalizeViewName($shortName)
 {
     if ($shortName !== AgaviView::NONE) {
         $shortName = AgaviToolkit::evaluateModuleDirective($this->moduleName, 'agavi.view.name', array('actionName' => $this->actionName, 'viewName' => $shortName));
         $shortName = AgaviToolkit::canonicalName($shortName);
     }
     return $shortName;
 }
开发者ID:philippjenni,项目名称:icinga-web,代码行数:21,代码来源:AgaviFragmentTestCase.class.php

示例3: initialize

 /**
  * Initialize the layer.
  *
  * Will try and figure out an alternative default for "directory".
  *
  * @param      AgaviContext The current Context instance.
  * @param      array        An array of initialization parameters.
  *
  * @author     David Zülke <david.zuelke@bitextender.com>
  * @since      1.0.0
  */
 public function initialize(AgaviContext $context, array $parameters = array())
 {
     $this->setParameter('directory', AgaviToolkit::evaluateModuleDirective(isset($parameters['module']) ? $parameters['module'] : '', 'agavi.template.directory'));
     parent::initialize($context, $parameters);
 }
开发者ID:horros,项目名称:agavi,代码行数:16,代码来源:AgaviFileTemplateLayer.class.php

示例4: getParametersForActionAndModule

 /**
  * Get validation information from agavi for the given action and module
  * name for the request method 'read'.
  *
  * @author Jan Schütze <jans@dracoblue.de>
  *
  * @param string $action name of action
  * @param string $module name of module
  *
  * @return array of parameters for all registered validators
  */
 protected function getParametersForActionAndModule($action, $module, $method = 'read')
 {
     /*
      * Agavi uses different coding standard, so we ignore the following...
      *
      * @codingStandardsIgnoreStart
      */
     $parameters = array();
     $this->getContext()->getController()->initializeModule($module);
     $validationManager = $this->getContext()->createInstanceFor('validation_manager');
     $validationConfig = \AgaviToolkit::evaluateModuleDirective($module, 'agavi.validate.path', array('moduleName' => $module, 'actionName' => \AgaviToolkit::canonicalName($action)));
     if (is_readable($validationConfig)) {
         require \AgaviConfigCache::checkConfig($validationConfig, $this->getContext()->getName());
     }
     foreach ($validationManager->getChilds() as $validator) {
         $property = new \ReflectionProperty(get_class($validator), 'arguments');
         $property->setAccessible(true);
         $arguments = $property->getValue($validator);
         $parameters[] = array('name' => implode(', ', $arguments), 'class' => $validator->getParameter('class'), 'required' => $validator->getParameter('required', 'true'), 'description' => $validator->getParameter('description', null), 'base' => $validator->getParameter('base', null));
     }
     /*
      * @codingStandardsIgnoreEnd
      */
     return $parameters;
 }
开发者ID:honeybee,项目名称:honeybee-agavi-cmf-vendor,代码行数:36,代码来源:Error404SuccessView.class.php

示例5: testEvaluateModuleDirective

 public function testEvaluateModuleDirective()
 {
     AgaviConfig::set('replace.me', 'replaced value $foo $bar $baz');
     AgaviConfig::set('modules.foo.bar', 'value $foo %replace.me% %nonexistant%');
     $array = array('foo' => 'replaced_foo', 'bar' => 'replaced_bar');
     $retval = 'value replaced_foo replaced value replaced_foo replaced_bar ${baz} %nonexistant%';
     $actual = AgaviToolkit::evaluateModuleDirective('foo', 'bar', $array);
     $this->assertEquals($retval, $actual);
 }
开发者ID:horros,项目名称:agavi,代码行数:9,代码来源:AgaviToolkitTest.php

示例6: registerValidators

 /**
  * register the validators for this container
  * 
  * @author     David Zülke <david.zuelke@bitxtender.com>
  * @author     Felix Gilcher <felix.gilcher@bitextender.com>
  * @since      1.0.0
  */
 public function registerValidators()
 {
     $validationManager = $this->getValidationManager();
     // get the current action instance
     $actionInstance = $this->getActionInstance();
     // get the current action information
     $moduleName = $this->getModuleName();
     $actionName = $this->getActionName();
     // get the (already formatted) request method
     $method = $this->getRequestMethod();
     // get the current action validation configuration
     $validationConfig = AgaviToolkit::evaluateModuleDirective($moduleName, 'agavi.validate.path', array('moduleName' => $moduleName, 'actionName' => $actionName));
     if (is_readable($validationConfig)) {
         // load validation configuration
         // do NOT use require_once
         require AgaviConfigCache::checkConfig($validationConfig, $this->context->getName());
     }
     // manually load validators
     $registerValidatorsMethod = 'register' . $method . 'Validators';
     if (!is_callable(array($actionInstance, $registerValidatorsMethod))) {
         $registerValidatorsMethod = 'registerValidators';
     }
     $actionInstance->{$registerValidatorsMethod}();
 }
开发者ID:philippjenni,项目名称:icinga-web,代码行数:31,代码来源:AgaviExecutionContainer.class.php

示例7: checkViewFile

 /**
  * Indicates whether or not a module has a specific view file.
  * 
  * Please note that this is only a cursory check and does not 
  * check whether the file actually contains the proper class
  *
  * @param      string A module name.
  * @param      string A view name.
  *
  * @return     mixed  the path to the view file if the view file 
  *                    exists and is readable, false in any other case
  * 
  * @author     Felix Gilcher <felix.gilcher@bitextender.com>
  * @since      1.0.0
  */
 public function checkViewFile($moduleName, $viewName)
 {
     $this->initializeModule($moduleName);
     $viewName = AgaviToolkit::canonicalName($viewName);
     $file = AgaviToolkit::evaluateModuleDirective($moduleName, 'agavi.view.path', array('moduleName' => $moduleName, 'viewName' => $viewName));
     if (is_readable($file) && substr($viewName, 0, 1) !== '/') {
         return $file;
     }
     return false;
 }
开发者ID:horros,项目名称:agavi,代码行数:25,代码来源:AgaviController.class.php


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