Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ## apps/frontend/config/factories.yml
- all:
- controller:
- class: mySfFrontWebController
- ## apps/frontend/config/app.yml
- all:
- database_not_connected:
- module: main
- action: notconnected
- ## apps/frontend/config/frontendConfiguration.class.php
- class frontendConfiguration extends sfApplicationConfiguration
- {
- public function configure()
- {
- $this->dispatcher->connect('doctrine.configure_connection', array($this, 'listenToAddCheckDatabaseConnection'));
- }
- public function listenToAddCheckDatabaseConnection(sfEvent $event)
- {
- $actions = $event->getSubject();
- sfConfig::set('sf_database_is_connected', $actions->getCurrentConnection()->isConnected());
- }
- }
- ## lib/controller/mySfFrontWebController.class.php
- class mySfFrontWebController extends sfFrontWebController
- {
- public function dispatch()
- {
- if (!sfConfig::get('sf_database_is_connected', true))
- {
- $request = $this->context->getRequest();
- $moduleName = $request->getParameter('module');
- $actionName = $request->getParameter('action');
- if ((!$module = sfConfig::get('app_database_not_connected_module')) ||
- (!$action = sfConfig::get('app_database_not_connected_action')))
- {
- throw new sfConfigurationException('Missing parameters app_database_not_connected_module and/or app_database_not_connected_action in app.yml');
- }
- else
- {
- if (($moduleName != $module) && ($actionName != $action))
- {
- $this->forward($module, $action);
- exit;
- }
- }
- }
- parent::dispatch();
- }
- }
Add Comment
Please, Sign In to add comment