Retrieve the controller.
public getController ( ) : sfController | ||
return | sfController | The current sfController implementation instance. |
/** * Initializes the cache manager. * * @param sfContext $context Current application context * @param sfCache $cache An sfCache instance */ public function initialize($context, sfCache $cache) { $this->context = $context; $this->dispatcher = $context->getEventDispatcher(); $this->controller = $context->getController(); // empty configuration $this->cacheConfig = array(); // cache instance $this->cache = $cache; // routing instance $this->routing = $context->getRouting(); }
/** * Initializes the cache manager. * * @param sfContext $context Current application context * @param sfCache $cache An sfCache instance */ public function initialize($context, sfCache $cache) { $this->context = $context; $this->dispatcher = $context->getEventDispatcher(); $this->controller = $context->getController(); if (sfConfig::get('sf_web_debug')) { $this->dispatcher->connect('view.cache.filter_content', array($this, 'decorateContentWithDebug')); } // empty configuration $this->cacheConfig = array(); // cache instance $this->cache = $cache; // routing instance $this->routing = $context->getRouting(); }
/** * Initializes the cache manager. * * @param sfContext $context Current application context * @param sfCache $cache An sfCache instance */ public function initialize($context, sfCache $cache, $options = array()) { $this->context = $context; $this->dispatcher = $context->getEventDispatcher(); $this->controller = $context->getController(); $this->request = $context->getRequest(); $this->options = array_merge(array('cache_key_use_vary_headers' => true, 'cache_key_use_host_name' => true), $options); if (sfConfig::get('sf_web_debug')) { $this->dispatcher->connect('view.cache.filter_content', array($this, 'decorateContentWithDebug')); } // empty configuration $this->cacheConfig = array(); // cache instance $this->cache = $cache; // routing instance $this->routing = $context->getRouting(); }
public function getPathAfterLoggingIn(sfContext $context) { $logger = Logger::getLogger('core.homepageservice'); $redirectToReferer = true; $request = $context->getRequest(); $referer = $request->getReferer(); $host = $request->getHost(); // get base url: ie something like: http://host:port/symfony/web/index.php $baseUrl = $request->getUriPrefix() . $request->getPathInfoPrefix(); if ($logger->isDebugEnabled()) { $logger->debug("referer: {$referer}, host: {$host}, base url: {$baseUrl}"); } if (strpos($referer, $this->loginPath)) { // Check whether referer is login page $redirectToReferer = false; if ($logger->isDebugEnabled()) { $logger->debug("referrer is the login page. Skipping redirect:" . $this->loginPath); } } elseif (strpos($referer, $this->validatePath)) { // Check whether referer is validate action $redirectToReferer = false; if ($logger->isDebugEnabled()) { $logger->debug("referrer is the validate action. Skipping redirect:" . $this->validatePath); } } else { if (false === strpos($referer, $baseUrl)) { // Check whether from same host $redirectToReferer = false; if ($logger->isDebugEnabled()) { $logger->debug("referrer does not have same base url. Skipping redirect"); } } } /* * Try to get action and module, skip redirecting to referrer and show homepage if: * 1) Action is not secure (probably a login related url we should not redirect to) * 2) Action is not accessible to current user. */ if ($redirectToReferer) { try { $moduleAndAction = str_replace($baseUrl, '', $referer); if ($logger->isDebugEnabled()) { $logger->debug('referrer module and action: ' . $moduleAndAction); } $params = $context->getRouting()->parse($moduleAndAction); if ($params && isset($params['module']) && isset($params['action'])) { $moduleName = $params['module']; $actionName = $params['action']; if ($logger->isDebugEnabled()) { $logger->debug("module: {$moduleName}, action: {$actionName}"); } if ($context->getController()->actionExists($moduleName, $actionName)) { $action = $context->getController()->getAction($moduleName, $actionName); if ($action instanceof sfAction) { if ($action->isSecure()) { $permissions = UserRoleManagerFactory::getUserRoleManager()->getScreenPermissions($moduleName, $actionName); if ($permissions instanceof ResourcePermission) { if ($permissions->canRead()) { return $referer; } } else { $logger->debug("action does not exist"); } } else { $logger->debug("action is not secure"); } } else { $logger->debug("action not an instance of sfAction"); } } else { $logger->debug("action does not exist"); } } else { $logger->debug("referrer does not match a route"); } } catch (Exception $e) { $logger->warn('Error when trying to get referrer action: ' . $e); } } return $this->getHomePagePath(); }
/** * Loads all of the js/css necessary to support the inline editor * * @param sfWebResponse $response * @return void */ protected function _loadEditorAssets(sfContext $context) { $context->getEventDispatcher()->notify(new sfEvent($context->getResponse(), 'editable_content.load_editor_assets')); $response = $context->getResponse(); $pluginWebRoot = sfConfig::get('app_editable_content_assets_web_root', '/ioEditableContentPlugin'); // JQuery if (true === sfConfig::get('app_editable_content_load_jquery')) { $response->addJavascript(sprintf('%s/js/jquery-1.4.3.min.js', $pluginWebRoot), 'last'); } // JQuery ui (just core and widget) if (true === sfConfig::get('app_editable_content_load_jquery_ui')) { $response->addJavascript(sprintf('%s/js/jquery-ui-core-widget.min.js', $pluginWebRoot), 'last'); } // JQuery metadata if (true === sfConfig::get('app_editable_content_load_jquery_metadata')) { $response->addJavascript(sprintf('%s/js/jquery.metadata.js', $pluginWebRoot), 'last'); } // JQuery form if (true === sfConfig::get('app_editable_content_load_jquery_form')) { $response->addJavascript(sprintf('%s/js/jquery.form.js', $pluginWebRoot), 'last'); } // JQuery blockUI if (true === sfConfig::get('app_editable_content_load_jquery_blockui')) { $response->addJavascript(sprintf('%s/js/jquery.blockUI.js', $pluginWebRoot), 'last'); } // Fancybox if (true === sfConfig::get('app_editable_content_load_fancybox')) { $response->addJavascript(sprintf('%s/fancybox/jquery.fancybox-1.3.4.js', $pluginWebRoot), 'last'); $response->addStylesheet(sprintf('%s/fancybox/jquery.fancybox-1.3.4.css', $pluginWebRoot), 'last'); } // The admin javascript file is handled by symfony $response->addJavascript(sprintf('%s/js/ioEditableContentList.js', $pluginWebRoot), 'last'); $response->addJavascript(sprintf('%s/js/ioEditableContent.js', $pluginWebRoot), 'last'); $response->addJavascript(sprintf('%s/js/ioContentEditor.js', $pluginWebRoot), 'last'); $response->addJavascript($context->getController()->genUrl('@editable_content_admin_js'), 'last'); // The admin css file is handled by symfony $response->addStylesheet($context->getController()->genUrl('@editable_content_admin_css'), 'first'); }
/** * Initialize cache manager * * @param sfContext $context * @param sfCache $taggingCache * @param array $options * * @see sfViewCacheManager::initialize() */ public function initialize($context, sfCache $taggingCache, $options = array()) { if (!$taggingCache instanceof sfTaggingCache) { throw new InvalidArgumentException(sprintf('Cache "%s" is not instanceof sfTaggingCache', get_class($taggingCache))); } if (!sfConfig::get('sf_cache')) { $taggingCache = new sfNoTaggingCache(); } $this->setTaggingCache($taggingCache); $this->cache = $this->getTaggingCache()->getCache(); $this->setEventDispatcher($context->getEventDispatcher()); $this->context = $context; $this->controller = $context->getController(); $this->request = $context->getRequest(); $this->routing = $context->getRouting(); $this->setOptions(array_merge(array('cache_key_use_vary_headers' => true, 'cache_key_use_host_name' => true), $options)); if (sfConfig::get('sf_web_debug')) { $this->getEventDispatcher()->connect('view.cache.filter_content', array($this, 'decorateContentWithDebug')); } // empty configuration $this->cacheConfig = array(); }