/cache/frontend/prod/config/config_core_compile.yml.php
PHP | 4063 lines | 3994 code | 67 blank | 2 comment | 443 complexity | c16621464255fd6c3c6c28760344d955 MD5 | raw file
Possible License(s): LGPL-3.0, LGPL-2.1, AGPL-3.0
Large files files are truncated, but you can click here to view the full file
- <?php
- // auto-generated by sfCompileConfigHandler
- // date: 2009/11/25 13:31:30
- class sfAutoload
- {
- static protected
- $freshCache = false,
- $instance = null;
- protected
- $overriden = array(),
- $classes = array();
- protected function __construct()
- {
- }
- static public function getInstance()
- {
- if (!isset(self::$instance))
- {
- self::$instance = new sfAutoload();
- }
- return self::$instance;
- }
- static public function register()
- {
- ini_set('unserialize_callback_func', 'spl_autoload_call');
- if (false === spl_autoload_register(array(self::getInstance(), 'autoload')))
- {
- throw new sfException(sprintf('Unable to register %s::autoload as an autoloading method.', get_class(self::getInstance())));
- }
- }
- static public function unregister()
- {
- spl_autoload_unregister(array(self::getInstance(), 'autoload'));
- }
- public function setClassPath($class, $path)
- {
- $this->overriden[$class] = $path;
- $this->classes[$class] = $path;
- }
- public function getClassPath($class)
- {
- return isset($this->classes[$class]) ? $this->classes[$class] : null;
- }
- public function reloadClasses($force = false)
- {
- if (self::$freshCache)
- {
- return;
- }
- $configuration = sfProjectConfiguration::getActive();
- if (!$configuration || !$configuration instanceof sfApplicationConfiguration)
- {
- return;
- }
- self::$freshCache = true;
- if (file_exists($configuration->getConfigCache()->getCacheName('config/autoload.yml')))
- {
- self::$freshCache = false;
- if ($force)
- {
- unlink($configuration->getConfigCache()->getCacheName('config/autoload.yml'));
- }
- }
- $file = $configuration->getConfigCache()->checkConfig('config/autoload.yml');
- $this->classes = include($file);
- foreach ($this->overriden as $class => $path)
- {
- $this->classes[$class] = $path;
- }
- }
- public function autoload($class)
- {
- if (!$this->classes)
- {
- self::reloadClasses();
- }
- return self::loadClass($class);
- }
- public function autoloadAgain($class)
- {
- self::reloadClasses(true);
- return self::loadClass($class);
- }
- public function loadClass($class)
- {
- if (class_exists($class, false) || interface_exists($class, false))
- {
- return true;
- }
- if (isset($this->classes[$class]))
- {
- require($this->classes[$class]);
- return true;
- }
- if (sfContext::hasInstance() && ($module = sfContext::getInstance()->getModuleName()) && isset($this->classes[$module.'/'.$class]))
- {
- require($this->classes[$module.'/'.$class]);
- return true;
- }
- return false;
- }
- }
- abstract class sfComponent
- {
- protected
- $moduleName = '',
- $actionName = '',
- $context = null,
- $dispatcher = null,
- $request = null,
- $response = null,
- $varHolder = null,
- $requestParameterHolder = null;
- public function __construct($context, $moduleName, $actionName)
- {
- $this->initialize($context, $moduleName, $actionName);
- }
- public function initialize($context, $moduleName, $actionName)
- {
- $this->moduleName = $moduleName;
- $this->actionName = $actionName;
- $this->context = $context;
- $this->dispatcher = $context->getEventDispatcher();
- $this->varHolder = new sfParameterHolder();
- $this->request = $context->getRequest();
- $this->response = $context->getResponse();
- $this->requestParameterHolder = $this->request->getParameterHolder();
- }
- abstract function execute($request);
- public function getModuleName()
- {
- return $this->moduleName;
- }
- public function getActionName()
- {
- return $this->actionName;
- }
- public final function getContext()
- {
- return $this->context;
- }
- public final function getLogger()
- {
- return $this->context->getLogger();
- }
- public function logMessage($message, $priority = 'info')
- {
- if (sfConfig::get('sf_logging_enabled'))
- {
- $this->dispatcher->notify(new sfEvent($this, 'application.log', array($message, 'priority' => constant('sfLogger::'.strtoupper($priority)))));
- }
- }
- public function debugMessage($message)
- {
- if (sfConfig::get('sf_web_debug') && sfConfig::get('sf_logging_enabled'))
- {
- $this->dispatcher->notify(new sfEvent(null, 'application.log', array('This function is deprecated in favor of the logMessage function.', 'priority' => sfLogger::ERR)));
- }
- }
- public function getRequestParameter($name, $default = null)
- {
- return $this->requestParameterHolder->get($name, $default);
- }
- public function hasRequestParameter($name)
- {
- return $this->requestParameterHolder->has($name);
- }
- public function getRequest()
- {
- return $this->request;
- }
- public function getResponse()
- {
- return $this->response;
- }
- public function getController()
- {
- return $this->context->getController();
- }
- public function generateUrl($route, $params = array(), $absolute = false)
- {
- return $this->context->getRouting()->generate($route, $params, $absolute);
- }
- public function getUser()
- {
- return $this->context->getUser();
- }
- public function setVar($name, $value, $safe = false)
- {
- $this->varHolder->set($name, $safe ? new sfOutputEscaperSafe($value) : $value);
- }
- public function getVar($name)
- {
- return $this->varHolder->get($name);
- }
- public function getVarHolder()
- {
- return $this->varHolder;
- }
- public function __set($key, $value)
- {
- return $this->varHolder->setByRef($key, $value);
- }
- public function & __get($key)
- {
- return $this->varHolder->get($key);
- }
- public function __isset($name)
- {
- return $this->varHolder->has($name);
- }
- public function __unset($name)
- {
- $this->varHolder->remove($name);
- }
- public function __call($method, $arguments)
- {
- $event = $this->dispatcher->notifyUntil(new sfEvent($this, 'component.method_not_found', array('method' => $method, 'arguments' => $arguments)));
- if (!$event->isProcessed())
- {
- throw new sfException(sprintf('Call to undefined method %s::%s.', get_class($this), $method));
- }
- return $event->getReturnValue();
- }
- }
- abstract class sfAction extends sfComponent
- {
- protected
- $security = array();
- public function initialize($context, $moduleName, $actionName)
- {
- parent::initialize($context, $moduleName, $actionName);
- if ($file = $context->getConfigCache()->checkConfig('modules/'.$this->getModuleName().'/config/security.yml', true))
- {
- require($file);
- }
- }
- public function preExecute()
- {
- }
- public function postExecute()
- {
- }
- public function forward404($message = null)
- {
- throw new sfError404Exception($this->get404Message($message));
- }
- public function forward404Unless($condition, $message = null)
- {
- if (!$condition)
- {
- throw new sfError404Exception($this->get404Message($message));
- }
- }
- public function forward404If($condition, $message = null)
- {
- if ($condition)
- {
- throw new sfError404Exception($this->get404Message($message));
- }
- }
- public function redirect404()
- {
- return $this->redirect('/'.sfConfig::get('sf_error_404_module').'/'.sfConfig::get('sf_error_404_action'));
- }
- public function forward($module, $action)
- {
- if (sfConfig::get('sf_logging_enabled'))
- {
- $this->dispatcher->notify(new sfEvent($this, 'application.log', array(sprintf('Forward to action "%s/%s"', $module, $action))));
- }
- $this->getController()->forward($module, $action);
- throw new sfStopException();
- }
- public function forwardIf($condition, $module, $action)
- {
- if ($condition)
- {
- $this->forward($module, $action);
- }
- }
- public function forwardUnless($condition, $module, $action)
- {
- if (!$condition)
- {
- $this->forward($module, $action);
- }
- }
- public function redirect($url, $statusCode = 302)
- {
- $this->getController()->redirect($url, 0, $statusCode);
- throw new sfStopException();
- }
- public function redirectIf($condition, $url, $statusCode = 302)
- {
- if ($condition)
- {
- $this->redirect($url, $statusCode);
- }
- }
- public function redirectUnless($condition, $url, $statusCode = 302)
- {
- if (!$condition)
- {
- $this->redirect($url, $statusCode);
- }
- }
- public function renderText($text)
- {
- $this->getResponse()->setContent($this->getResponse()->getContent().$text);
- return sfView::NONE;
- }
- public function getPartial($templateName, $vars = null)
- {
- $this->getContext()->getConfiguration()->loadHelpers('Partial');
- $vars = !is_null($vars) ? $vars : $this->varHolder->getAll();
- return get_partial($templateName, $vars);
- }
- public function renderPartial($templateName, $vars = null)
- {
- return $this->renderText($this->getPartial($templateName, $vars));
- }
- public function getComponent($moduleName, $componentName, $vars = null)
- {
- $this->getContext()->getConfiguration()->loadHelpers('Partial');
- $vars = !is_null($vars) ? $vars : $this->varHolder->getAll();
- return get_component($moduleName, $componentName, $vars);
- }
- public function renderComponent($moduleName, $componentName, $vars = null)
- {
- return $this->renderText($this->getComponent($moduleName, $componentName, $vars));
- }
- public function getDefaultView()
- {
- if (!sfConfig::get('sf_compat_10'))
- {
- throw new sfConfigurationException('You must set "compat_10" to true if you want to use this method which is deprecated.');
- }
- return sfView::INPUT;
- }
- public function handleError()
- {
- if (!sfConfig::get('sf_compat_10'))
- {
- throw new sfConfigurationException('You must set "compat_10" to true if you want to use this method which is deprecated.');
- }
- return sfView::ERROR;
- }
- public function validate()
- {
- if (!sfConfig::get('sf_compat_10'))
- {
- throw new sfConfigurationException('You must set "compat_10" to true if you want to use this method which is deprecated.');
- }
- return true;
- }
- public function getSecurityConfiguration()
- {
- return $this->security;
- }
- public function setSecurityConfiguration($security)
- {
- $this->security = $security;
- }
- public function isSecure()
- {
- $actionName = strtolower($this->getActionName());
- if (isset($this->security[$actionName]['is_secure']))
- {
- return $this->security[$actionName]['is_secure'];
- }
- if (isset($this->security['all']['is_secure']))
- {
- return $this->security['all']['is_secure'];
- }
- return false;
- }
- public function getCredential()
- {
- $actionName = strtolower($this->getActionName());
- if (isset($this->security[$actionName]['credentials']))
- {
- $credentials = $this->security[$actionName]['credentials'];
- }
- else if (isset($this->security['all']['credentials']))
- {
- $credentials = $this->security['all']['credentials'];
- }
- else
- {
- $credentials = null;
- }
- return $credentials;
- }
- public function setTemplate($name, $module = null)
- {
- if (sfConfig::get('sf_logging_enabled'))
- {
- $this->dispatcher->notify(new sfEvent($this, 'application.log', array(sprintf('Change template to "%s/%s"', is_null($module) ? 'CURRENT' : $module, $name))));
- }
- if (!is_null($module))
- {
- $name = sfConfig::get('sf_app_dir').'/modules/'.$module.'/templates/'.$name;
- }
- sfConfig::set('symfony.view.'.$this->getModuleName().'_'.$this->getActionName().'_template', $name);
- }
- public function getTemplate()
- {
- return sfConfig::get('symfony.view.'.$this->getModuleName().'_'.$this->getActionName().'_template');
- }
- public function setLayout($name)
- {
- if (sfConfig::get('sf_logging_enabled'))
- {
- $this->dispatcher->notify(new sfEvent($this, 'application.log', array(sprintf('Change layout to "%s"', $name))));
- }
- sfConfig::set('symfony.view.'.$this->getModuleName().'_'.$this->getActionName().'_layout', $name);
- }
- public function getLayout()
- {
- return sfConfig::get('symfony.view.'.$this->getModuleName().'_'.$this->getActionName().'_layout');
- }
- public function setViewClass($class)
- {
- sfConfig::set('mod_'.strtolower($this->getModuleName()).'_view_class', $class);
- }
- public function getRoute()
- {
- return $this->getRequest()->getAttribute('sf_route');
- }
- protected function get404Message($message = null)
- {
- return is_null($message) ? sprintf('This request has been forwarded to a 404 error page by the action "%s/%s".', $this->getModuleName(), $this->getActionName()) : $message;
- }
- }
- abstract class sfActions extends sfAction
- {
- public function execute($request)
- {
- $actionToRun = 'execute'.ucfirst($this->getActionName());
- if ($actionToRun === 'execute')
- {
- throw new sfInitializationException(sprintf('sfAction initialization failed for module "%s". There was no action given.', $this->getModuleName()));
- }
- if (!is_callable(array($this, $actionToRun)))
- {
- throw new sfInitializationException(sprintf('sfAction initialization failed for module "%s", action "%s". You must create a "%s" method.', $this->getModuleName(), $this->getActionName(), $actionToRun));
- }
- if (sfConfig::get('sf_logging_enabled'))
- {
- $this->dispatcher->notify(new sfEvent($this, 'application.log', array(sprintf('Call "%s->%s()"', get_class($this), $actionToRun))));
- }
- return $this->$actionToRun($request);
- }
- }
- class sfActionStack
- {
- protected
- $stack = array();
- public function addEntry($moduleName, $actionName, $actionInstance)
- {
- $actionEntry = new sfActionStackEntry($moduleName, $actionName, $actionInstance);
- $this->stack[] = $actionEntry;
- return $actionEntry;
- }
- public function getEntry($index)
- {
- $retval = null;
- if ($index > -1 && $index < count($this->stack))
- {
- $retval = $this->stack[$index];
- }
- return $retval;
- }
- public function popEntry()
- {
- return array_pop($this->stack);
- }
- public function getFirstEntry()
- {
- $retval = null;
- if (isset($this->stack[0]))
- {
- $retval = $this->stack[0];
- }
- return $retval;
- }
- public function getLastEntry()
- {
- $count = count($this->stack);
- $retval = null;
- if (isset($this->stack[0]))
- {
- $retval = $this->stack[$count - 1];
- }
- return $retval;
- }
- public function getSize()
- {
- return count($this->stack);
- }
- }
- class sfActionStackEntry
- {
- protected
- $actionInstance = null,
- $actionName = null,
- $moduleName = null,
- $presentation = null;
- public function __construct($moduleName, $actionName, $actionInstance)
- {
- $this->actionName = $actionName;
- $this->actionInstance = $actionInstance;
- $this->moduleName = $moduleName;
- }
- public function getActionName()
- {
- return $this->actionName;
- }
- public function getActionInstance()
- {
- return $this->actionInstance;
- }
- public function getModuleName()
- {
- return $this->moduleName;
- }
- public function & getPresentation()
- {
- return $this->presentation;
- }
- public function setPresentation(&$presentation)
- {
- $this->presentation =& $presentation;
- }
- }
- class sfLoader
- {
- static public function getHelperDirs($moduleName = '')
- {
- $configuration = sfProjectConfiguration::getActive();
- $configuration->getEventDispatcher()->notify(new sfEvent(null, 'application.log', array('The sfLoader::getHelperDirs() method is deprecated. Please use the same method from sfApplicationConfiguration.', 'priority' => sfLogger::ERR)));
- return $configuration->getHelperDirs($moduleName);
- }
- static public function loadHelpers($helpers, $moduleName = '')
- {
- $configuration = sfProjectConfiguration::getActive();
- $configuration->getEventDispatcher()->notify(new sfEvent(null, 'application.log', array('The sfLoader::loadHelpers() method is deprecated. Please use the same method from sfApplicationConfiguration.', 'priority' => sfLogger::ERR)));
- return $configuration->loadHelpers($helpers, $moduleName);
- }
- }
- abstract class sfController
- {
- protected
- $context = null,
- $dispatcher = null,
- $controllerClasses = array(),
- $maxForwards = 5,
- $renderMode = sfView::RENDER_CLIENT;
- public function __construct($context)
- {
- $this->initialize($context);
- }
- public function initialize($context)
- {
- $this->context = $context;
- $this->dispatcher = $context->getEventDispatcher();
- $this->maxForwards = sfConfig::get('sf_max_forwards', $this->maxForwards);
- }
- public function componentExists($moduleName, $componentName)
- {
- return $this->controllerExists($moduleName, $componentName, 'component', false);
- }
- public function actionExists($moduleName, $actionName)
- {
- return $this->controllerExists($moduleName, $actionName, 'action', false);
- }
- protected function controllerExists($moduleName, $controllerName, $extension, $throwExceptions)
- {
- $dirs = $this->context->getConfiguration()->getControllerDirs($moduleName);
- foreach ($dirs as $dir => $checkEnabled)
- {
- if ($checkEnabled && !in_array($moduleName, sfConfig::get('sf_enabled_modules')) && is_readable($dir))
- {
- throw new sfConfigurationException(sprintf('The module "%s" is not enabled.', $moduleName));
- }
- $classFile = strtolower($extension);
- $classSuffix = ucfirst(strtolower($extension));
- $file = $dir.'/'.$controllerName.$classSuffix.'.class.php';
- if (is_readable($file))
- {
- require_once($file);
- $this->controllerClasses[$moduleName.'_'.$controllerName.'_'.$classSuffix] = $controllerName.$classSuffix;
- return true;
- }
- $module_file = $dir.'/'.$classFile.'s.class.php';
- if (is_readable($module_file))
- {
- require_once($module_file);
- if (!class_exists($moduleName.$classSuffix.'s', false))
- {
- if ($throwExceptions)
- {
- throw new sfControllerException(sprintf('There is no "%s" class in your action file "%s".', $moduleName.$classSuffix.'s', $module_file));
- }
- return false;
- }
- if (!in_array('execute'.ucfirst($controllerName), get_class_methods($moduleName.$classSuffix.'s')))
- {
- if ($throwExceptions)
- {
- throw new sfControllerException(sprintf('There is no "%s" method in your action class "%s".', 'execute'.ucfirst($controllerName), $moduleName.$classSuffix.'s'));
- }
- return false;
- }
- $this->controllerClasses[$moduleName.'_'.$controllerName.'_'.$classSuffix] = $moduleName.$classSuffix.'s';
- return true;
- }
- }
- if ($throwExceptions && sfConfig::get('sf_debug'))
- {
- $dirs = array_keys($dirs);
- foreach ($dirs as &$dir)
- {
- $dir = str_replace(sfConfig::get('sf_root_dir'), '%SF_ROOT_DIR%', $dir);
- }
- throw new sfControllerException(sprintf('Controller "%s/%s" does not exist in: %s.', $moduleName, $controllerName, implode(', ', $dirs)));
- }
- return false;
- }
- 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(sprintf('Too many forwards have been detected for this request (> %d).', $this->maxForwards));
- }
- $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);
- require($this->context->getConfigCache()->checkConfig('modules/'.$moduleName.'/config/module.yml'));
- 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));
- }
- 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);
- }
- }
- public function getAction($moduleName, $actionName)
- {
- return $this->getController($moduleName, $actionName, 'action');
- }
- public function getComponent($moduleName, $componentName)
- {
- return $this->getController($moduleName, $componentName, 'component');
- }
- protected function getController($moduleName, $controllerName, $extension)
- {
- $classSuffix = ucfirst(strtolower($extension));
- if (!isset($this->controllerClasses[$moduleName.'_'.$controllerName.'_'.$classSuffix]))
- {
- $this->controllerExists($moduleName, $controllerName, $extension, true);
- }
- $class = $this->controllerClasses[$moduleName.'_'.$controllerName.'_'.$classSuffix];
- $moduleClass = $moduleName.'_'.$class;
- if (class_exists($moduleClass, false))
- {
- $class = $moduleClass;
- }
- return new $class($this->context, $moduleName, $controllerName);
- }
- public function getActionStack()
- {
- return $this->context->getActionStack();
- }
- public function getRenderMode()
- {
- return $this->renderMode;
- }
- public function getView($moduleName, $actionName, $viewName)
- {
- $file = sfConfig::get('sf_app_module_dir').'/'.$moduleName.'/view/'.$actionName.$viewName.'View.class.php';
- if (is_readable($file))
- {
- require_once($file);
- $class = $actionName.$viewName.'View';
- $moduleClass = $moduleName.'_'.$class;
- if (class_exists($moduleClass, false))
- {
- $class = $moduleClass;
- }
- }
- else
- {
- $class = sfConfig::get('mod_'.strtolower($moduleName).'_view_class', 'sfPHP').'View';
- }
- return new $class($this->context, $moduleName, $actionName, $viewName);
- }
- public function sendEmail($module, $action)
- {
- if (sfConfig::get('sf_logging_enabled'))
- {
- $this->dispatcher->notify(new sfEvent($this, 'application.log', array('sendEmail method is deprecated', 'priority' => sfLogger::ERR)));
- }
- return $this->getPresentationFor($module, $action, 'sfMail');
- }
- public function getPresentationFor($module, $action, $viewName = null)
- {
- if (sfConfig::get('sf_logging_enabled'))
- {
- $this->dispatcher->notify(new sfEvent($this, 'application.log', array(sprintf('Get presentation for action "%s/%s" (view class: "%s")', $module, $action, $viewName))));
- }
- $renderMode = $this->getRenderMode();
- $this->setRenderMode(sfView::RENDER_VAR);
- $actionStack = $this->getActionStack();
- $index = $actionStack->getSize();
- if ($viewName)
- {
- $currentViewName = sfConfig::get('mod_'.strtolower($module).'_view_class');
- sfConfig::set('mod_'.strtolower($module).'_view_class', $viewName);
- }
- try
- {
- $this->forward($module, $action);
- }
- catch (Exception $e)
- {
- $this->setRenderMode($renderMode);
- if ($viewName)
- {
- sfConfig::set('mod_'.strtolower($module).'_view_class', $currentViewName);
- }
- throw $e;
- }
- $actionEntry = $actionStack->getEntry($index);
- $presentation =& $actionEntry->getPresentation();
- $this->setRenderMode($renderMode);
- $nb = $actionStack->getSize() - $index;
- while ($nb-- > 0)
- {
- $actionEntry = $actionStack->popEntry();
- if ($actionEntry->getModuleName() == sfConfig::get('sf_login_module') && $actionEntry->getActionName() == sfConfig::get('sf_login_action'))
- {
- throw new sfException('Your action is secured, but the user is not authenticated.');
- }
- else if ($actionEntry->getModuleName() == sfConfig::get('sf_secure_module') && $actionEntry->getActionName() == sfConfig::get('sf_secure_action'))
- {
- throw new sfException('Your action is secured, but the user does not have access.');
- }
- }
- if ($viewName)
- {
- sfConfig::set('mod_'.strtolower($module).'_view_class', $currentViewName);
- }
- return $presentation;
- }
- public function setRenderMode($mode)
- {
- if ($mode == sfView::RENDER_CLIENT || $mode == sfView::RENDER_VAR || $mode == sfView::RENDER_NONE)
- {
- $this->renderMode = $mode;
- return;
- }
- throw new sfRenderException(sprintf('Invalid rendering mode: %s.', $mode));
- }
- public function inCLI()
- {
- return 0 == strncasecmp(PHP_SAPI, 'cli', 3);
- }
- public function __call($method, $arguments)
- {
- $event = $this->dispatcher->notifyUntil(new sfEvent($this, 'controller.method_not_found', array('method' => $method, 'arguments' => $arguments)));
- if (!$event->isProcessed())
- {
- throw new sfException(sprintf('Call to undefined method %s::%s.', get_class($this), $method));
- }
- return $event->getReturnValue();
- }
- }
- class sfDatabaseManager
- {
- protected
- $configuration = null,
- $databases = array();
- public function __construct(sfProjectConfiguration $configuration, $options = array())
- {
- $this->initialize($configuration);
- if (!isset($options['auto_shutdown']) || $options['auto_shutdown'])
- {
- register_shutdown_function(array($this, 'shutdown'));
- }
- }
- public function initialize(sfProjectConfiguration $configuration)
- {
- $this->configuration = $configuration;
- $this->loadConfiguration();
- }
- public function loadConfiguration()
- {
- if ($this->configuration instanceof sfApplicationConfiguration)
- {
- $databases = include($this->configuration->getConfigCache()->checkConfig('config/databases.yml'));
- }
- else
- {
- $configHandler = new sfDatabaseConfigHandler();
- $databases = $configHandler->evaluate(array($this->configuration->getRootDir().'/config/databases.yml'));
- }
- foreach ($databases as $name => $database)
- {
- $this->setDatabase($name, $database);
- }
- }
- public function setDatabase($name, sfDatabase $database)
- {
- $this->databases[$name] = $database;
- }
- public function getDatabase($name = 'default')
- {
- if (isset($this->databases[$name]))
- {
- return $this->databases[$name];
- }
- throw new sfDatabaseException(sprintf('Database "%s" does not exist.', $name));
- }
- public function getNames()
- {
- return array_keys($this->databases);
- }
- public function shutdown()
- {
- foreach ($this->databases as $database)
- {
- $database->shutdown();
- }
- }
- }
- class sfEvent implements ArrayAccess
- {
- protected
- $value = null,
- $processed = false,
- $subject = null,
- $name = '',
- $parameters = null;
- public function __construct($subject, $name, $parameters = array())
- {
- $this->subject = $subject;
- $this->name = $name;
- $this->parameters = $parameters;
- }
- public function getSubject()
- {
- return $this->subject;
- }
- public function getName()
- {
- return $this->name;
- }
- public function setReturnValue($value)
- {
- $this->value = $value;
- }
- public function getReturnValue()
- {
- return $this->value;
- }
- public function setProcessed($processed)
- {
- $this->processed = (boolean) $processed;
- }
- public function isProcessed()
- {
- return $this->processed;
- }
- public function getParameters()
- {
- return $this->parameters;
- }
- public function offsetExists($name)
- {
- return array_key_exists($name, $this->parameters);
- }
- public function offsetGet($name)
- {
- if (!array_key_exists($name, $this->parameters))
- {
- throw new InvalidArgumentException(sprintf('The event "%s" has no "%s" parameter.', $this->name, $name));
- }
- return $this->parameters[$name];
- }
- public function offsetSet($name, $value)
- {
- $this->parameters[$name] = $value;
- }
- public function offsetUnset($name)
- {
- unset($this->parameters[$name]);
- }
- }
- abstract class sfFilter
- {
- protected
- $parameterHolder = null,
- $context = null;
- public static
- $filterCalled = array();
- public function __construct($context, $parameters = array())
- {
- $this->initialize($context, $parameters);
- }
- public function initialize($context, $parameters = array())
- {
- $this->context = $context;
- $this->parameterHolder = new sfParameterHolder();
- $this->parameterHolder->add($parameters);
- return true;
- }
- protected function isFirstCall()
- {
- $class = get_class($this);
- if (isset(self::$filterCalled[$class]))
- {
- return false;
- }
- else
- {
- self::$filterCalled[$class] = true;
- return true;
- }
- }
- public final function getContext()
- {
- return $this->context;
- }
- public function getParameterHolder()
- {
- return $this->parameterHolder;
- }
- public function getParameter($name, $default = null)
- {
- return $this->parameterHolder->get($name, $default);
- }
- public function hasParameter($name)
- {
- return $this->parameterHolder->has($name);
- }
- public function setParameter($name, $value)
- {
- return $this->parameterHolder->set($name, $value);
- }
- }
- class sfCommonFilter extends sfFilter
- {
- public function execute($filterChain)
- {
- $filterChain->execute();
- $response = $this->context->getResponse();
- $content = $response->getContent();
- if (false !== ($pos = strpos($content, '</head>')))
- {
- $this->context->getConfiguration()->loadHelpers(array('Tag', 'Asset'));
- $html = '';
- if (!sfConfig::get('symfony.asset.javascripts_included', false))
- {
- $html .= get_javascripts($response);
- }
- if (!sfConfig::get('symfony.asset.stylesheets_included', false))
- {
- $html .= get_stylesheets($response);
- }
- if ($html)
- {
- $response->setContent(substr($content, 0, $pos).$html.substr($content, $pos));
- }
- }
- sfConfig::set('symfony.asset.javascripts_included', false);
- sfConfig::set('symfony.asset.stylesheets_included', false);
- }
- }
- class sfExecutionFilter extends sfFilter
- {
- public function execute($filterChain)
- {
- $actionInstance = $this->context->getController()->getActionStack()->getLastEntry()->getActionInstance();
- if (sfConfig::get('sf_debug') && sfConfig::get('sf_logging_enabled'))
- {
- $timer = sfTimerManager::getTimer(sprintf('Action "%s/%s"', $actionInstance->getModuleName(), $actionInstance->getActionName()));
- $viewName = $this->handleAction($filterChain, $actionInstance);
- $timer->addTime();
- $timer = sfTimerManager::getTimer(sprintf('View "%s" for "%s/%s"', $viewName, $actionInstance->getModuleName(), $actionInstance->getActionName()));
- $this->handleView($filterChain, $actionInstance, $viewName);
- $timer->addTime();
- }
- else
- {
- $viewName = $this->handleAction($filterChain, $actionInstance);
- $this->handleView($filterChain, $actionInstance, $viewName);
- }
- }
- protected function handleAction($filterChain, $actionInstance)
- {
- $uri = $this->context->getRouting()->getCurrentInternalUri();
- if (sfConfig::get('sf_cache') && !is_null($uri) && $this->context->getViewCacheManager()->hasActionCache($uri))
- {
- return sfView::SUCCESS;
- }
- return $this->executeAction($actionInstance);
- }
- protected function executeAction($actionInstance)
- {
- $actionInstance->preExecute();
- $viewName = $actionInstance->execute($this->context->getRequest());
- $actionInstance->postExecute();
- return is_null($viewName) ? sfView::SUCCESS : $viewName;
- }
- protected function handleView($filterChain, $actionInstance, $viewName)
- {
- switch ($viewName)
- {
- case sfView::HEADER_ONLY:
- $this->context->getResponse()->setHeaderOnly(true);
- return;
- case sfView::NONE:
- return;
- }
- $this->executeView($actionInstance->getModuleName(), $actionInstance->getActionName(), $viewName, $actionInstance->getVarHolder()->getAll());
- }
- protected function executeView($moduleName, $actionName, $viewName, $viewAttributes)
- {
- $controller = $this->context->getController();
- $view = $controller->getView($moduleName, $actionName, $viewName);
- $view->execute();
- $view->getAttributeHolder()->add($viewAttributes);
- switch ($controller->getRenderMode())
- {
- case sfView::RENDER_NONE:
- break;
- case sfView::RENDER_CLIENT:
- $viewData = $view->render();
- $this->context->getResponse()->setContent($viewData);
- break;
- case sfView::RENDER_VAR:
- $viewData = $view->render();
- $controller->getActionStack()->getLastEntry()->setPresentation($viewData);
- break;
- }
- }
- }
- class sfRenderingFilter extends sfFilter
- {
- public function execute($filterChain)
- {
- $filterChain->execute();
- $response = $this->context->getResponse();
- if (sfForm::hasToStringException())
- {
- throw sfForm::getToStringException();
- }
- else if (sfFormField::hasToStringException())
- {
- throw sfFormField::getToStringException();
- }
- $response->send();
- }
- }
- class sfFilterChain
- {
- protected
- $chain = array(),
- $index = -1;
- public function loadConfiguration($actionInstance)
- {
- require(sfContext::getInstance()->getConfigCache()->checkConfig('modules/'.$actionInstance->getModuleName().'/config/filters.yml'));
- }
- public function execute()
- {
- ++$this->index;
- if ($this->index < count($this->chain))
- {
- if (sfConfig::get('sf_logging_enabled'))
- {
- sfContext::getInstance()->getEventDispatcher()->notify(new sfEvent($this, 'application.log', array(sprintf('Executing filter "%s"', get_class($this->chain[$this->index])))));
- }
- $this->chain[$this->index]->execute($this);
- }
- }
- public function hasFilter($class)
- {
- foreach ($this->chain as $filter)
- {
- if ($filter instanceof $class)
- {
- return true;
- }
- }
- return false;
- }
- public function register($filter)
- {
- $this->chain[] = $filter;
- }
- }
- abstract class sfLogger
- {
- const EMERG = 0; const ALERT = 1; const CRIT = 2; const ERR = 3; const WARNING = 4; const NOTICE = 5; const INFO = 6; const DEBUG = 7;
- protected
- $level = self::INFO;
- public function __construct(sfEventDispatcher $dispatcher, $options = array())
- {
- $this->initialize($dispatcher, $options);
- if (!isset($options['auto_shutdown']) || $options['auto_shutdown'])
- {
- register_shutdown_function(array($this, 'shutdown'));
- }
- }
- public function initialize(sfEventDispatcher $dispatcher, $options = array())
- {
- if (isset($options['level']))
- {
- $this->setLogLevel($options['level']);
- }
- $dispatcher->connect('application.log', array($this, 'listenToLogEvent'));
- }
- public function getLogLevel()
- {
- return $this->level;
- }
- public function setLogLevel($level)
- {
- if (!is_int($level))
- {
- $level = constant('sfLogger::'.strtoupper($level));
- }
- $this->level = $level;
- }
- public function log($message, $priority = self::INFO)
- {
- if ($this->getLogLevel() < $priority)
- {
- return false;
- }
- return $this->doLog($message, $priority);
- }
- abstract protected function doLog($message, $priority);
- public function emerg($message)
- {
- $this->log($message, self::EMERG);
- }
- public function alert($message)
- {
- $this->log($message, self::ALERT);
- }
- public function crit($message)
- {
- $this->log($message, self::CRIT);
- }
- public function err($message)
- {
- $this->log($message, self::ERR);
- }
- public function warning($message)
- {
- $this->log($message, self::WARNING);
- }
- public function notice($message)
- {
- $this->log($message, self::NOTICE);
- }
- public function info($message)
- {
- $this->log($message, self::INFO);
- }
- public function debug($message)
- {
- $this->log($message, self::DEBUG);
- }
- public function listenToLogEvent(sfEvent $event)
- {
- $priority = isset($event['priority']) ? $event['priority'] : self::INFO;
- $subject = $event->getSubject();
- $subject = is_object($subject) ? get_class($subject) : (is_string($subject) ? $subject : 'main');
- foreach ($event->getParameters() as $key => $message)
- {
- if ('priority' === $key)
- {
- continue;
- }
- $this->log(sprintf('{%s} %s', $subject, $message), $priority);
- }
- }
- public function shutdown()
- {
- }
- static public function getPriorityName($priority)
- {
- static $levels = array(
- self::EMERG => 'emerg',
- self::ALERT => 'alert',
- self::CRIT => 'crit',
- self::ERR => 'err',
- self::WARNING => 'warning',
- self::NOTICE => 'notice',
- self::INFO => 'info',
- self::DEBUG => 'debug',
- );
- if (!isset($levels[$priority]))
- {
- throw new sfException(sprintf('The priority level "%s" does not exist.', $priority));
- }
- return $levels[$priority];
- }
- }
- class sfNoLogger extends sfLogger
- {
- public function initialize(sfEventDispatcher $dispatcher, $options = array())
- {
- }
- protected function doLog($message, $priority)
- {
- }
- }
- abstract class sfRequest
- {
- const GET = 'GET';
- const POST = 'POST';
- const PUT = 'PUT';
- const DELETE = 'DELETE';
- const HEAD = 'HEAD';
- protected
- $dispatcher = null,
- $method = null,
- $options = array(),
- $parameterHolder = null,
- $attributeHolder = null;
- public function __construct(sfEventDispatcher $dispatcher, $parameters = array(), $attributes = array(), $options = array())
- {
- $this->initialize($dispatcher, $parameters, $attributes, $options);
- }
- public function initialize(sfEventDispatcher $dispatcher, $parameters = array(), $attributes = array(), $options = array())
- {
- $this->dispatcher = $dispatcher;
- $this->options = $options;
- if (!isset($this->options['logging']))
- {
- $this->options['logging'] = false;
- }
- $this->parameterHolder = new sfParameterHolder();
- $this->attributeHolder = new sfParameterHolder();
- $this->parameterHolder->add($parameters);
- $this->attributeHolder->add($attributes);
- }
- public function extractParameters($names)
- {
- $array = array();
- $parameters = $this->parameterHolder->getAll();
- foreach ($parameters as $key => $value)
- {
- if (in_array($key, $names))
- {
- $array[$key] = $value;
- }
- }
- return $array;
- }
- public function getMethod()
- {
- return $this->method;
- }
- public function setMethod($method)
- {
- if (!in_array(strtoupper($method), array(self::GET, self::POST, self::PUT, self::DELETE, self::HEAD)))
- {
- throw new sfException(sprintf('Invalid request method: %s.', $method));
- }
- $this->method = strtoupper($method);
- }
- public function getParameterHolder()
- {
- return $this->parameterHolder;
- }
- public function getAttributeHolder()
- {
- return $this->attributeHolder;
- }
- public function getAttribute($name, $default = null)
- {
- return $this->attributeHolder->get($name, $default);
- }
- public function hasAttribute($name)
- {
- return $this->attributeHolder->has($name);
- }
- public function setAttribute($name, $value)
- {
- $this->attributeHolder->set($name, $value);
- }
- public function getParameter($name, $default = null)
- {
- return $this->parameterHolder->get($name, $default);
- }
- public function hasParameter($name)
- {
- return $this->parameterHolder->has($name);
- }
- public function setParameter($name, $value)
- {
- $this->parameterHolder->set($name, $value);
- }
- public function __call($method, $arguments)
- {
- $event = $this->dispatcher->notifyUntil(new sfEvent($this, 'request.method_not_found', array('method' => $method, 'arguments' => $arguments)));
- if (!$event->isProcessed())
- {
- throw new sfException(sprintf('Call to undefined method %s::%s.', get_class($this), $method));
- }
- return $event->getReturnValue();
- }
- public function __clone()
- {
- $this->parameterHolder = clone $this->parameterHolder;
- $this->attributeHolder = clone $this->attributeHolder;
- }
- }
- abstract class sfResponse implements Serializable
- {
- protected
- $options = array(),
- $dispatcher = null,
- $content = '';
- public function __construct(sfEventDispatcher $dispatcher, $options = array())
- {
- $this->initialize($dispatcher, $options);
- }
- public function initialize(sfEventDispatcher $dispatcher, $options = array())
- {
- $this->dispatcher = $dispatcher;
- $this->options = $options;
- if (!isset($this->options['logging']))
- {
- $this->options['logging'] = false;
- }
- }
- public function setEventDispatcher(sfEventDispatcher $dispatcher)
- {
- $this->dispatcher = $dispatcher;
- }
- public function setContent($content)
- {
- $this->content = $content;
- }
- public function getContent()
- {
- return $this->content;
- }
- public function sendContent()
- {
- $event = $this->dispatcher->filter(new sfEvent($this, 'response.filter_content'), $this->getContent());
- $content = $event->getReturnValue();
- if ($this->options['logging'])
- {
- $this->dispatcher->notify(new sfEvent($this, 'application.log', array(sprintf('Send content (%s o)', strlen($content)))));
- }
- echo $content;
- }
- public function send()
- {
- $this->sendContent();
- }
- public function getOptions()
- {
- return $this->options;
- }
- public function __call($method, $arguments)
- {
- $event = $this->dispatcher->notifyUntil(new sfEvent($this, 'response.method_not_found', array('method' => $method, 'arguments' => $arguments)));
- if (!$event->isProcessed())
- {
- throw new sfException(sprintf('Call to undefined method %s::%s.', get_class($this), $method));
- }
- return $event->getReturnValue();
- }
- public function serialize()
- {
- return serialize($this->content);
- }
- public function unserialize($serialized)
- {
- $this->content = unserialize($serialized);
- }
- }
- abstract class sfRouting
- {
- protected
- $dispatcher = null,
- $cache = null,
- $defaultParameters = array(),
- $options = array();
- public function __construct(sfEventDispatcher $dispatcher, sfCache $cache = null, $options = array())
- {
- $this->initialize($dispatcher, $cache, $options);
- if (!isset($this->options['auto_shutdown']) || $this->options['auto_shutdown'])
- {
- register_shutdown_function(array($this, 'shutdown'));
- }
- }
- public function getCache()
- {
- return $this->cache;
- }
- public function initialize(sfEventDispatcher $dispatcher, sfCache $cache = null, $options = array())
- {
- $this->dispatcher = $dispatcher;
- $options['debug'] = isset($options['debug']) ? (boolean) $options['debug'] : false;
- $this->cache = $options['debug'] ? null : $cache;
- $this->setDefaultParameter('module', isset($options['default_module']) ? $options['default_module'] : 'default');
- $this->setDefaultParameter('action', isset($options['default_action']) ? $options['default_action'] : 'index');
- if (!isset($options['logging']))
- {
- $options['logging'] = false;
- }
- if (!isset($options['context']))
- {
- $options['context'] = array();
- }
- $this->options = $options;
- $this->dispatcher->connect('user.change_culture', array($this, 'listenToChangeCultureEvent'));
- $this->dispatcher->connect('request.filter_parameters', array($this, 'filterParametersEvent'));
- $this->loadConfiguration();
- }
- public function getOptions()
- {
- return $this->options;
- }
- public function loadConfiguration()
- {
- $this->dispatcher->notify(new sfEvent($this, 'routing.load_configuration'));
- }
- abstract public function getCurrentInternalUri($with_route_name = false);
- abstract public function getRoutes();
- abstract public function setRoutes($routes);
- abstract public function hasRoutes();
- abstract public function clearRoutes();
- abstract public function generate($name, $params = array(), $absolute = false);
- abstract public function parse($url);
- public function getDefaultParameters()
- {
- return $this->defaultParameters;
- }
- public function getDefaultParameter($key)
- {
- return isset($this->defaultParameters[$key]) ? $this->defaultParameters[$key] : null;
- }
- public function setDefaultParameter($key, $value)
- {
- $this->defaultParameters[$key] = $value;
- }
- public function setDefaultParameters($parameters)
- {
- $this->defaultParameters = $parameters;
- }
- protected function mergeArrays($arr1, $arr2)
- {
- foreach ($arr2 as $key => $value)
- {
- $arr1[$key] = $value;
- }
- return $arr1;
- }
- public function listenToChangeCultureEvent(sfEvent $event)
- {
- $this->setDefaultParameter('sf_culture', $event['culture']);
- }
- public function filterParametersEvent(sfEvent $event, $parameters)
- {
- $context = $event->getParameters();
- $this->options['context'] = $context;
- if (false === $params = $this->parse($event['path_info']))
- {
- return $parameters;
- }
- return array_merge($parameters, $params);
- }
- protected function fixGeneratedUrl($url, $absolute = false)
- {
- if (isset($this->options['context']['prefix']))
- {
- if (0 === strpos($url, 'http'))
- {
- $url = preg_replace('#https?\://[^/]+#', '$0'.$this->options['context']['prefix'], $url);
- }
- else
- {
- $url = $this->options['context']['prefix'].$url;
- }
- }
- if ($absolute && isset($this->options['context']['host']) && 0 !== strpos($url, 'http'))
- {
- $url = 'http'.(isset($this->options['context']['is_secure']) && $this->options['context']['is_secure'] ? 's' : '').'://'.$this->options['context']['host'].$url;
- }
- return $url;
- }
- public function shutdown()
- {
- }
- }
- abstract class sfStorage
- {
- protected
- $options = array();
- public function __construct($options = array())
- {
- $this->initialize($options);
- if ($this->options['auto_shutdown'])
- {
- register_shutdown_function(array($this, 'shutdown'));
- }
- }
- public function initialize($options = array())
- {
- $this->options = array_merge(array(
- 'auto_shutdown' => true,
- ), $options);
- }
- public function getOptions()
- {
- return $this->options;
- }
- abstract public function read($key);
- abstract public function regenerate($destroy = false);
- abstract public function remove($key);
- abstract public function shutdown();
- abstract public function write($key, $data);
- }
- class sfUser
- {
- const ATTRIBUTE_NAMESPACE = 'symfony/user/sfUser/attributes';
- const CULTURE_NAMESPACE = 'symfony/user/sfUser/culture';
- protected
- $options = array(),
- $attributeHolder = null,
- $culture = null,
- $storage = null,
- $dispatcher = null;
- public function __construct(sfEventDispatcher $dispatcher, sfStorage $storage, $options = array())
- {
- $this->initialize($dispatcher, $storage, $options);
- if ($this->options['auto_shutdown'])
- {
- register_shutdown_function(array($this, 'shutdown'));
- }
- }
- public function initialize(sfEventDispatcher $dispatcher, sfStorage $storage, $options = array())
- {
- $this->dispatcher = $dispatcher;
- $this->storage = $storage;
- $this->options = array_merge(array(
- 'auto_shutdown' => true,
- 'culture' => null,
- 'default_culture' => 'en',
- 'use_flash' => false,
- 'logging' => false,
- ), $options);
- $this->attributeHolder = new sfNamespacedParameterHolder(self::ATTRIBUTE_NAMESPACE);
- $attributes = $storage->read(self::ATTRIBUTE_NAMESPACE);
- if (is_array($attributes))
- {
- foreach ($attributes as $namespace => $values)
- {
- $this->attributeHolder->add($values, $namespace);
- }
- }
- $currentCulture = $storage->read(self::CULTURE_NAMESPACE);
- $this->setCulture(!is_null($this->options['culture']) ? $this->options['culture'…
Large files files are truncated, but you can click here to view the full file