本文整理汇总了PHP中sfFilterChain::loadConfiguration方法的典型用法代码示例。如果您正苦于以下问题:PHP sfFilterChain::loadConfiguration方法的具体用法?PHP sfFilterChain::loadConfiguration怎么用?PHP sfFilterChain::loadConfiguration使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sfFilterChain
的用法示例。
在下文中一共展示了sfFilterChain::loadConfiguration方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: forward
public function forward($moduleName, $actionName)
{
$moduleName = preg_replace('/[^a-z0-9_]+/i', '', $moduleName);
$actionName = preg_replace('/[^a-z0-9_]+/i', '', $actionName);
if ($this->getActionStack()->getSize() >= $this->maxForwards) {
throw new sfForwardException('Too many forwards have been detected for this request.');
}
$this->context->getConfigCache()->import('modules/' . $moduleName . '/config/generator.yml', false, true);
if (!$this->actionExists($moduleName, $actionName)) {
if (sfConfig::get('sf_logging_enabled')) {
$this->dispatcher->notify(new sfEvent($this, 'application.log', array(sprintf('Action "%s/%s" does not exist', $moduleName, $actionName))));
}
throw new sfError404Exception(sprintf('Action "%s/%s" does not exist.', $moduleName, $actionName));
}
$actionInstance = $this->getAction($moduleName, $actionName);
$this->getActionStack()->addEntry($moduleName, $actionName, $actionInstance);
$viewClass = sfConfig::get('mod_' . strtolower($moduleName) . '_view_class', false);
require $this->context->getConfigCache()->checkConfig('modules/' . $moduleName . '/config/module.yml');
if (false !== $viewClass) {
sfConfig::set('mod_' . strtolower($moduleName) . '_view_class', $viewClass);
}
if (sfConfig::get('mod_' . strtolower($moduleName) . '_enabled')) {
$moduleConfig = sfConfig::get('sf_app_module_dir') . '/' . $moduleName . '/config/config.php';
if (is_readable($moduleConfig)) {
require_once $moduleConfig;
}
$filterChain = new sfFilterChain();
$filterChain->loadConfiguration($actionInstance);
$this->context->getEventDispatcher()->notify(new sfEvent($this, 'controller.change_action', array('module' => $moduleName, 'action' => $actionName)));
if ($moduleName == sfConfig::get('sf_error_404_module') && $actionName == sfConfig::get('sf_error_404_action')) {
$this->context->getResponse()->setStatusCode(404);
$this->context->getResponse()->setHttpHeader('Status', '404 Not Found');
$this->dispatcher->notify(new sfEvent($this, 'controller.page_not_found', array('module' => $moduleName, 'action' => $actionName)));
}
$filterChain->execute();
} else {
$moduleName = sfConfig::get('sf_module_disabled_module');
$actionName = sfConfig::get('sf_module_disabled_action');
if (!$this->actionExists($moduleName, $actionName)) {
throw new sfConfigurationException(sprintf('Invalid configuration settings: [sf_module_disabled_module] "%s", [sf_module_disabled_action] "%s".', $moduleName, $actionName));
}
$this->forward($moduleName, $actionName);
}
}
示例2: forward
/**
* Forwards the request to another action.
*
* @param string $moduleName A module name
* @param string $actionName An action name
*
* @throws sfConfigurationException If an invalid configuration setting has been found
* @throws sfForwardException If an error occurs while forwarding the request
* @throws sfError404Exception If the action not exist
* @throws sfInitializationException If the action could not be initialized
*/
public function forward($moduleName, $actionName)
{
// replace unwanted characters
$moduleName = preg_replace('/[^a-z0-9_]+/i', '', $moduleName);
$actionName = preg_replace('/[^a-z0-9_]+/i', '', $actionName);
if ($this->getActionStack()->getSize() >= 5) {
// let's kill this party before it turns into cpu cycle hell
throw new sfForwardException('Too many forwards have been detected for this request.');
}
// check for a module generator config file
$this->context->getConfigCache()->import('modules/' . $moduleName . '/config/generator.yml', false, true);
if (!$this->actionExists($moduleName, $actionName)) {
// the requested action doesn't exist
if (sfConfig::get('sf_logging_enabled')) {
$this->dispatcher->notify(new sfEvent($this, 'application.log', array(sprintf('Action "%s/%s" does not exist', $moduleName, $actionName))));
}
throw new sfError404Exception(sprintf('Action "%s/%s" does not exist.', $moduleName, $actionName));
}
// create an instance of the action
$actionInstance = $this->getAction($moduleName, $actionName);
// add a new action stack entry
$this->getActionStack()->addEntry($moduleName, $actionName, $actionInstance);
// include module configuration
require $this->context->getConfigCache()->checkConfig('modules/' . $moduleName . '/config/module.yml');
// check if this module is internal
if ($this->getActionStack()->getSize() == 1 && sfConfig::get('mod_' . strtolower($moduleName) . '_is_internal') && !sfConfig::get('sf_test')) {
throw new sfConfigurationException(sprintf('Action "%s" from module "%s" cannot be called directly.', $actionName, $moduleName));
}
// module enabled?
if (sfConfig::get('mod_' . strtolower($moduleName) . '_enabled')) {
// check for a module config.php
$moduleConfig = sfConfig::get('sf_app_module_dir') . '/' . $moduleName . '/config/config.php';
if (is_readable($moduleConfig)) {
require_once $moduleConfig;
}
// create a new filter chain
$filterChain = new sfFilterChain();
$filterChain->loadConfiguration($actionInstance);
$this->context->getEventDispatcher()->notify(new sfEvent($this, 'controller.change_action', array('module' => $moduleName, 'action' => $actionName)));
if ($moduleName == sfConfig::get('sf_error_404_module') && $actionName == sfConfig::get('sf_error_404_action')) {
$this->context->getResponse()->setStatusCode(404);
$this->context->getResponse()->setHttpHeader('Status', '404 Not Found');
$this->dispatcher->notify(new sfEvent($this, 'controller.page_not_found', array('module' => $moduleName, 'action' => $actionName)));
}
// process the filter chain
$filterChain->execute();
} else {
$moduleName = sfConfig::get('sf_module_disabled_module');
$actionName = sfConfig::get('sf_module_disabled_action');
if (!$this->actionExists($moduleName, $actionName)) {
// cannot find mod disabled module/action
throw new sfConfigurationException(sprintf('Invalid configuration settings: [sf_module_disabled_module] "%s", [sf_module_disabled_action] "%s".', $moduleName, $actionName));
}
$this->forward($moduleName, $actionName);
}
}