Abstract Class luya\base\BaseBootstrap

Inheritanceluya\base\BaseBootstrap
Implementsyii\base\BootstrapInterface
Subclassesluya\console\Bootstrap, luya\web\Bootstrap
Available since version1.0.0
Source Code https://github.com/luyadev/luya/blob/master/core/base/BaseBootstrap.php

Base class for luya bootsrapping proccess.

Public Methods

Hide inherited 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

Hide inherited methods

beforeRun() public abstract method

This method will be invoke before the run() method.

public abstract void beforeRun ( $app )
$app object

Luya Application luya\base\Application

                abstract public function beforeRun($app);

            
bootstrap() public method

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 luya\base\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');
}

            
extractModules() public method

Extract and load all modules from the Application-Object.

public void extractModules ( $app )
$app object

Luya Application luya\base\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 = [];
        }
    }
}

            
getModules() public method

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 luya\base\Module.

                public function getModules()
{
    return $this->_modules;
}

            
hasModule() public method

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);
}

            
run() public abstract method

This method will be invoke after the beforeRun() method.

public abstract void run ( $app )
$app object

Luya Application luya\base\Application

                abstract public function run($app);