Bootstrap.php 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <?php
  2. /**
  3. * Zend Framework
  4. *
  5. * LICENSE
  6. *
  7. * This source file is subject to the new BSD license that is bundled
  8. * with this package in the file LICENSE.txt.
  9. * It is also available through the world-wide-web at this URL:
  10. * http://framework.zend.com/license/new-bsd
  11. * If you did not receive a copy of the license and are unable to
  12. * obtain it through the world-wide-web, please send an email
  13. * to license@zend.com so we can send you a copy immediately.
  14. *
  15. * @category Zend
  16. * @package Zend_Application
  17. * @subpackage Bootstrap
  18. * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
  19. * @license http://framework.zend.com/license/new-bsd New BSD License
  20. * @version $Id$
  21. */
  22. /**
  23. * Concrete base class for bootstrap classes
  24. *
  25. * Registers and utilizes Zend_Controller_Front by default.
  26. *
  27. * @uses Zend_Application_Bootstrap_Bootstrap
  28. * @category Zend
  29. * @package Zend_Application
  30. * @subpackage Bootstrap
  31. * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
  32. * @license http://framework.zend.com/license/new-bsd New BSD License
  33. */
  34. class Zend_Application_Bootstrap_Bootstrap
  35. extends Zend_Application_Bootstrap_BootstrapAbstract
  36. {
  37. /**
  38. * Constructor
  39. *
  40. * Ensure FrontController resource is registered
  41. *
  42. * @param Zend_Application|Zend_Application_Bootstrap_Bootstrapper $application
  43. * @return void
  44. */
  45. public function __construct($application)
  46. {
  47. parent::__construct($application);
  48. if (!$this->hasPluginResource('FrontController')) {
  49. $this->registerPluginResource('FrontController');
  50. }
  51. }
  52. /**
  53. * Run the application
  54. *
  55. * Checks to see that we have a default controller directory. If not, an
  56. * exception is thrown.
  57. *
  58. * If so, it registers the bootstrap with the 'bootstrap' parameter of
  59. * the front controller, and dispatches the front controller.
  60. *
  61. * @return void
  62. * @throws Zend_Application_Bootstrap_Exception
  63. */
  64. public function run()
  65. {
  66. $front = $this->getResource('FrontController');
  67. $default = $front->getDefaultModule();
  68. if (null === $front->getControllerDirectory($default)) {
  69. throw new Zend_Application_Bootstrap_Exception(
  70. 'No default controller directory registered with front controller'
  71. );
  72. }
  73. $front->setParam('bootstrap', $this);
  74. $front->dispatch();
  75. }
  76. }