Abstract Class luya\base\BaseBootstrap
Inheritance | luya\base\BaseBootstrap |
---|---|
Implements | yii\base\BootstrapInterface |
Subclasses | luya\console\Bootstrap, luya\web\Bootstrap |
Available since version | 1.0.0 |
Source Code | https://github.com/luyadev/luya/blob/master/core/base/BaseBootstrap.php |
Base class for luya bootsrapping proccess.
Public Methods
Method | Description | Defined By |
---|---|---|
beforeRun() | This method will be invoke before the run() method. |
luya\base\BaseBootstrap |
bootstrap() | Boostrap method will be invoken by Yii Application bootrapping proccess containing the Application ($app) Object to get/set data. | luya\base\BaseBootstrap |
extractModules() | Extract and load all modules from the Application-Object. | luya\base\BaseBootstrap |
getModules() | Return all modules prepared by extractModules() method. |
luya\base\BaseBootstrap |
hasModule() | Check if a Module exists in the module list getModules() . |
luya\base\BaseBootstrap |
run() | This method will be invoke after the beforeRun() method. |
luya\base\BaseBootstrap |
Method Details
This method will be invoke before the run()
method.
public abstract void beforeRun ( $app ) | ||
$app | object |
Luya Application |
abstract public function beforeRun($app);
Boostrap method will be invoken by Yii Application bootrapping proccess containing the Application ($app) Object to get/set data.
public void bootstrap ( $app ) | ||
$app | object |
Luya Application |
public function bootstrap($app)
{
// add trace
Yii::beginProfile('LUYA Boostrap process profiling', __METHOD__);
// register luya core translation message source
if (!isset($app->i18n->translations['luya'])) {
$app->i18n->translations['luya'] = [
'class' => 'yii\i18n\PhpMessageSource',
'basePath' => '@luya/messages',
];
}
$this->extractModules($app);
$this->beforeRun($app);
$this->startModules($app);
$this->run($app);
// end trace
Yii::debug('End of the LUYA bootstraping process', __METHOD__);
Yii::endProfile('LUYA Boostrap process profiling');
}
Extract and load all modules from the Application-Object.
public void extractModules ( $app ) | ||
$app | object |
Luya Application |
public function extractModules($app)
{
if ($this->_modules === null) {
foreach ($app->getModules() as $id => $obj) {
// create module object
$moduleObject = Yii::$app->getModule($id);
// see if the module is a luya base module, otherwise ignore
if ($moduleObject instanceof \luya\base\Module) {
$this->_modules[$id] = $moduleObject;
}
}
// when no luya modules are registered an empty array will be returned.
if ($this->_modules === null) {
$this->_modules = [];
}
}
}
Return all modules prepared by extractModules()
method.
public array getModules ( ) | ||
return | array |
An array containg all modules where the key is the module name and the value is the Module Object |
---|
public function getModules()
{
return $this->_modules;
}
Check if a Module exists in the module list getModules()
.
public boolean hasModule ( $module ) | ||
$module | string |
The name of the Module |
public function hasModule($module)
{
return array_key_exists($module, $this->_modules);
}