Guest User

Untitled

a guest
Jul 18th, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.39 KB | None | 0 0
  1. <?php
  2. /**
  3. * Application bootstrap
  4. *
  5. * @uses Zend_Application_Bootstrap_Bootstrap
  6. * @package QuickStart
  7. */
  8. class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
  9. {
  10. /**
  11. * Bootstrap autoloader for application resources
  12. *
  13. * @return Zend_Application_Module_Autoloader
  14. */
  15. protected function _initAutoload ()
  16. {
  17. $autoloader = new Zend_Application_Module_Autoloader(array('namespace' => 'Default' , 'supressNotFoundWarnings' => false , 'basePath' => dirname(__FILE__)));
  18. return $autoloader;
  19. }
  20. /**
  21. * Bootstrap the view doctype
  22. *
  23. * @return void
  24. */
  25. protected function _initDoctype ()
  26. {
  27. $this->bootstrap('view');
  28. $view = $this->getResource('view');
  29. $view->doctype('HTML5');
  30. }
  31.  
  32.  
  33. public function _initRoutes ()
  34. {
  35. $front = Zend_Controller_Front::getInstance();
  36. $router = $front->getRouter();
  37. $route1 = new Zend_Controller_Router_Route('ads/:subject', array('controller' => 'ads' , 'action' => 'index'));
  38. $route2 = new Zend_Controller_Router_Route('ads/:subject/:province', array('controller' => 'ads' , 'action' => 'index'));
  39. $route3 = new Zend_Controller_Router_Route('ads/:subject/:province/:city', array('controller' => 'ads' , 'action' => 'index'));
  40. $route10 = new Zend_Controller_Router_Route_Static('ads/sign', array('controller' => 'ads' , 'action' => 'sign'));
  41. $adspages = new Zend_Controller_Router_Route('ads/:page', array('controller' => 'ads' , 'action' => 'index'), array('page' => '[0-9]'));
  42. $router->addRoute('subject', $route1);
  43. $router->addRoute('province', $route2);
  44. $router->addRoute('city', $route3);
  45. $router->addRoute('ads', $route10);
  46. $router->addRoute('adspages', $adspages);
  47. }
  48. protected function _initZFDebug ()
  49. {
  50. if (APPLICATION_ENV == "development") {
  51. $autoloader = Zend_Loader_Autoloader::getInstance();
  52. $autoloader->registerNamespace('ZFDebug');
  53. $options = array('plugins' => array('Variables' , 'File' => array('base_path' => 'APPLICATION_PATH') , 'Memory' , 'Time' , 'Registry' , 'Exception'));
  54. # Instantiate the database adapter and setup the plugin.
  55. # Alternatively just add the plugin like above and rely on the autodiscovery feature.
  56. if ($this->hasPluginResource('db')) {
  57. $this->bootstrap('db');
  58. $db = $this->getPluginResource('db')->getDbAdapter();
  59. $options['plugins']['Database']['adapter'] = $db;
  60. }
  61. # Setup the cache plugin
  62. if ($this->hasPluginResource('cache')) {
  63. $this->bootstrap('cache');
  64. $cache = $this->getPluginResource('cache')->getDbAdapter();
  65. $options['plugins']['Cache']['backend'] = $cache->getBackend();
  66. }
  67. $debug = new ZFDebug_Controller_Plugin_Debug($options);
  68. $this->bootstrap('frontController');
  69. $frontController = $this->getResource('frontController');
  70. $frontController->registerPlugin($debug);
  71. }
  72. }
  73. protected function _initViewHelpers ()
  74. {
  75. $this->bootstrap('view');
  76. $view = $this->getResource('view');
  77. $view->addHelperPath('ZendX/JQuery/View/Helper', 'ZendX_Jquery_View_Helper');
  78. }
  79. }
Add Comment
Please, Sign In to add comment