PageRenderTime 112ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/vendor/magento/zendframework1/library/Zend/Application/Bootstrap/Bootstrap.php

https://gitlab.com/yousafsyed/easternglamor
PHP | 168 lines | 71 code | 12 blank | 85 comment | 6 complexity | a54f574a13568e3b0d79f9792b58a77b MD5 | raw file
  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-2015 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. * @see Zend_Application_Bootstrap_BootstrapAbstract
  24. */
  25. #require_once 'Zend/Application/Bootstrap/BootstrapAbstract.php';
  26. /**
  27. * Concrete base class for bootstrap classes
  28. *
  29. * Registers and utilizes Zend_Controller_Front by default.
  30. *
  31. * @uses Zend_Application_Bootstrap_Bootstrap
  32. * @category Zend
  33. * @package Zend_Application
  34. * @subpackage Bootstrap
  35. * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
  36. * @license http://framework.zend.com/license/new-bsd New BSD License
  37. */
  38. class Zend_Application_Bootstrap_Bootstrap
  39. extends Zend_Application_Bootstrap_BootstrapAbstract
  40. {
  41. /**
  42. * Application resource namespace
  43. * @var false|string
  44. */
  45. protected $_appNamespace = false;
  46. /**
  47. * Application resource autoloader
  48. * @var Zend_Loader_Autoloader_Resource
  49. */
  50. protected $_resourceLoader;
  51. /**
  52. * Constructor
  53. *
  54. * Ensure FrontController resource is registered
  55. *
  56. * @param Zend_Application|Zend_Application_Bootstrap_Bootstrapper $application
  57. */
  58. public function __construct($application)
  59. {
  60. parent::__construct($application);
  61. if ($application->hasOption('resourceloader')) {
  62. $this->setOptions(
  63. array(
  64. 'resourceloader' => $application->getOption(
  65. 'resourceloader'
  66. )
  67. )
  68. );
  69. }
  70. $this->getResourceLoader();
  71. if (!$this->hasPluginResource('FrontController')) {
  72. $this->registerPluginResource('FrontController');
  73. }
  74. }
  75. /**
  76. * Run the application
  77. *
  78. * Checks to see that we have a default controller directory. If not, an
  79. * exception is thrown.
  80. *
  81. * If so, it registers the bootstrap with the 'bootstrap' parameter of
  82. * the front controller, and dispatches the front controller.
  83. *
  84. * @return mixed
  85. * @throws Zend_Application_Bootstrap_Exception
  86. */
  87. public function run()
  88. {
  89. $front = $this->getResource('FrontController');
  90. $default = $front->getDefaultModule();
  91. if (null === $front->getControllerDirectory($default)) {
  92. throw new Zend_Application_Bootstrap_Exception(
  93. 'No default controller directory registered with front controller'
  94. );
  95. }
  96. $front->setParam('bootstrap', $this);
  97. $response = $front->dispatch();
  98. if ($front->returnResponse()) {
  99. return $response;
  100. }
  101. }
  102. /**
  103. * Set module resource loader
  104. *
  105. * @param Zend_Loader_Autoloader_Resource $loader
  106. * @return Zend_Application_Module_Bootstrap
  107. */
  108. public function setResourceLoader(Zend_Loader_Autoloader_Resource $loader)
  109. {
  110. $this->_resourceLoader = $loader;
  111. return $this;
  112. }
  113. /**
  114. * Retrieve module resource loader
  115. *
  116. * @return Zend_Loader_Autoloader_Resource
  117. */
  118. public function getResourceLoader()
  119. {
  120. if ((null === $this->_resourceLoader)
  121. && (false !== ($namespace = $this->getAppNamespace()))
  122. ) {
  123. $r = new ReflectionClass($this);
  124. $path = $r->getFileName();
  125. $this->setResourceLoader(
  126. new Zend_Application_Module_Autoloader(
  127. array(
  128. 'namespace' => $namespace,
  129. 'basePath' => dirname($path),
  130. )
  131. )
  132. );
  133. }
  134. return $this->_resourceLoader;
  135. }
  136. /**
  137. * Get application namespace (used for module autoloading)
  138. *
  139. * @return string
  140. */
  141. public function getAppNamespace()
  142. {
  143. return $this->_appNamespace;
  144. }
  145. /**
  146. * Set application namespace (for module autoloading)
  147. *
  148. * @param string
  149. * @return Zend_Application_Bootstrap_Bootstrap
  150. */
  151. public function setAppNamespace($value)
  152. {
  153. $this->_appNamespace = (string) $value;
  154. return $this;
  155. }
  156. }