Fatal Error Invalid controller specified (a)
EXCEPTION_NO_CONTROLLER : 0
{main}
open/home/peruvian/subdomains/m.peruvianvip.com/vendor/zendframework/zendframework1/library/Zend/Controller/Dispatcher/Standard.php
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_Controller
17    * @subpackage Dispatcher
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   /** Zend_Loader */
24   
require_once 'Zend/Loader.php';
25   
26   
/** Zend_Controller_Dispatcher_Abstract */
27   
require_once 'Zend/Controller/Dispatcher/Abstract.php';
28   
29   
/**
30    * @category   Zend
31    * @package    Zend_Controller
32    * @subpackage Dispatcher
33    * @copyright  Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
34    * @license    http://framework.zend.com/license/new-bsd     New BSD License
35    */
36   
class Zend_Controller_Dispatcher_Standard extends Zend_Controller_Dispatcher_Abstract
37   
{
38       
/**
39        * Current dispatchable directory
40        * @var string
41        */
42       
protected $_curDirectory;
43   
44       
/**
45        * Current module (formatted)
46        * @var string
47        */
48       
protected $_curModule;
49   
50       
/**
51        * Controller directory(ies)
52        * @var array
53        */
54       
protected $_controllerDirectory = array();
55   
56       
/**
57        * Constructor: Set current module to default value
58        *
59        * @param  array $params
60        * @return void
61        */
62       
public function __construct(array $params = array())
63       {
64           
parent::__construct($params);
65           
$this->_curModule $this->getDefaultModule();
66       }
67   
68       
/**
69        * Add a single path to the controller directory stack
70        *
71        * @param string $path
72        * @param string $module
73        * @return Zend_Controller_Dispatcher_Standard
74        */
75       
public function addControllerDirectory($path$module null)
76       {
77           if (
null === $module) {
78               
$module $this->_defaultModule;
79           }
80   
81           
$module = (string) $module;
82           
$path   rtrim((string) $path'/\\');
83   
84           
$this->_controllerDirectory[$module] = $path;
85           return 
$this;
86       }
87   
88       
/**
89        * Set controller directory
90        *
91        * @param array|string $directory
92        * @return Zend_Controller_Dispatcher_Standard
93        */
94       
public function setControllerDirectory($directory$module null)
95       {
96           
$this->_controllerDirectory = array();
97   
98           if (
is_string($directory)) {
99               
$this->addControllerDirectory($directory$module);
100          } elseif (
is_array($directory)) {
101              foreach ((array) 
$directory as $module => $path) {
102                  
$this->addControllerDirectory($path$module);
103              }
104          } else {
105              require_once 
'Zend/Controller/Exception.php';
106              throw new 
Zend_Controller_Exception('Controller directory spec must be either a string or an array');
107          }
108  
109          return 
$this;
110      }
111  
112      
/**
113       * Return the currently set directories for Zend_Controller_Action class
114       * lookup
115       *
116       * If a module is specified, returns just that directory.
117       *
118       * @param  string $module Module name
119       * @return array|string Returns array of all directories by default, single
120       * module directory if module argument provided
121       */
122      
public function getControllerDirectory($module null)
123      {
124          if (
null === $module) {
125              return 
$this->_controllerDirectory;
126          }
127  
128          
$module = (string) $module;
129          if (
array_key_exists($module$this->_controllerDirectory)) {
130              return 
$this->_controllerDirectory[$module];
131          }
132  
133          return 
null;
134      }
135  
136      
/**
137       * Remove a controller directory by module name
138       *
139       * @param  string $module
140       * @return bool
141       */
142      
public function removeControllerDirectory($module)
143      {
144          
$module = (string) $module;
145          if (
array_key_exists($module$this->_controllerDirectory)) {
146              unset(
$this->_controllerDirectory[$module]);
147              return 
true;
148          }
149          return 
false;
150      }
151  
152      
/**
153       * Format the module name.
154       *
155       * @param string $unformatted
156       * @return string
157       */
158      
public function formatModuleName($unformatted)
159      {
160          if ((
$this->_defaultModule == $unformatted) && !$this->getParam('prefixDefaultModule')) {
161              return 
$unformatted;
162          }
163  
164          return 
ucfirst($this->_formatName($unformatted));
165      }
166  
167      
/**
168       * Format action class name
169       *
170       * @param string $moduleName Name of the current module
171       * @param string $className Name of the action class
172       * @return string Formatted class name
173       */
174      
public function formatClassName($moduleName$className)
175      {
176          return 
$this->formatModuleName($moduleName) . '_' $className;
177      }
178  
179      
/**
180       * Convert a class name to a filename
181       *
182       * @param string $class
183       * @return string
184       */
185      
public function classToFilename($class)
186      {
187          return 
str_replace('_'DIRECTORY_SEPARATOR$class) . '.php';
188      }
189  
190      
/**
191       * Returns TRUE if the Zend_Controller_Request_Abstract object can be
192       * dispatched to a controller.
193       *
194       * Use this method wisely. By default, the dispatcher will fall back to the
195       * default controller (either in the module specified or the global default)
196       * if a given controller does not exist. This method returning false does
197       * not necessarily indicate the dispatcher will not still dispatch the call.
198       *
199       * @param Zend_Controller_Request_Abstract $action
200       * @return boolean
201       */
202      
public function isDispatchable(Zend_Controller_Request_Abstract $request)
203      {
204          
$className $this->getControllerClass($request);
205          if (!
$className) {
206              return 
false;
207          }
208  
209          
$finalClass  $className;
210          if ((
$this->_defaultModule != $this->_curModule)
211              || 
$this->getParam('prefixDefaultModule'))
212          {
213              
$finalClass $this->formatClassName($this->_curModule$className);
214          }
215          if (
class_exists($finalClassfalse)) {
216              return 
true;
217          }
218  
219          
$fileSpec    $this->classToFilename($className);
220          
$dispatchDir $this->getDispatchDirectory();
221          
$test        $dispatchDir DIRECTORY_SEPARATOR $fileSpec;
222          return 
Zend_Loader::isReadable($test);
223      }
224  
225      
/**
226       * Dispatch to a controller/action
227       *
228       * By default, if a controller is not dispatchable, dispatch() will throw
229       * an exception. If you wish to use the default controller instead, set the
230       * param 'useDefaultControllerAlways' via {@link setParam()}.
231       *
232       * @param Zend_Controller_Request_Abstract $request
233       * @param Zend_Controller_Response_Abstract $response
234       * @return void
235       * @throws Zend_Controller_Dispatcher_Exception
236       */
237      
public function dispatch(Zend_Controller_Request_Abstract $requestZend_Controller_Response_Abstract $response)
238      {
239          
$this->setResponse($response);
240  
241          
/**
242           * Get controller class
243           */
244          
if (!$this->isDispatchable($request)) {
245              
$controller $request->getControllerName();
246              if (!
$this->getParam('useDefaultControllerAlways') && !empty($controller)) {
247                  require_once 
'Zend/Controller/Dispatcher/Exception.php';
248                  throw new 
Zend_Controller_Dispatcher_Exception('Invalid controller specified (' $request->getControllerName() . ')');
249              }
250  
251              
$className $this->getDefaultControllerClass($request);
252          } else {
253              
$className $this->getControllerClass($request);
254              if (!
$className) {
255                  
$className $this->getDefaultControllerClass($request);
256              }
257          }
258  
259          
/**
260           * If we're in a module or prefixDefaultModule is on, we must add the module name
261           * prefix to the contents of $className, as getControllerClass does not do that automatically.
262           * We must keep a separate variable because modules are not strictly PSR-0: We need the no-module-prefix
263           * class name to do the class->file mapping, but the full class name to insantiate the controller
264           */
265          
$moduleClassName $className;
266          if ((
$this->_defaultModule != $this->_curModule)
267              || 
$this->getParam('prefixDefaultModule'))
268          {
269              
$moduleClassName $this->formatClassName($this->_curModule$className);
270          }
271  
272          
/**
273           * Load the controller class file
274           */
275          
$className $this->loadClass($className);
276  
277          
/**
278           * Instantiate controller with request, response, and invocation
279           * arguments; throw exception if it's not an action controller
280           */
281          
$controller = new $moduleClassName($request$this->getResponse(), $this->getParams());
282          if (!(
$controller instanceof Zend_Controller_Action_Interface) &&
283              !(
$controller instanceof Zend_Controller_Action)) {
284              require_once 
'Zend/Controller/Dispatcher/Exception.php';
285              throw new 
Zend_Controller_Dispatcher_Exception(
286                  
'Controller "' $moduleClassName '" is not an instance of Zend_Controller_Action_Interface'
287              
);
288          }
289  
290          
/**
291           * Retrieve the action name
292           */
293          
$action $this->getActionMethod($request);
294  
295          
/**
296           * Dispatch the method call
297           */
298          
$request->setDispatched(true);
299  
300          
// by default, buffer output
301          
$disableOb $this->getParam('disableOutputBuffering');
302          
$obLevel   ob_get_level();
303          if (empty(
$disableOb)) {
304              
ob_start();
305          }
306  
307          try {
308              
$controller->dispatch($action);
309          } catch (
Exception $e) {
310              
// Clean output buffer on error
311              
$curObLevel ob_get_level();
312              if (
$curObLevel $obLevel) {
313                  do {
314                      
ob_get_clean();
315                      
$curObLevel ob_get_level();
316                  } while (
$curObLevel $obLevel);
317              }
318              throw 
$e;
319          }
320  
321          if (empty(
$disableOb)) {
322              
$content ob_get_clean();
323              
$response->appendBody($content);
324          }
325  
326          
// Destroy the page controller instance and reflection objects
327          
$controller null;
328      }
329  
330      
/**
331       * Load a controller class
332       *
333       * Attempts to load the controller class file from
334       * {@link getControllerDirectory()}.  If the controller belongs to a
335       * module, looks for the module prefix to the controller class.
336       *
337       * @param string $className
338       * @return string Class name loaded
339       * @throws Zend_Controller_Dispatcher_Exception if class not loaded
340       */
341      
public function loadClass($className)
342      {
343          
$finalClass  $className;
344          if ((
$this->_defaultModule != $this->_curModule)
345              || 
$this->getParam('prefixDefaultModule'))
346          {
347              
$finalClass $this->formatClassName($this->_curModule$className);
348          }
349          if (
class_exists($finalClassfalse)) {
350              return 
$finalClass;
351          }
352  
353          
$dispatchDir $this->getDispatchDirectory();
354          
$loadFile    $dispatchDir DIRECTORY_SEPARATOR $this->classToFilename($className);
355  
356          if (
Zend_Loader::isReadable($loadFile)) {
357              include_once 
$loadFile;
358          } else {
359              require_once 
'Zend/Controller/Dispatcher/Exception.php';
360              throw new 
Zend_Controller_Dispatcher_Exception('Cannot load controller class "' $className '" from file "' $loadFile "'");
361          }
362  
363          if (!
class_exists($finalClassfalse)) {
364              require_once 
'Zend/Controller/Dispatcher/Exception.php';
365              throw new 
Zend_Controller_Dispatcher_Exception('Invalid controller class ("' $finalClass '")');
366          }
367  
368          return 
$finalClass;
369      }
370  
371      
/**
372       * Get controller class name
373       *
374       * Try request first; if not found, try pulling from request parameter;
375       * if still not found, fallback to default
376       *
377       * @param Zend_Controller_Request_Abstract $request
378       * @return string|false Returns class name on success
379       */
380      
public function getControllerClass(Zend_Controller_Request_Abstract $request)
381      {
382          
$controllerName $request->getControllerName();
383          if (empty(
$controllerName)) {
384              if (!
$this->getParam('useDefaultControllerAlways')) {
385                  return 
false;
386              }
387              
$controllerName $this->getDefaultControllerName();
388              
$request->setControllerName($controllerName);
389          }
390  
391          
$className $this->formatControllerName($controllerName);
392  
393          
$controllerDirs      $this->getControllerDirectory();
394          
$module $request->getModuleName();
395          if (
$this->isValidModule($module)) {
396              
$this->_curModule    $module;
397              
$this->_curDirectory $controllerDirs[$module];
398          } elseif (
$this->isValidModule($this->_defaultModule)) {
399              
$request->setModuleName($this->_defaultModule);
400              
$this->_curModule    $this->_defaultModule;
401              
$this->_curDirectory $controllerDirs[$this->_defaultModule];
402          } else {
403              require_once 
'Zend/Controller/Exception.php';
404              throw new 
Zend_Controller_Exception('No default module defined for this application');
405          }
406  
407          return 
$className;
408      }
409  
410      
/**
411       * Determine if a given module is valid
412       *
413       * @param  string $module
414       * @return bool
415       */
416      
public function isValidModule($module)
417      {
418          if (!
is_string($module)) {
419              return 
false;
420          }
421  
422          
$module        strtolower($module);
423          
$controllerDir $this->getControllerDirectory();
424          foreach (
array_keys($controllerDir) as $moduleName) {
425              if (
$module == strtolower($moduleName)) {
426                  return 
true;
427              }
428          }
429  
430          return 
false;
431      }
432  
433      
/**
434       * Retrieve default controller class
435       *
436       * Determines whether the default controller to use lies within the
437       * requested module, or if the global default should be used.
438       *
439       * By default, will only use the module default unless that controller does
440       * not exist; if this is the case, it falls back to the default controller
441       * in the default module.
442       *
443       * @param Zend_Controller_Request_Abstract $request
444       * @return string
445       */
446      
public function getDefaultControllerClass(Zend_Controller_Request_Abstract $request)
447      {
448          
$controller $this->getDefaultControllerName();
449          
$default    $this->formatControllerName($controller);
450          
$request->setControllerName($controller)
451                  ->
setActionName(null);
452  
453          
$module              $request->getModuleName();
454          
$controllerDirs      $this->getControllerDirectory();
455          
$this->_curModule    $this->_defaultModule;
456          
$this->_curDirectory $controllerDirs[$this->_defaultModule];
457          if (
$this->isValidModule($module)) {
458              
$found false;
459              if (
class_exists($defaultfalse)) {
460                  
$found true;
461              } else {
462                  
$moduleDir $controllerDirs[$module];
463                  
$fileSpec  $moduleDir DIRECTORY_SEPARATOR $this->classToFilename($default);
464                  if (
Zend_Loader::isReadable($fileSpec)) {
465                      
$found true;
466                      
$this->_curDirectory $moduleDir;
467                  }
468              }
469              if (
$found) {
470                  
$request->setModuleName($module);
471                  
$this->_curModule    $this->formatModuleName($module);
472              }
473          } else {
474              
$request->setModuleName($this->_defaultModule);
475          }
476  
477          return 
$default;
478      }
479  
480      
/**
481       * Return the value of the currently selected dispatch directory (as set by
482       * {@link getController()})
483       *
484       * @return string
485       */
486      
public function getDispatchDirectory()
487      {
488          return 
$this->_curDirectory;
489      }
490  
491      
/**
492       * Determine the action name
493       *
494       * First attempt to retrieve from request; then from request params
495       * using action key; default to default action
496       *
497       * Returns formatted action name
498       *
499       * @param Zend_Controller_Request_Abstract $request
500       * @return string
501       */
502      
public function getActionMethod(Zend_Controller_Request_Abstract $request)
503      {
504          
$action $request->getActionName();
505          if (empty(
$action)) {
506              
$action $this->getDefaultAction();
507              
$request->setActionName($action);
508          }
509  
510          return 
$this->formatActionName($action);
511      }
512  }
513  
Stack trace
  1. open/home/peruvian/subdomains/m.peruvianvip.com/vendor/zendframework/zendframework1/library/Zend/Controller/Front.php
    Zend_Controller_Dispatcher_Standard->dispatch(Zend_Controller_Request_Http, Zend_Controller_Response_Http)
    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_Controller
    17    * @copyright  Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
    18    * @license    http://framework.zend.com/license/new-bsd     New BSD License
    19    * @version    $Id$
    20    */
    21   
    22   
    23   /** Zend_Loader */
    24   
    require_once 'Zend/Loader.php';
    25   
    26   
    /** Zend_Controller_Action_HelperBroker */
    27   
    require_once 'Zend/Controller/Action/HelperBroker.php';
    28   
    29   
    /** Zend_Controller_Plugin_Broker */
    30   
    require_once 'Zend/Controller/Plugin/Broker.php';
    31   
    32   
    /**
    33    * @category   Zend
    34    * @package    Zend_Controller
    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_Controller_Front
    39   
    {
    40       
    /**
    41        * Base URL
    42        * @var string
    43        */
    44       
    protected $_baseUrl null;
    45   
    46       
    /**
    47        * Directory|ies where controllers are stored
    48        *
    49        * @var string|array
    50        */
    51       
    protected $_controllerDir null;
    52   
    53       
    /**
    54        * Instance of Zend_Controller_Dispatcher_Interface
    55        * @var Zend_Controller_Dispatcher_Interface
    56        */
    57       
    protected $_dispatcher null;
    58   
    59       
    /**
    60        * Singleton instance
    61        *
    62        * Marked only as protected to allow extension of the class. To extend,
    63        * simply override {@link getInstance()}.
    64        *
    65        * @var Zend_Controller_Front
    66        */
    67       
    protected static $_instance null;
    68   
    69       
    /**
    70        * Array of invocation parameters to use when instantiating action
    71        * controllers
    72        * @var array
    73        */
    74       
    protected $_invokeParams = array();
    75   
    76       
    /**
    77        * Subdirectory within a module containing controllers; defaults to 'controllers'
    78        * @var string
    79        */
    80       
    protected $_moduleControllerDirectoryName 'controllers';
    81   
    82       
    /**
    83        * Instance of Zend_Controller_Plugin_Broker
    84        * @var Zend_Controller_Plugin_Broker
    85        */
    86       
    protected $_plugins null;
    87   
    88       
    /**
    89        * Instance of Zend_Controller_Request_Abstract
    90        * @var Zend_Controller_Request_Abstract
    91        */
    92       
    protected $_request null;
    93   
    94       
    /**
    95        * Instance of Zend_Controller_Response_Abstract
    96        * @var Zend_Controller_Response_Abstract
    97        */
    98       
    protected $_response null;
    99   
    100      
    /**
    101       * Whether or not to return the response prior to rendering output while in
    102       * {@link dispatch()}; default is to send headers and render output.
    103       * @var boolean
    104       */
    105      
    protected $_returnResponse false;
    106  
    107      
    /**
    108       * Instance of Zend_Controller_Router_Interface
    109       * @var Zend_Controller_Router_Interface
    110       */
    111      
    protected $_router null;
    112  
    113      
    /**
    114       * Whether or not exceptions encountered in {@link dispatch()} should be
    115       * thrown or trapped in the response object
    116       * @var boolean
    117       */
    118      
    protected $_throwExceptions false;
    119  
    120      
    /**
    121       * Constructor
    122       *
    123       * Instantiate using {@link getInstance()}; front controller is a singleton
    124       * object.
    125       *
    126       * Instantiates the plugin broker.
    127       *
    128       * @return void
    129       */
    130      
    protected function __construct()
    131      {
    132          
    $this->_plugins = new Zend_Controller_Plugin_Broker();
    133      }
    134  
    135      
    /**
    136       * Enforce singleton; disallow cloning
    137       *
    138       * @return void
    139       */
    140      
    private function __clone()
    141      {
    142      }
    143  
    144      
    /**
    145       * Singleton instance
    146       *
    147       * @return Zend_Controller_Front
    148       */
    149      
    public static function getInstance()
    150      {
    151          if (
    null === self::$_instance) {
    152              
    self::$_instance = new self();
    153          }
    154  
    155          return 
    self::$_instance;
    156      }
    157  
    158      
    /**
    159       * Resets all object properties of the singleton instance
    160       *
    161       * Primarily used for testing; could be used to chain front controllers.
    162       *
    163       * Also resets action helper broker, clearing all registered helpers.
    164       *
    165       * @return void
    166       */
    167      
    public function resetInstance()
    168      {
    169          
    $reflection = new ReflectionObject($this);
    170          foreach (
    $reflection->getProperties() as $property) {
    171              
    $name $property->getName();
    172              switch (
    $name) {
    173                  case 
    '_instance':
    174                      break;
    175                  case 
    '_controllerDir':
    176                  case 
    '_invokeParams':
    177                      
    $this->{$name} = array();
    178                      break;
    179                  case 
    '_plugins':
    180                      
    $this->{$name} = new Zend_Controller_Plugin_Broker();
    181                      break;
    182                  case 
    '_throwExceptions':
    183                  case 
    '_returnResponse':
    184                      
    $this->{$name} = false;
    185                      break;
    186                  case 
    '_moduleControllerDirectoryName':
    187                      
    $this->{$name} = 'controllers';
    188                      break;
    189                  default:
    190                      
    $this->{$name} = null;
    191                      break;
    192              }
    193          }
    194          
    Zend_Controller_Action_HelperBroker::resetHelpers();
    195      }
    196  
    197      
    /**
    198       * Convenience feature, calls setControllerDirectory()->setRouter()->dispatch()
    199       *
    200       * In PHP 5.1.x, a call to a static method never populates $this -- so run()
    201       * may actually be called after setting up your front controller.
    202       *
    203       * @param string|array $controllerDirectory Path to Zend_Controller_Action
    204       * controller classes or array of such paths
    205       * @return void
    206       * @throws Zend_Controller_Exception if called from an object instance
    207       */
    208      
    public static function run($controllerDirectory)
    209      {
    210          
    self::getInstance()
    211              ->
    setControllerDirectory($controllerDirectory)
    212              ->
    dispatch();
    213      }
    214  
    215      
    /**
    216       * Add a controller directory to the controller directory stack
    217       *
    218       * If $args is presented and is a string, uses it for the array key mapping
    219       * to the directory specified.
    220       *
    221       * @param string $directory
    222       * @param string $module Optional argument; module with which to associate directory. If none provided, assumes 'default'
    223       * @return Zend_Controller_Front
    224       * @throws Zend_Controller_Exception if directory not found or readable
    225       */
    226      
    public function addControllerDirectory($directory$module null)
    227      {
    228          
    $this->getDispatcher()->addControllerDirectory($directory$module);
    229          return 
    $this;
    230      }
    231  
    232      
    /**
    233       * Set controller directory
    234       *
    235       * Stores controller directory(ies) in dispatcher. May be an array of
    236       * directories or a string containing a single directory.
    237       *
    238       * @param string|array $directory Path to Zend_Controller_Action controller
    239       * classes or array of such paths
    240       * @param  string $module Optional module name to use with string $directory
    241       * @return Zend_Controller_Front
    242       */
    243      
    public function setControllerDirectory($directory$module null)
    244      {
    245          
    $this->getDispatcher()->setControllerDirectory($directory$module);
    246          return 
    $this;
    247      }
    248  
    249      
    /**
    250       * Retrieve controller directory
    251       *
    252       * Retrieves:
    253       * - Array of all controller directories if no $name passed
    254       * - String path if $name passed and exists as a key in controller directory array
    255       * - null if $name passed but does not exist in controller directory keys
    256       *
    257       * @param  string $name Default null
    258       * @return array|string|null
    259       */
    260      
    public function getControllerDirectory($name null)
    261      {
    262          return 
    $this->getDispatcher()->getControllerDirectory($name);
    263      }
    264  
    265      
    /**
    266       * Remove a controller directory by module name
    267       *
    268       * @param  string $module
    269       * @return bool
    270       */
    271      
    public function removeControllerDirectory($module)
    272      {
    273          return 
    $this->getDispatcher()->removeControllerDirectory($module);
    274      }
    275  
    276      
    /**
    277       * Specify a directory as containing modules
    278       *
    279       * Iterates through the directory, adding any subdirectories as modules;
    280       * the subdirectory within each module named after {@link $_moduleControllerDirectoryName}
    281       * will be used as the controller directory path.
    282       *
    283       * @param  string $path
    284       * @return Zend_Controller_Front
    285       */
    286      
    public function addModuleDirectory($path)
    287      {
    288          try{
    289              
    $dir = new DirectoryIterator($path);
    290          } catch(
    Exception $e) {
    291              require_once 
    'Zend/Controller/Exception.php';
    292              throw new 
    Zend_Controller_Exception("Directory $path not readable"0$e);
    293          }
    294          foreach (
    $dir as $file) {
    295              if (
    $file->isDot() || !$file->isDir()) {
    296                  continue;
    297              }
    298  
    299              
    $module    $file->getFilename();
    300  
    301              
    // Don't use SCCS directories as modules
    302              
    if (preg_match('/^[^a-z]/i'$module) || ('CVS' == $module)) {
    303                  continue;
    304              }
    305  
    306              
    $moduleDir $file->getPathname() . DIRECTORY_SEPARATOR $this->getModuleControllerDirectoryName();
    307              
    $this->addControllerDirectory($moduleDir$module);
    308          }
    309  
    310          return 
    $this;
    311      }
    312  
    313      
    /**
    314       * Return the path to a module directory (but not the controllers directory within)
    315       *
    316       * @param  string $module
    317       * @return string|null
    318       */
    319      
    public function getModuleDirectory($module null)
    320      {
    321          if (
    null === $module) {
    322              
    $request $this->getRequest();
    323              if (
    null !== $request) {
    324                  
    $module $this->getRequest()->getModuleName();
    325              }
    326              if (empty(
    $module)) {
    327                  
    $module $this->getDispatcher()->getDefaultModule();
    328              }
    329          }
    330  
    331          
    $controllerDir $this->getControllerDirectory($module);
    332  
    333          if ((
    null === $controllerDir) || !is_string($controllerDir)) {
    334              return 
    null;
    335          }
    336  
    337          return 
    dirname($controllerDir);
    338      }
    339  
    340      
    /**
    341       * Set the directory name within a module containing controllers
    342       *
    343       * @param  string $name
    344       * @return Zend_Controller_Front
    345       */
    346      
    public function setModuleControllerDirectoryName($name 'controllers')
    347      {
    348          
    $this->_moduleControllerDirectoryName = (string) $name;
    349  
    350          return 
    $this;
    351      }
    352  
    353      
    /**
    354       * Return the directory name within a module containing controllers
    355       *
    356       * @return string
    357       */
    358      
    public function getModuleControllerDirectoryName()
    359      {
    360          return 
    $this->_moduleControllerDirectoryName;
    361      }
    362  
    363      
    /**
    364       * Set the default controller (unformatted string)
    365       *
    366       * @param string $controller
    367       * @return Zend_Controller_Front
    368       */
    369      
    public function setDefaultControllerName($controller)
    370      {
    371          
    $dispatcher $this->getDispatcher();
    372          
    $dispatcher->setDefaultControllerName($controller);
    373          return 
    $this;
    374      }
    375  
    376      
    /**
    377       * Retrieve the default controller (unformatted string)
    378       *
    379       * @return string
    380       */
    381      
    public function getDefaultControllerName()
    382      {
    383          return 
    $this->getDispatcher()->getDefaultControllerName();
    384      }
    385  
    386      
    /**
    387       * Set the default action (unformatted string)
    388       *
    389       * @param string $action
    390       * @return Zend_Controller_Front
    391       */
    392      
    public function setDefaultAction($action)
    393      {
    394          
    $dispatcher $this->getDispatcher();
    395          
    $dispatcher->setDefaultAction($action);
    396          return 
    $this;
    397      }
    398  
    399      
    /**
    400       * Retrieve the default action (unformatted string)
    401       *
    402       * @return string
    403       */
    404      
    public function getDefaultAction()
    405      {
    406          return 
    $this->getDispatcher()->getDefaultAction();
    407      }
    408  
    409      
    /**
    410       * Set the default module name
    411       *
    412       * @param string $module
    413       * @return Zend_Controller_Front
    414       */
    415      
    public function setDefaultModule($module)
    416      {
    417          
    $dispatcher $this->getDispatcher();
    418          
    $dispatcher->setDefaultModule($module);
    419          return 
    $this;
    420      }
    421  
    422      
    /**
    423       * Retrieve the default module
    424       *
    425       * @return string
    426       */
    427      
    public function getDefaultModule()
    428      {
    429          return 
    $this->getDispatcher()->getDefaultModule();
    430      }
    431  
    432      
    /**
    433       * Set request class/object
    434       *
    435       * Set the request object.  The request holds the request environment.
    436       *
    437       * If a class name is provided, it will instantiate it
    438       *
    439       * @param string|Zend_Controller_Request_Abstract $request
    440       * @throws Zend_Controller_Exception if invalid request class
    441       * @return Zend_Controller_Front
    442       */
    443      
    public function setRequest($request)
    444      {
    445          if (
    is_string($request)) {
    446              if (!
    class_exists($request)) {
    447                  require_once 
    'Zend/Loader.php';
    448                  
    Zend_Loader::loadClass($request);
    449              }
    450              
    $request = new $request();
    451          }
    452          if (!
    $request instanceof Zend_Controller_Request_Abstract) {
    453              require_once 
    'Zend/Controller/Exception.php';
    454              throw new 
    Zend_Controller_Exception('Invalid request class');
    455          }
    456  
    457          
    $this->_request $request;
    458  
    459          return 
    $this;
    460      }
    461  
    462      
    /**
    463       * Return the request object.
    464       *
    465       * @return null|Zend_Controller_Request_Abstract
    466       */
    467      
    public function getRequest()
    468      {
    469          return 
    $this->_request;
    470      }
    471  
    472      
    /**
    473       * Set router class/object
    474       *
    475       * Set the router object.  The router is responsible for mapping
    476       * the request to a controller and action.
    477       *
    478       * If a class name is provided, instantiates router with any parameters
    479       * registered via {@link setParam()} or {@link setParams()}.
    480       *
    481       * @param string|Zend_Controller_Router_Interface $router
    482       * @throws Zend_Controller_Exception if invalid router class
    483       * @return Zend_Controller_Front
    484       */
    485      
    public function setRouter($router)
    486      {
    487          if (
    is_string($router)) {
    488              if (!
    class_exists($router)) {
    489                  require_once 
    'Zend/Loader.php';
    490                  
    Zend_Loader::loadClass($router);
    491              }
    492              
    $router = new $router();
    493          }
    494  
    495          if (!
    $router instanceof Zend_Controller_Router_Interface) {
    496              require_once 
    'Zend/Controller/Exception.php';
    497              throw new 
    Zend_Controller_Exception('Invalid router class');
    498          }
    499  
    500          
    $router->setFrontController($this);
    501          
    $this->_router $router;
    502  
    503          return 
    $this;
    504      }
    505  
    506      
    /**
    507       * Return the router object.
    508       *
    509       * Instantiates a Zend_Controller_Router_Rewrite object if no router currently set.
    510       *
    511       * @return Zend_Controller_Router_Interface
    512       */
    513      
    public function getRouter()
    514      {
    515          if (
    null == $this->_router) {
    516              require_once 
    'Zend/Controller/Router/Rewrite.php';
    517              
    $this->setRouter(new Zend_Controller_Router_Rewrite());
    518          }
    519  
    520          return 
    $this->_router;
    521      }
    522  
    523      
    /**
    524       * Set the base URL used for requests
    525       *
    526       * Use to set the base URL segment of the REQUEST_URI to use when
    527       * determining PATH_INFO, etc. Examples:
    528       * - /admin
    529       * - /myapp
    530       * - /subdir/index.php
    531       *
    532       * Note that the URL should not include the full URI. Do not use:
    533       * - http://example.com/admin
    534       * - http://example.com/myapp
    535       * - http://example.com/subdir/index.php
    536       *
    537       * If a null value is passed, this can be used as well for autodiscovery (default).
    538       *
    539       * @param string $base
    540       * @return Zend_Controller_Front
    541       * @throws Zend_Controller_Exception for non-string $base
    542       */
    543      
    public function setBaseUrl($base null)
    544      {
    545          if (!
    is_string($base) && (null !== $base)) {
    546              require_once 
    'Zend/Controller/Exception.php';
    547              throw new 
    Zend_Controller_Exception('Rewrite base must be a string');
    548          }
    549  
    550          
    $this->_baseUrl $base;
    551  
    552          if ((
    null !== ($request $this->getRequest())) && (method_exists($request'setBaseUrl'))) {
    553              
    $request->setBaseUrl($base);
    554          }
    555  
    556          return 
    $this;
    557      }
    558  
    559      
    /**
    560       * Retrieve the currently set base URL
    561       *
    562       * @return string
    563       */
    564      
    public function getBaseUrl()
    565      {
    566          
    $request $this->getRequest();
    567          if ((
    null !== $request) && method_exists($request'getBaseUrl')) {
    568              return 
    $request->getBaseUrl();
    569          }
    570  
    571          return 
    $this->_baseUrl;
    572      }
    573  
    574      
    /**
    575       * Set the dispatcher object.  The dispatcher is responsible for
    576       * taking a Zend_Controller_Dispatcher_Token object, instantiating the controller, and
    577       * call the action method of the controller.
    578       *
    579       * @param Zend_Controller_Dispatcher_Interface $dispatcher
    580       * @return Zend_Controller_Front
    581       */
    582      
    public function setDispatcher(Zend_Controller_Dispatcher_Interface $dispatcher)
    583      {
    584          
    $this->_dispatcher $dispatcher;
    585          return 
    $this;
    586      }
    587  
    588      
    /**
    589       * Return the dispatcher object.
    590       *
    591       * @return Zend_Controller_Dispatcher_Interface
    592       */
    593      
    public function getDispatcher()
    594      {
    595          
    /**
    596           * Instantiate the default dispatcher if one was not set.
    597           */
    598          
    if (!$this->_dispatcher instanceof Zend_Controller_Dispatcher_Interface) {
    599              require_once 
    'Zend/Controller/Dispatcher/Standard.php';
    600              
    $this->_dispatcher = new Zend_Controller_Dispatcher_Standard();
    601          }
    602          return 
    $this->_dispatcher;
    603      }
    604  
    605      
    /**
    606       * Set response class/object
    607       *
    608       * Set the response object.  The response is a container for action
    609       * responses and headers. Usage is optional.
    610       *
    611       * If a class name is provided, instantiates a response object.
    612       *
    613       * @param string|Zend_Controller_Response_Abstract $response
    614       * @throws Zend_Controller_Exception if invalid response class
    615       * @return Zend_Controller_Front
    616       */
    617      
    public function setResponse($response)
    618      {
    619          if (
    is_string($response)) {
    620              if (!
    class_exists($response)) {
    621                  require_once 
    'Zend/Loader.php';
    622                  
    Zend_Loader::loadClass($response);
    623              }
    624              
    $response = new $response();
    625          }
    626          if (!
    $response instanceof Zend_Controller_Response_Abstract) {
    627              require_once 
    'Zend/Controller/Exception.php';
    628              throw new 
    Zend_Controller_Exception('Invalid response class');
    629          }
    630  
    631          
    $this->_response $response;
    632  
    633          return 
    $this;
    634      }
    635  
    636      
    /**
    637       * Return the response object.
    638       *
    639       * @return null|Zend_Controller_Response_Abstract
    640       */
    641      
    public function getResponse()
    642      {
    643          return 
    $this->_response;
    644      }
    645  
    646      
    /**
    647       * Add or modify a parameter to use when instantiating an action controller
    648       *
    649       * @param string $name
    650       * @param mixed $value
    651       * @return Zend_Controller_Front
    652       */
    653      
    public function setParam($name$value)
    654      {
    655          
    $name = (string) $name;
    656          
    $this->_invokeParams[$name] = $value;
    657          return 
    $this;
    658      }
    659  
    660      
    /**
    661       * Set parameters to pass to action controller constructors
    662       *
    663       * @param array $params
    664       * @return Zend_Controller_Front
    665       */
    666      
    public function setParams(array $params)
    667      {
    668          
    $this->_invokeParams array_merge($this->_invokeParams$params);
    669          return 
    $this;
    670      }
    671  
    672      
    /**
    673       * Retrieve a single parameter from the controller parameter stack
    674       *
    675       * @param string $name
    676       * @return mixed
    677       */
    678      
    public function getParam($name)
    679      {
    680          if(isset(
    $this->_invokeParams[$name])) {
    681              return 
    $this->_invokeParams[$name];
    682          }
    683  
    684          return 
    null;
    685      }
    686  
    687      
    /**
    688       * Retrieve action controller instantiation parameters
    689       *
    690       * @return array
    691       */
    692      
    public function getParams()
    693      {
    694          return 
    $this->_invokeParams;
    695      }
    696  
    697      
    /**
    698       * Clear the controller parameter stack
    699       *
    700       * By default, clears all parameters. If a parameter name is given, clears
    701       * only that parameter; if an array of parameter names is provided, clears
    702       * each.
    703       *
    704       * @param null|string|array single key or array of keys for params to clear
    705       * @return Zend_Controller_Front
    706       */
    707      
    public function clearParams($name null)
    708      {
    709          if (
    null === $name) {
    710              
    $this->_invokeParams = array();
    711          } elseif (
    is_string($name) && isset($this->_invokeParams[$name])) {
    712              unset(
    $this->_invokeParams[$name]);
    713          } elseif (
    is_array($name)) {
    714              foreach (
    $name as $key) {
    715                  if (
    is_string($key) && isset($this->_invokeParams[$key])) {
    716                      unset(
    $this->_invokeParams[$key]);
    717                  }
    718              }
    719          }
    720  
    721          return 
    $this;
    722      }
    723  
    724      
    /**
    725       * Register a plugin.
    726       *
    727       * @param  Zend_Controller_Plugin_Abstract $plugin
    728       * @param  int $stackIndex Optional; stack index for plugin
    729       * @return Zend_Controller_Front
    730       */
    731      
    public function registerPlugin(Zend_Controller_Plugin_Abstract $plugin$stackIndex null)
    732      {
    733          
    $this->_plugins->registerPlugin($plugin$stackIndex);
    734          return 
    $this;
    735      }
    736  
    737      
    /**
    738       * Unregister a plugin.
    739       *
    740       * @param  string|Zend_Controller_Plugin_Abstract $plugin Plugin class or object to unregister
    741       * @return Zend_Controller_Front
    742       */
    743      
    public function unregisterPlugin($plugin)
    744      {
    745          
    $this->_plugins->unregisterPlugin($plugin);
    746          return 
    $this;
    747      }
    748  
    749      
    /**
    750       * Is a particular plugin registered?
    751       *
    752       * @param  string $class
    753       * @return bool
    754       */
    755      
    public function hasPlugin($class)
    756      {
    757          return 
    $this->_plugins->hasPlugin($class);
    758      }
    759  
    760      
    /**
    761       * Retrieve a plugin or plugins by class
    762       *
    763       * @param  string $class
    764       * @return false|Zend_Controller_Plugin_Abstract|array
    765       */
    766      
    public function getPlugin($class)
    767      {
    768          return 
    $this->_plugins->getPlugin($class);
    769      }
    770  
    771      
    /**
    772       * Retrieve all plugins
    773       *
    774       * @return array
    775       */
    776      
    public function getPlugins()
    777      {
    778          return 
    $this->_plugins->getPlugins();
    779      }
    780  
    781      
    /**
    782       * Set the throwExceptions flag and retrieve current status
    783       *
    784       * Set whether exceptions encounted in the dispatch loop should be thrown
    785       * or caught and trapped in the response object.
    786       *
    787       * Default behaviour is to trap them in the response object; call this
    788       * method to have them thrown.
    789       *
    790       * Passing no value will return the current value of the flag; passing a
    791       * boolean true or false value will set the flag and return the current
    792       * object instance.
    793       *
    794       * @param boolean $flag Defaults to null (return flag state)
    795       * @return boolean|Zend_Controller_Front Used as a setter, returns object; as a getter, returns boolean
    796       */
    797      
    public function throwExceptions($flag null)
    798      {
    799          if (
    $flag !== null) {
    800              
    $this->_throwExceptions = (bool) $flag;
    801              return 
    $this;
    802          }
    803  
    804          return 
    $this->_throwExceptions;
    805      }
    806  
    807      
    /**
    808       * Set whether {@link dispatch()} should return the response without first
    809       * rendering output. By default, output is rendered and dispatch() returns
    810       * nothing.
    811       *
    812       * @param boolean $flag
    813       * @return boolean|Zend_Controller_Front Used as a setter, returns object; as a getter, returns boolean
    814       */
    815      
    public function returnResponse($flag null)
    816      {
    817          if (
    true === $flag) {
    818              
    $this->_returnResponse true;
    819              return 
    $this;
    820          } elseif (
    false === $flag) {
    821              
    $this->_returnResponse false;
    822              return 
    $this;
    823          }
    824  
    825          return 
    $this->_returnResponse;
    826      }
    827  
    828      
    /**
    829       * Dispatch an HTTP request to a controller/action.
    830       *
    831       * @param Zend_Controller_Request_Abstract|null $request
    832       * @param Zend_Controller_Response_Abstract|null $response
    833       * @return void|Zend_Controller_Response_Abstract Returns response object if returnResponse() is true
    834       */
    835      
    public function dispatch(Zend_Controller_Request_Abstract $request nullZend_Controller_Response_Abstract $response null)
    836      {
    837          if (!
    $this->getParam('noErrorHandler') && !$this->_plugins->hasPlugin('Zend_Controller_Plugin_ErrorHandler')) {
    838              
    // Register with stack index of 100
    839              
    require_once 'Zend/Controller/Plugin/ErrorHandler.php';
    840              
    $this->_plugins->registerPlugin(new Zend_Controller_Plugin_ErrorHandler(), 100);
    841          }
    842  
    843          if (!
    $this->getParam('noViewRenderer') && !Zend_Controller_Action_HelperBroker::hasHelper('viewRenderer')) {
    844              require_once 
    'Zend/Controller/Action/Helper/ViewRenderer.php';
    845              
    Zend_Controller_Action_HelperBroker::getStack()->offsetSet(-80, new Zend_Controller_Action_Helper_ViewRenderer());
    846          }
    847  
    848          
    /**
    849           * Instantiate default request object (HTTP version) if none provided
    850           */
    851          
    if (null !== $request) {
    852              
    $this->setRequest($request);
    853          } elseif ((
    null === $request) && (null === ($request $this->getRequest()))) {
    854              require_once 
    'Zend/Controller/Request/Http.php';
    855              
    $request = new Zend_Controller_Request_Http();
    856              
    $this->setRequest($request);
    857          }
    858  
    859          
    /**
    860           * Set base URL of request object, if available
    861           */
    862          
    if (is_callable(array($this->_request'setBaseUrl'))) {
    863              if (
    null !== $this->_baseUrl) {
    864                  
    $this->_request->setBaseUrl($this->_baseUrl);
    865              }
    866          }
    867  
    868          
    /**
    869           * Instantiate default response object (HTTP version) if none provided
    870           */
    871          
    if (null !== $response) {
    872              
    $this->setResponse($response);
    873          } elseif ((
    null === $this->_response) && (null === ($this->_response $this->getResponse()))) {
    874              require_once 
    'Zend/Controller/Response/Http.php';
    875              
    $response = new Zend_Controller_Response_Http();
    876              
    $this->setResponse($response);
    877          }
    878  
    879          
    /**
    880           * Register request and response objects with plugin broker
    881           */
    882          
    $this->_plugins
    883               
    ->setRequest($this->_request)
    884               ->
    setResponse($this->_response);
    885  
    886          
    /**
    887           * Initialize router
    888           */
    889          
    $router $this->getRouter();
    890          
    $router->setParams($this->getParams());
    891  
    892          
    /**
    893           * Initialize dispatcher
    894           */
    895          
    $dispatcher $this->getDispatcher();
    896          
    $dispatcher->setParams($this->getParams())
    897                     ->
    setResponse($this->_response);
    898  
    899          
    // Begin dispatch
    900          
    try {
    901              
    /**
    902               * Route request to controller/action, if a router is provided
    903               */
    904  
    905              /**
    906              * Notify plugins of router startup
    907              */
    908              
    $this->_plugins->routeStartup($this->_request);
    909  
    910              try {
    911                  
    $router->route($this->_request);
    912              }  catch (
    Exception $e) {
    913                  if (
    $this->throwExceptions()) {
    914                      throw 
    $e;
    915                  }
    916  
    917                  
    $this->_response->setException($e);
    918              }
    919  
    920              
    /**
    921              * Notify plugins of router completion
    922              */
    923              
    $this->_plugins->routeShutdown($this->_request);
    924  
    925              
    /**
    926               * Notify plugins of dispatch loop startup
    927               */
    928              
    $this->_plugins->dispatchLoopStartup($this->_request);
    929  
    930              
    /**
    931               *  Attempt to dispatch the controller/action. If the $this->_request
    932               *  indicates that it needs to be dispatched, move to the next
    933               *  action in the request.
    934               */
    935              
    do {
    936                  
    $this->_request->setDispatched(true);
    937  
    938                  
    /**
    939                   * Notify plugins of dispatch startup
    940                   */
    941                  
    $this->_plugins->preDispatch($this->_request);
    942  
    943                  
    /**
    944                   * Skip requested action if preDispatch() has reset it
    945                   */
    946                  
    if (!$this->_request->isDispatched()) {
    947                      continue;
    948                  }
    949  
    950                  
    /**
    951                   * Dispatch request
    952                   */
    953                  
    try {
    954                      
    $dispatcher->dispatch($this->_request$this->_response);
    955                  } catch (
    Exception $e) {
    956                      if (
    $this->throwExceptions()) {
    957                          throw 
    $e;
    958                      }
    959                      
    $this->_response->setException($e);
    960                  }
    961  
    962                  
    /**
    963                   * Notify plugins of dispatch completion
    964                   */
    965                  
    $this->_plugins->postDispatch($this->_request);
    966              } while (!
    $this->_request->isDispatched());
    967          } catch (
    Exception $e) {
    968              if (
    $this->throwExceptions()) {
    969                  throw 
    $e;
    970              }
    971  
    972              
    $this->_response->setException($e);
    973          }
    974  
    975          
    /**
    976           * Notify plugins of dispatch loop completion
    977           */
    978          
    try {
    979              
    $this->_plugins->dispatchLoopShutdown();
    980          } catch (
    Exception $e) {
    981              if (
    $this->throwExceptions()) {
    982                  throw 
    $e;
    983              }
    984  
    985              
    $this->_response->setException($e);
    986          }
    987  
    988          if (
    $this->returnResponse()) {
    989              return 
    $this->_response;
    990          }
    991  
    992          
    $this->_response->sendResponse();
    993      }
    994  }
    995  
  2. open/home/peruvian/subdomains/m.peruvianvip.com/vendor/zendframework/zendframework1/library/Zend/Application/Bootstrap/Bootstrap.php
    Zend_Controller_Front->dispatch()
    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   /**
    24    * @see Zend_Application_Bootstrap_BootstrapAbstract
    25    */
    26   
    require_once 'Zend/Application/Bootstrap/BootstrapAbstract.php';
    27   
    28   
    /**
    29    * Concrete base class for bootstrap classes
    30    *
    31    * Registers and utilizes Zend_Controller_Front by default.
    32    *
    33    * @uses       Zend_Application_Bootstrap_Bootstrap
    34    * @category   Zend
    35    * @package    Zend_Application
    36    * @subpackage Bootstrap
    37    * @copyright  Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
    38    * @license    http://framework.zend.com/license/new-bsd     New BSD License
    39    */
    40   
    class Zend_Application_Bootstrap_Bootstrap
    41       
    extends Zend_Application_Bootstrap_BootstrapAbstract
    42   
    {
    43       
    /**
    44        * Application resource namespace
    45        * @var false|string
    46        */
    47       
    protected $_appNamespace false;
    48   
    49       
    /**
    50        * Application resource autoloader
    51        * @var Zend_Loader_Autoloader_Resource
    52        */
    53       
    protected $_resourceLoader;
    54   
    55       
    /**
    56        * Constructor
    57        *
    58        * Ensure FrontController resource is registered
    59        *
    60        * @param  Zend_Application|Zend_Application_Bootstrap_Bootstrapper $application
    61        */
    62       
    public function __construct($application)
    63       {
    64           
    parent::__construct($application);
    65   
    66           if (
    $application->hasOption('resourceloader')) {
    67               
    $this->setOptions(
    68                   array(
    69                       
    'resourceloader' => $application->getOption(
    70                           
    'resourceloader'
    71                       
    )
    72                   )
    73               );
    74           }
    75           
    $this->getResourceLoader();
    76   
    77           if (!
    $this->hasPluginResource('FrontController')) {
    78               
    $this->registerPluginResource('FrontController');
    79           }
    80       }
    81   
    82       
    /**
    83        * Run the application
    84        *
    85        * Checks to see that we have a default controller directory. If not, an
    86        * exception is thrown.
    87        *
    88        * If so, it registers the bootstrap with the 'bootstrap' parameter of
    89        * the front controller, and dispatches the front controller.
    90        *
    91        * @return mixed
    92        * @throws Zend_Application_Bootstrap_Exception
    93        */
    94       
    public function run()
    95       {
    96           
    $front   $this->getResource('FrontController');
    97           
    $default $front->getDefaultModule();
    98           if (
    null === $front->getControllerDirectory($default)) {
    99               throw new 
    Zend_Application_Bootstrap_Exception(
    100                  
    'No default controller directory registered with front controller'
    101              
    );
    102          }
    103  
    104          
    $front->setParam('bootstrap'$this);
    105          
    $response $front->dispatch();
    106          if (
    $front->returnResponse()) {
    107              return 
    $response;
    108          }
    109      }
    110  
    111      
    /**
    112       * Set module resource loader
    113       *
    114       * @param  Zend_Loader_Autoloader_Resource $loader
    115       * @return Zend_Application_Module_Bootstrap
    116       */
    117      
    public function setResourceLoader(Zend_Loader_Autoloader_Resource $loader)
    118      {
    119          
    $this->_resourceLoader $loader;
    120          return 
    $this;
    121      }
    122  
    123      
    /**
    124       * Retrieve module resource loader
    125       *
    126       * @return Zend_Loader_Autoloader_Resource
    127       */
    128      
    public function getResourceLoader()
    129      {
    130          if ((
    null === $this->_resourceLoader)
    131              && (
    false !== ($namespace $this->getAppNamespace()))
    132          ) {
    133              
    $r    = new ReflectionClass($this);
    134              
    $path $r->getFileName();
    135              
    $this->setResourceLoader(
    136                  new 
    Zend_Application_Module_Autoloader(
    137                      array(
    138                          
    'namespace' => $namespace,
    139                          
    'basePath'  => dirname($path),
    140                      )
    141                  )
    142              );
    143          }
    144          return 
    $this->_resourceLoader;
    145      }
    146  
    147      
    /**
    148       * Get application namespace (used for module autoloading)
    149       *
    150       * @return string
    151       */
    152      
    public function getAppNamespace()
    153      {
    154          return 
    $this->_appNamespace;
    155      }
    156  
    157      
    /**
    158       * Set application namespace (for module autoloading)
    159       *
    160       * @param  string
    161       * @return Zend_Application_Bootstrap_Bootstrap
    162       */
    163      
    public function setAppNamespace($value)
    164      {
    165          
    $this->_appNamespace = (string) $value;
    166          return 
    $this;
    167      }
    168  }
    169  
  3. open/home/peruvian/subdomains/m.peruvianvip.com/vendor/zendframework/zendframework1/library/Zend/Application.php
    Zend_Application_Bootstrap_Bootstrap->run()
    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    * @copyright  Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
    18    * @license    http://framework.zend.com/license/new-bsd     New BSD License
    19    * @version    $Id$
    20    */
    21   
    22   /**
    23    * @category   Zend
    24    * @package    Zend_Application
    25    * @copyright  Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
    26    * @license    http://framework.zend.com/license/new-bsd     New BSD License
    27    */
    28   
    class Zend_Application
    29   
    {
    30       
    /**
    31        * Autoloader to use
    32        *
    33        * @var Zend_Loader_Autoloader
    34        */
    35       
    protected $_autoloader;
    36   
    37       
    /**
    38        * Bootstrap
    39        *
    40        * @var Zend_Application_Bootstrap_BootstrapAbstract
    41        */
    42       
    protected $_bootstrap;
    43   
    44       
    /**
    45        * Application environment
    46        *
    47        * @var string
    48        */
    49       
    protected $_environment;
    50   
    51       
    /**
    52        * Flattened (lowercase) option keys
    53        *
    54        * @var array
    55        */
    56       
    protected $_optionKeys = array();
    57   
    58       
    /**
    59        * Options for Zend_Application
    60        *
    61        * @var array
    62        */
    63       
    protected $_options = array();
    64   
    65       
    /**
    66        * Constructor
    67        *
    68        * Initialize application. Potentially initializes include_paths, PHP
    69        * settings, and bootstrap class.
    70        *
    71        * @param  string                   $environment
    72        * @param  string|array|Zend_Config $options String path to configuration file, or array/Zend_Config of configuration options
    73        * @throws Zend_Application_Exception When invalid options are provided
    74        * @return void
    75        */
    76       
    public function __construct($environment$options null)
    77       {
    78           
    $this->_environment = (string) $environment;
    79   
    80           require_once 
    'Zend/Loader/Autoloader.php';
    81           
    $this->_autoloader Zend_Loader_Autoloader::getInstance();
    82   
    83           if (
    null !== $options) {
    84               if (
    is_string($options)) {
    85                   
    $options $this->_loadConfig($options);
    86               } elseif (
    $options instanceof Zend_Config) {
    87                   
    $options $options->toArray();
    88               } elseif (!
    is_array($options)) {
    89                   throw new 
    Zend_Application_Exception(
    90                       
    'Invalid options provided; must be location of config file,'
    91                       
    ' a config object, or an array'
    92                   
    );
    93               }
    94   
    95               
    $this->setOptions($options);
    96           }
    97       }
    98   
    99       
    /**
    100       * Retrieve current environment
    101       *
    102       * @return string
    103       */
    104      
    public function getEnvironment()
    105      {
    106          return 
    $this->_environment;
    107      }
    108  
    109      
    /**
    110       * Retrieve autoloader instance
    111       *
    112       * @return Zend_Loader_Autoloader
    113       */
    114      
    public function getAutoloader()
    115      {
    116          return 
    $this->_autoloader;
    117      }
    118  
    119      
    /**
    120       * Set application options
    121       *
    122       * @param  array $options
    123       * @throws Zend_Application_Exception When no bootstrap path is provided
    124       * @throws Zend_Application_Exception When invalid bootstrap information are provided
    125       * @return Zend_Application
    126       */
    127      
    public function setOptions(array $options)
    128      {
    129          if (!empty(
    $options['config'])) {
    130              if (
    is_array($options['config'])) {
    131                  
    $_options = array();
    132                  foreach (
    $options['config'] as $tmp) {
    133                      
    $_options $this->mergeOptions(
    134                          
    $_options$this->_loadConfig($tmp)
    135                      );
    136                  }
    137                  
    $options $this->mergeOptions($_options$options);
    138              } else {
    139                  
    $options $this->mergeOptions(
    140                      
    $this->_loadConfig($options['config']), $options
    141                  
    );
    142              }
    143          }
    144  
    145          
    $this->_options $options;
    146  
    147          
    $options array_change_key_case($optionsCASE_LOWER);
    148  
    149          
    $this->_optionKeys array_keys($options);
    150  
    151          if (!empty(
    $options['phpsettings'])) {
    152              
    $this->setPhpSettings($options['phpsettings']);
    153          }
    154  
    155          if (!empty(
    $options['includepaths'])) {
    156              
    $this->setIncludePaths($options['includepaths']);
    157          }
    158  
    159          if (!empty(
    $options['autoloadernamespaces'])) {
    160              
    $this->setAutoloaderNamespaces($options['autoloadernamespaces']);
    161          }
    162  
    163          if (!empty(
    $options['autoloaderzfpath'])) {
    164              
    $autoloader $this->getAutoloader();
    165              if (
    method_exists($autoloader'setZfPath')) {
    166                  
    $zfPath    $options['autoloaderzfpath'];
    167                  
    $zfVersion = !empty($options['autoloaderzfversion'])
    168                             ? 
    $options['autoloaderzfversion']
    169                             : 
    'latest';
    170                  
    $autoloader->setZfPath($zfPath$zfVersion);
    171              }
    172          }
    173  
    174          if (!empty(
    $options['bootstrap'])) {
    175              
    $bootstrap $options['bootstrap'];
    176  
    177              if (
    is_string($bootstrap)) {
    178                  
    $this->setBootstrap($bootstrap);
    179              } elseif (
    is_array($bootstrap)) {
    180                  if (empty(
    $bootstrap['path'])) {
    181                      throw new 
    Zend_Application_Exception(
    182                          
    'No bootstrap path provided'
    183                      
    );
    184                  }
    185  
    186                  
    $path  $bootstrap['path'];
    187                  
    $class null;
    188  
    189                  if (!empty(
    $bootstrap['class'])) {
    190                      
    $class $bootstrap['class'];
    191                  }
    192  
    193                  
    $this->setBootstrap($path$class);
    194              } else {
    195                  throw new 
    Zend_Application_Exception(
    196                      
    'Invalid bootstrap information provided'
    197                  
    );
    198              }
    199          }
    200  
    201          return 
    $this;
    202      }
    203  
    204      
    /**
    205       * Retrieve application options (for caching)
    206       *
    207       * @return array
    208       */
    209      
    public function getOptions()
    210      {
    211          return 
    $this->_options;
    212      }
    213  
    214      
    /**
    215       * Is an option present?
    216       *
    217       * @param  string $key
    218       * @return bool
    219       */
    220      
    public function hasOption($key)
    221      {
    222          return 
    in_array(strtolower($key), $this->_optionKeys);
    223      }
    224  
    225      
    /**
    226       * Retrieve a single option
    227       *
    228       * @param  string $key
    229       * @return mixed
    230       */
    231      
    public function getOption($key)
    232      {
    233          if (
    $this->hasOption($key)) {
    234              
    $options $this->getOptions();
    235              
    $options array_change_key_case($optionsCASE_LOWER);
    236              return 
    $options[strtolower($key)];
    237          }
    238          return 
    null;
    239      }
    240  
    241      
    /**
    242       * Merge options recursively
    243       *
    244       * @param  array $array1
    245       * @param  mixed $array2
    246       * @return array
    247       */
    248      
    public function mergeOptions(array $array1$array2 null)
    249      {
    250          if (
    is_array($array2)) {
    251              foreach (
    $array2 as $key => $val) {
    252                  if (
    is_array($array2[$key])) {
    253                      
    $array1[$key] = (array_key_exists($key$array1) && is_array($array1[$key]))
    254                                    ? 
    $this->mergeOptions($array1[$key], $array2[$key])
    255                                    : 
    $array2[$key];
    256                  } else {
    257                      
    $array1[$key] = $val;
    258                  }
    259              }
    260          }
    261          return 
    $array1;
    262      }
    263  
    264      
    /**
    265       * Set PHP configuration settings
    266       *
    267       * @param  array $settings
    268       * @param  string $prefix Key prefix to prepend to array values (used to map . separated INI values)
    269       * @return Zend_Application
    270       */
    271      
    public function setPhpSettings(array $settings$prefix '')
    272      {
    273          foreach (
    $settings as $key => $value) {
    274              
    $key = empty($prefix) ? $key $prefix $key;
    275              if (
    is_scalar($value)) {
    276                  
    ini_set($key$value);
    277              } elseif (
    is_array($value)) {
    278                  
    $this->setPhpSettings($value$key '.');
    279              }
    280          }
    281  
    282          return 
    $this;
    283      }
    284  
    285      
    /**
    286       * Set include path
    287       *
    288       * @param  array $paths
    289       * @return Zend_Application
    290       */
    291      
    public function setIncludePaths(array $paths)
    292      {
    293          
    $path implode(PATH_SEPARATOR$paths);
    294          
    set_include_path($path PATH_SEPARATOR get_include_path());
    295          return 
    $this;
    296      }
    297  
    298      
    /**
    299       * Set autoloader namespaces
    300       *
    301       * @param  array $namespaces
    302       * @return Zend_Application
    303       */
    304      
    public function setAutoloaderNamespaces(array $namespaces)
    305      {
    306          
    $autoloader $this->getAutoloader();
    307  
    308          foreach (
    $namespaces as $namespace) {
    309              
    $autoloader->registerNamespace($namespace);
    310          }
    311  
    312          return 
    $this;
    313      }
    314  
    315      
    /**
    316       * Set bootstrap path/class
    317       *
    318       * @param  string $path
    319       * @param  string $class
    320       * @return Zend_Application
    321       */
    322      
    public function setBootstrap($path$class null)
    323      {
    324          
    // setOptions() can potentially send a null value; specify default
    325          // here
    326          
    if (null === $class) {
    327              
    $class 'Bootstrap';
    328          }
    329  
    330          if (!
    class_exists($classfalse)) {
    331              require_once 
    $path;
    332              if (!
    class_exists($classfalse)) {
    333                  throw new 
    Zend_Application_Exception(
    334                      
    'Bootstrap class not found'
    335                  
    );
    336              }
    337          }
    338          
    $this->_bootstrap = new $class($this);
    339  
    340          if (!
    $this->_bootstrap instanceof Zend_Application_Bootstrap_Bootstrapper) {
    341              throw new 
    Zend_Application_Exception(
    342                  
    'Bootstrap class does not implement'
    343                  
    ' Zend_Application_Bootstrap_Bootstrapper'
    344              
    );
    345          }
    346  
    347          return 
    $this;
    348      }
    349  
    350      
    /**
    351       * Get bootstrap object
    352       *
    353       * @return Zend_Application_Bootstrap_BootstrapAbstract
    354       */
    355      
    public function getBootstrap()
    356      {
    357          if (
    null === $this->_bootstrap) {
    358              
    $this->_bootstrap = new Zend_Application_Bootstrap_Bootstrap($this);
    359          }
    360          return 
    $this->_bootstrap;
    361      }
    362  
    363      
    /**
    364       * Bootstrap application
    365       *
    366       * @param  null|string|array $resource
    367       * @return Zend_Application
    368       */
    369      
    public function bootstrap($resource null)
    370      {
    371          
    $this->getBootstrap()->bootstrap($resource);
    372          return 
    $this;
    373      }
    374  
    375      
    /**
    376       * Run the application
    377       *
    378       * @return void
    379       */
    380      
    public function run()
    381      {
    382          
    $this->getBootstrap()->run();
    383      }
    384  
    385      
    /**
    386       * Load configuration file of options
    387       *
    388       * @param  string $file
    389       * @throws Zend_Application_Exception When invalid configuration file is provided
    390       * @return array
    391       */
    392      
    protected function _loadConfig($file)
    393      {
    394          
    $environment $this->getEnvironment();
    395          
    $suffix      pathinfo($filePATHINFO_EXTENSION);
    396          
    $suffix      = ($suffix === 'dist')
    397                       ? 
    pathinfo(basename($file".$suffix"), PATHINFO_EXTENSION)
    398                       : 
    $suffix;
    399  
    400          switch (
    strtolower($suffix)) {
    401              case 
    'ini':
    402                  
    $config = new Zend_Config_Ini($file$environment);
    403                  break;
    404  
    405              case 
    'xml':
    406                  
    $config = new Zend_Config_Xml($file$environment);
    407                  break;
    408  
    409              case 
    'json':
    410                  
    $config = new Zend_Config_Json($file$environment);
    411                  break;
    412  
    413              case 
    'yaml':
    414              case 
    'yml':
    415                  
    $config = new Zend_Config_Yaml($file$environment);
    416                  break;
    417  
    418              case 
    'php':
    419              case 
    'inc':
    420                  
    $config = include $file;
    421                  if (!
    is_array($config)) {
    422                      throw new 
    Zend_Application_Exception(
    423                          
    'Invalid configuration file provided; PHP file does not'
    424                          
    ' return array value'
    425                      
    );
    426                  }
    427                  return 
    $config;
    428                  break;
    429  
    430              default:
    431                  throw new 
    Zend_Application_Exception(
    432                      
    'Invalid configuration file provided; unknown config type'
    433                  
    );
    434          }
    435  
    436          return 
    $config->toArray();
    437      }
    438  }
    439  
  4. open/home/peruvian/subdomains/m.peruvianvip.com/public/index.php
    Zend_Application->run()
    1     <?php
    2    define
    ('DS'DIRECTORY_SEPARATOR);
    3    
    define('PS'PATH_SEPARATOR);
    4    
    5    
    6    
    //Define to base directory
    7    
    defined('BASE_PATH')
    8        || 
    define('BASE_PATH'realpath(dirname(__FILE__) . DS '..'));
    9    
    10   
    // Define path to application directory
    11   
    defined('APPLICATION_PATH')
    12       || 
    define('APPLICATION_PATH'BASE_PATH DS 'application');
    13   
    14   
    // Define application domain
    15   
    defined('APPLICATION_DOMAIN')
    16       || 
    define('APPLICATION_DOMAIN'$_SERVER['HTTP_HOST']);
    17   
    18   
    // Define application environment
    19   
    defined('APPLICATION_ENV')
    20       || 
    define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production'));
    21   
    22   
    // Ensure library/ is on include_path
    23   
    set_include_path(implode(PS, array(
    24       
    realpath(BASE_PATH DS 'library')
    25   )));
    26   
    27   
    // load composer libraries
    28   
    require_once realpath(BASE_PATH DS 'vendor/autoload.php');
    29   
    30   
    /** Zend_Application */
    31   
    require_once 'Core/Init.php';
    32   
    33   
    // Create application, bootstrap, and run
    34   
    $application Core_Init::getApplication();
    35   
    36   if (
    PHP_SAPI !== 'cli') {
    37       
    $application->bootstrap()->run();
    38   } else {
    39       
    $application->bootstrap();
    40   }
    41