In my bootstrap.php, I have many _initX () functions, and some of them may contain code that depends on the code in the previous initX
protected function _initAutoloading() { } protected function _initViewInitializer() { } protected function _initVariables() { }
So my question is: are these _init functions guaranteed in the order in which they were declared?
EDIT. , , , , , ReflectionObjects:: getmethods() get_class_methods PHP, , PHP Zend , , , .
, / : $bootstrap->bootstrap(array('foo', 'bar')); , Zend Application , .
$bootstrap->bootstrap(array('foo', 'bar'));
, , $bootstrap ('foo') "bar" ( _init *())
, , , , _init *().
, Zend Application doc
, :
var $init_us = array( "_initAutoloading", "_initViewInitializer", "_initVariables", ); function __construct() { foreach ($this->init_us as $fn) { $this->{$fn}(); } }
ZF, __construct _initOrderedList _initFunctions _myinit... - .
__construct
_initOrderedList
_initFunctions
_myinit...
manual. :
If the resource depends on another resource, it must call bootstrap () in its code to ensure that the resource is executed. Subsequent calls will then be ignored.
Here is a sample code:
class Bootstrap extends Zend_Application_Bootstrap_Bootstrap { protected function _initRequest() { // Ensure the front controller is initialized $this->bootstrap('FrontController'); // Retrieve the front controller from the bootstrap registry $front = $this->getResource('FrontController'); $request = new Zend_Controller_Request_Http(); $request->setBaseUrl('/foo'); $front->setRequest($request); // Ensure the request is stored in the bootstrap registry return $request; } }
You do not need to rely on the order.
Source: https://habr.com/ru/post/1773864/More articles:Using gluUnProject () to draw a square at the cursor position - screenSQL row cuts - sqliOs: Why IBOutlets are not connected after [[alloc] init], but after calling viewDidUnload: - iosUse or not use with with statement in AS3? - actionscript-3AppFabric Powershell cache exception - windowsMy phone does not display the mobile version of my site - htmlconverting HBITMAP to a byte array - c ++Почему Process.Start бросает Win32Exception при использовании разных учетных данных пользователя? - c#Destroy XML into a C # Object - c #jQuery replace element text - javascriptAll Articles