Class luya\console\Application

Inheritanceluya\console\Application » yii\console\Application » yii\base\Application » yii\base\Module » yii\di\ServiceLocator » yii\base\Component » yii\base\BaseObject
Implementsyii\base\Configurable
Uses Traitsluya\traits\ApplicationTrait
Available since version1.0.0

LUYA Console/CLI Application.

Public Properties

Hide inherited properties

Property Type Description Defined By
$adminModules luya\base\AdminModuleInterface luya\traits\ApplicationTrait
$adminModulesAssets array luya\traits\ApplicationTrait
$adminModulesJsTranslationMessages array luya\traits\ApplicationTrait
$adminModulesMenus array An array where the key is the module id and value the menu array. luya\traits\ApplicationTrait
$aliases array List of path aliases to be defined. yii\base\Module
$applicationModules luya\base\Module[] luya\traits\ApplicationTrait
$assetManager yii\web\AssetManager The asset manager application component. yii\base\Application
$authManager yii\rbac\ManagerInterface|null The auth manager application component or null if it's not configured. yii\base\Application
$basePath string The root directory of the application. yii\base\Application
$behaviors yii\base\Behavior[] List of behaviors attached to this component. yii\base\Component
$bootstrap array List of components that should be run during the application bootstrapping process. yii\base\Application
$cache yii\caching\CacheInterface|null The cache application component. yii\base\Application
$charset string The charset currently used for the application. yii\base\Application
$components array The list of the component definitions or the loaded component instances (ID => definition or instance). yii\di\ServiceLocator
$consoleBaseUrl string This value is used when declared for console request as urlManger baseUrl in order to enable urlHandling. luya\traits\ApplicationTrait
$consoleHostInfo string This value will be used as hostInfo when running console applications in urlManager. luya\traits\ApplicationTrait
$container array Values given in terms of name-value pairs. yii\base\Application
$controller yii\console\Controller The currently active controller instance yii\console\Application
$controllerMap array Mapping from controller ID to controller configurations. yii\base\Module
$controllerNamespace string The namespace that controller classes are located in. yii\base\Application
$controllerPath string The directory that contains the controller classes. yii\base\Module
$corsConfig array An array to provide application wide CORS settings. luya\traits\ApplicationTrait
$db yii\db\Connection The database connection. yii\base\Application
$defaultRoute string The default route of this application. yii\console\Application
$enableCoreCommands boolean Whether to enable the commands provided by the core framework. yii\console\Application
$ensureSecureConnection boolean If enabled, the application will throw an exception if a request is not from a secure connection (https). luya\traits\ApplicationTrait
$errorHandler luya\console\ErrorHandler The error handler component. luya\console\Application
$extensions array|null List of installed Yii extensions. yii\base\Application
$formatter luya\components\Formatter Format values luya\traits\ApplicationTrait
$frontendModules luya\base\Module luya\traits\ApplicationTrait
$i18n yii\i18n\I18N The internationalization application component. yii\base\Application
$id string An ID that uniquely identifies this module among other modules which have the same parent. yii\base\Module
$language string The language that is meant to be used for end users. yii\base\Application
$layout string|boolean The layout that should be applied for views in this application. yii\base\Application
$layoutPath string The root directory of layout files. yii\base\Module
$loadedModules array List of loaded modules indexed by their class names. yii\base\Application
$locale string The language short code to set the locale for. luya\traits\ApplicationTrait
$locales array Can override the localisation value used for php internal setlocale() method for specific language. luya\traits\ApplicationTrait
$log yii\log\Dispatcher The log dispatcher application component. yii\base\Application
$mail luya\components\Mail Mail Component luya\traits\ApplicationTrait
$mailer yii\mail\MailerInterface The mailer application component. yii\base\Application
$module yii\base\Module|null The parent module of this module. yii\base\Module
$modules array The modules (indexed by their IDs). yii\base\Module
$mute boolean Mute the Applications ouput, this is used to make application cli tests with no output. luya\console\Application
$name string The application name. yii\base\Application
$packageInstaller luya\base\PackageInstaller luya\traits\ApplicationTrait
$params array Custom module parameters (name => value). yii\base\Module
$remoteToken string|boolean Set a token, which will be used to collect data from a central host, if you want to enable this feature. luya\traits\ApplicationTrait
$request yii\console\Request The request component. yii\console\Application
$requestedAction yii\base\Action|null The requested Action. yii\base\Application
$requestedParams array The parameters supplied to the requested action. yii\base\Application
$requestedRoute string The requested route yii\base\Application
$response yii\console\Response The response component. yii\console\Application
$runtimePath string The directory that stores runtime files. yii\base\Application
$security yii\base\Security The security application component. yii\base\Application
$siteTitle string Title for the application used in different sections like Login screen luya\traits\ApplicationTrait
$sourceLanguage string The language that the application is written in. yii\base\Application
$state integer The current application state during a request handling life cycle. yii\base\Application
$tags array Add tags to the TagParser class. luya\traits\ApplicationTrait
$themeManager luya\theme\ThemeManager Theme Manager luya\traits\ApplicationTrait
$timeZone string The time zone used by this application. yii\base\Application
$uniqueId string The unique ID of the module. yii\base\Application
$urlManager yii\web\UrlManager The URL manager for this application. yii\base\Application
$vendorPath string The directory that stores vendor files. yii\base\Application
$version string The version of this module. yii\base\Module
$view yii\base\View|yii\web\View The view application component that is used to render various view files. yii\base\Application
$viewPath string The root directory of view files. yii\base\Module
$webroot string Returns the webroot directory event for console commands. luya\traits\ApplicationTrait
$webrootDirectory string The directory where your webroot represents, this is basically used to find the webroot directory in the console mode, cause some importer classes need those variables. luya\traits\ApplicationTrait

Public Methods

Hide inherited methods

Method Description Defined By
__call() Calls the named method which is not a class method. yii\base\Component
__clone() This method is called after the object is created by cloning an existing one. yii\base\Component
__construct() Constructor. yii\console\Application
__get() Getter magic method. yii\di\ServiceLocator
__isset() Checks if a property value is null. yii\di\ServiceLocator
__set() Sets the value of a component property. yii\base\Component
__unset() Sets a component property to be null. yii\base\Component
afterAction() This method is invoked right after an action within this module is executed. yii\base\Module
attachBehavior() Attaches a behavior to this component. yii\base\Component
attachBehaviors() Attaches a list of behaviors to the component. yii\base\Component
beforeAction() This method is invoked right before an action within this module is executed. yii\base\Module
behaviors() Returns a list of behaviors that this component should behave as. yii\base\Component
canGetProperty() Returns a value indicating whether a property can be read. yii\base\Component
canSetProperty() Returns a value indicating whether a property can be set. yii\base\Component
className() Returns the fully qualified name of this class. yii\base\BaseObject
clear() Removes the component from the locator. yii\di\ServiceLocator
coreCommands() Provides an array with all LUYA core commands. luya\console\Application
coreComponents() Returns the configuration of core application components. luya\console\Application
createController() Creates a controller instance based on the given route. yii\base\Module
createControllerByID() Creates a controller based on the given controller ID. yii\base\Module
detachBehavior() Detaches a behavior from the component. yii\base\Component
detachBehaviors() Detaches all behaviors from the component. yii\base\Component
end() Terminates the application. yii\base\Application
ensureBehaviors() Makes sure that the behaviors declared in behaviors() are attached to this component. yii\base\Component
ensureLocale() Transform the $language into a locale sign to set php env settings. luya\traits\ApplicationTrait
get() Returns the component instance with the specified ID. yii\base\Module
getAdminModules() Return all Admin Module Interface implementing modules. luya\traits\ApplicationTrait
getAdminModulesAssets() Get all assets files from all admin modules luya\traits\ApplicationTrait
getAdminModulesJsTranslationMessages() Get all js translations from all admin modules luya\traits\ApplicationTrait
getAdminModulesMenus() Get all admin menu modules luya\traits\ApplicationTrait
getApplicationModules() Get an array with all modules which are an instance of the luya\base\Module. luya\traits\ApplicationTrait
getAssetManager() Returns the asset manager. yii\base\Application
getAuthManager() Returns the auth manager for this application. yii\base\Application
getBasePath() Returns the root directory of the module. yii\base\Module
getBehavior() Returns the named behavior object. yii\base\Component
getBehaviors() Returns all behaviors attached to this component. yii\base\Component
getCache() Returns the cache component. yii\base\Application
getComponents() Returns the list of the component definitions or the loaded component instances. yii\di\ServiceLocator
getControllerPath() Returns the directory that contains the controller classes according to $controllerNamespace. yii\base\Module
getDb() Returns the database connection component. yii\base\Application
getErrorHandler() Returns the error handler component. yii\console\Application
getFormatter() Returns the formatter component. yii\base\Application
getFrontendModules() Return a list with all registered frontend modules except 'luya' and 'cms'. This is needed in the module block. luya\traits\ApplicationTrait
getI18n() Returns the internationalization (i18n) component. yii\base\Application
getInstance() Returns the currently requested instance of this module class. yii\base\Module
getLayoutPath() Returns the directory that contains layout view files for this module. yii\base\Module
getLog() Returns the log dispatcher component. yii\base\Application
getMailer() Returns the mailer component. yii\base\Application
getModule() Retrieves the child module of the specified ID. yii\base\Module
getModules() Returns the sub-modules in this module. yii\base\Module
getPackageInstaller() Get the package Installer luya\traits\ApplicationTrait
getRequest() Returns the request component. yii\console\Application
getResponse() Returns the response component. yii\console\Application
getRuntimePath() Returns the directory that stores runtime files. yii\base\Application
getSecurity() Returns the security component. yii\base\Application
getTimeZone() Returns the time zone used by this application. yii\base\Application
getUniqueId() Returns an ID that uniquely identifies this module among all modules within the current application. yii\base\Application
getUrlManager() Returns the URL manager for this application. yii\base\Application
getVendorPath() Returns the directory that stores vendor files. yii\base\Application
getVersion() Returns current module version. yii\base\Module
getView() Returns the view object. yii\base\Application
getViewPath() Returns the directory that contains the view files for this module. yii\base\Module
getWebroot() Read only property which is used in cli bootstrap process to set the @webroot alias luya\traits\ApplicationTrait
handleRequest() Handles the specified request. yii\console\Application
has() Returns a value indicating whether the locator has the specified component definition or has instantiated the component. yii\base\Module
hasEventHandlers() Returns a value indicating whether there is any handler attached to the named event. yii\base\Component
hasMethod() Returns a value indicating whether a method is defined. yii\base\Component
hasModule() Checks whether the child module of the specified ID exists. yii\base\Module
hasProperty() Returns a value indicating whether a property is defined for this component. yii\base\Component
init() Add trace info to luya application trait luya\traits\ApplicationTrait
luyaCoreComponents() Add additional core components to the yii2 base core components. luya\traits\ApplicationTrait
off() Detaches an existing event handler from this component. yii\base\Component
on() Attaches an event handler to an event. yii\base\Component
preInit() Pre-initializes the application. yii\base\Application
run() Runs the application. yii\base\Application
runAction() Runs a controller action specified by a route. yii\console\Application
set() Registers a component definition with this locator. yii\di\ServiceLocator
setAliases() Defines path aliases. yii\base\Module
setBasePath() Sets the root directory of the application and the @app alias. yii\base\Application
setComponents() Registers a set of component definitions in this locator. yii\di\ServiceLocator
setContainer() Configures Yii::$container with the $config. yii\base\Application
setControllerPath() Sets the directory that contains the controller classes. yii\base\Module
setInstance() Sets the currently requested instance of this module class. yii\base\Module
setLayoutPath() Sets the directory that contains the layout files. yii\base\Module
setLocale() Set the application localisation trough setlocale. luya\traits\ApplicationTrait
setModule() Adds a sub-module to this module. yii\base\Module
setModules() Registers sub-modules in the current module. yii\base\Module
setRuntimePath() Sets the directory that stores runtime files. yii\base\Application
setTimeZone() Sets the time zone used by this application. yii\base\Application
setVendorPath() Sets the directory that stores vendor files. yii\base\Application
setVersion() Sets current module version. yii\base\Module
setViewPath() Sets the directory that contains the view files. yii\base\Module
trigger() Triggers an event. yii\base\Component

Protected Methods

Hide inherited methods

Method Description Defined By
bootstrap() Initializes extensions and executes bootstrap components. luya\traits\ApplicationTrait
defaultVersion() Returns default module version. yii\base\Module
loadConfig() Loads the configuration. yii\console\Application
registerErrorHandler() Registers the errorHandler component as a PHP error handler. yii\base\Application

Events

Hide inherited events

Event Type Description Defined By
EVENT_AFTER_ACTION yii\base\ActionEvent An event raised after executing a controller action. yii\base\Module
EVENT_AFTER_REQUEST yii\base\Event An event raised after the application successfully handles a request (before the response is sent out). yii\base\Application
EVENT_BEFORE_ACTION yii\base\ActionEvent An event raised before executing a controller action. yii\base\Module
EVENT_BEFORE_REQUEST yii\base\Event An event raised before the application starts to handle a request. yii\base\Application

Constants

Hide inherited constants

Constant Value Description Defined By
OPTION_APPCONFIG 'appconfig' The option name for specifying the application configuration file path. yii\console\Application
STATE_AFTER_REQUEST 4 Application state used by $state: application is triggering EVENT_AFTER_REQUEST. . yii\base\Application
STATE_BEFORE_REQUEST 2 Application state used by $state: application is triggering EVENT_BEFORE_REQUEST. yii\base\Application
STATE_BEGIN 0 Application state used by $state: application just started. yii\base\Application
STATE_END 6 Application state used by $state: application has ended. yii\base\Application
STATE_HANDLING_REQUEST 3 Application state used by $state: application is handling the request. yii\base\Application
STATE_INIT 1 Application state used by $state: application is initializing. yii\base\Application
STATE_SENDING_RESPONSE 5 Application state used by $state: application is about to send response. yii\base\Application

Property Details

Hide inherited properties

$errorHandler public property

The error handler component.

$mute public property

Mute the Applications ouput, this is used to make application cli tests with no output. The luya\console\Controller output/print methods are listening to this property.

public boolean $mute false

Method Details

Hide inherited methods

__call() public method

Defined in: yii\base\Component::__call()

Calls the named method which is not a class method.

This method will check if any attached behavior has the named method and will execute it if available.

Do not call this method directly as it is a PHP magic method that will be implicitly called when an unknown method is being invoked.

public mixed __call ( $name, $params )
$name string

The method name

$params array

Method parameters

return mixed

The method return value

throws yii\base\UnknownMethodException

when calling unknown method

                public function __call($name, $params)
{
    $this->ensureBehaviors();
    foreach ($this->_behaviors as $object) {
        if ($object->hasMethod($name)) {
            return call_user_func_array([$object, $name], $params);
        }
    }
    throw new UnknownMethodException('Calling unknown method: ' . get_class($this) . "::$name()");
}

            
__clone() public method

Defined in: yii\base\Component::__clone()

This method is called after the object is created by cloning an existing one.

It removes all behaviors because they are attached to the old object.

public void __clone ( )

                public function __clone()
{
    $this->_events = [];
    $this->_eventWildcards = [];
    $this->_behaviors = null;
}

            
__construct() public method

Defined in: yii\console\Application::__construct()

Constructor.

public void __construct ( $config = [] )
$config array

Name-value pairs that will be used to initialize the object properties. Note that the configuration must contain both $id and $basePath.

throws yii\base\InvalidConfigException

if either $id or $basePath configuration is missing.

                public function __construct($config = [])
{
    $config = $this->loadConfig($config);
    parent::__construct($config);
}

            
__get() public method

Defined in: yii\di\ServiceLocator::__get()

Getter magic method.

This method is overridden to support accessing components like reading properties.

public mixed __get ( $name )
$name string

Component or property name

return mixed

The named property value

                public function __get($name)
{
    if ($this->has($name)) {
        return $this->get($name);
    }
    return parent::__get($name);
}

            
__isset() public method

Defined in: yii\di\ServiceLocator::__isset()

Checks if a property value is null.

This method overrides the parent implementation by checking if the named component is loaded.

public boolean __isset ( $name )
$name string

The property name or the event name

return boolean

Whether the property value is null

                public function __isset($name)
{
    if ($this->has($name)) {
        return true;
    }
    return parent::__isset($name);
}

            
__set() public method

Defined in: yii\base\Component::__set()

Sets the value of a component property.

This method will check in the following order and act accordingly:

  • a property defined by a setter: set the property value
  • an event in the format of "on xyz": attach the handler to the event "xyz"
  • a behavior in the format of "as xyz": attach the behavior named as "xyz"
  • a property of a behavior: set the behavior property value

Do not call this method directly as it is a PHP magic method that will be implicitly called when executing $component->property = $value;.

See also __get().

public void __set ( $name, $value )
$name string

The property name or the event name

$value mixed

The property value

throws yii\base\UnknownPropertyException

if the property is not defined

throws yii\base\InvalidCallException

if the property is read-only.

                public function __set($name, $value)
{
    $setter = 'set' . $name;
    if (method_exists($this, $setter)) {
        // set property
        $this->$setter($value);
        return;
    } elseif (strncmp($name, 'on ', 3) === 0) {
        // on event: attach event handler
        $this->on(trim(substr($name, 3)), $value);
        return;
    } elseif (strncmp($name, 'as ', 3) === 0) {
        // as behavior: attach behavior
        $name = trim(substr($name, 3));
        $this->attachBehavior($name, $value instanceof Behavior ? $value : Yii::createObject($value));
        return;
    }
    // behavior property
    $this->ensureBehaviors();
    foreach ($this->_behaviors as $behavior) {
        if ($behavior->canSetProperty($name)) {
            $behavior->$name = $value;
            return;
        }
    }
    if (method_exists($this, 'get' . $name)) {
        throw new InvalidCallException('Setting read-only property: ' . get_class($this) . '::' . $name);
    }
    throw new UnknownPropertyException('Setting unknown property: ' . get_class($this) . '::' . $name);
}

            
__unset() public method

Defined in: yii\base\Component::__unset()

Sets a component property to be null.

This method will check in the following order and act accordingly:

  • a property defined by a setter: set the property value to be null
  • a property of a behavior: set the property value to be null

Do not call this method directly as it is a PHP magic method that will be implicitly called when executing unset($component->property).

See also https://www.php.net/manual/en/function.unset.php.

public void __unset ( $name )
$name string

The property name

throws yii\base\InvalidCallException

if the property is read only.

                public function __unset($name)
{
    $setter = 'set' . $name;
    if (method_exists($this, $setter)) {
        $this->$setter(null);
        return;
    }
    // behavior property
    $this->ensureBehaviors();
    foreach ($this->_behaviors as $behavior) {
        if ($behavior->canSetProperty($name)) {
            $behavior->$name = null;
            return;
        }
    }
    throw new InvalidCallException('Unsetting an unknown or read-only property: ' . get_class($this) . '::' . $name);
}

            
afterAction() public method

Defined in: yii\base\Module::afterAction()

This method is invoked right after an action within this module is executed.

The method will trigger the EVENT_AFTER_ACTION event. The return value of the method will be used as the action return value.

If you override this method, your code should look like the following:

public function afterAction($action, $result)
{
    $result = parent::afterAction($action, $result);
    // your custom code here
    return $result;
}
public mixed afterAction ( $action, $result )
$action yii\base\Action

The action just executed.

$result mixed

The action return result.

return mixed

The processed action result.

                public function afterAction($action, $result)
{
    $event = new ActionEvent($action);
    $event->result = $result;
    $this->trigger(self::EVENT_AFTER_ACTION, $event);
    return $event->result;
}

            
attachBehavior() public method

Defined in: yii\base\Component::attachBehavior()

Attaches a behavior to this component.

This method will create the behavior object based on the given configuration. After that, the behavior object will be attached to this component by calling the yii\base\Behavior::attach() method.

See also detachBehavior().

public yii\base\Behavior attachBehavior ( $name, $behavior )
$name string

The name of the behavior.

$behavior string|array|yii\base\Behavior

The behavior configuration. This can be one of the following:

return yii\base\Behavior

The behavior object

                public function attachBehavior($name, $behavior)
{
    $this->ensureBehaviors();
    return $this->attachBehaviorInternal($name, $behavior);
}

            
attachBehaviors() public method

Defined in: yii\base\Component::attachBehaviors()

Attaches a list of behaviors to the component.

Each behavior is indexed by its name and should be a yii\base\Behavior object, a string specifying the behavior class, or an configuration array for creating the behavior.

See also attachBehavior().

public void attachBehaviors ( $behaviors )
$behaviors array

List of behaviors to be attached to the component

                public function attachBehaviors($behaviors)
{
    $this->ensureBehaviors();
    foreach ($behaviors as $name => $behavior) {
        $this->attachBehaviorInternal($name, $behavior);
    }
}

            
beforeAction() public method

Defined in: yii\base\Module::beforeAction()

This method is invoked right before an action within this module is executed.

The method will trigger the EVENT_BEFORE_ACTION event. The return value of the method will determine whether the action should continue to run.

In case the action should not run, the request should be handled inside of the beforeAction code by either providing the necessary output or redirecting the request. Otherwise the response will be empty.

If you override this method, your code should look like the following:

public function beforeAction($action)
{
    if (!parent::beforeAction($action)) {
        return false;
    }

    // your custom code here

    return true; // or false to not run the action
}
public boolean beforeAction ( $action )
$action yii\base\Action

The action to be executed.

return boolean

Whether the action should continue to be executed.

                public function beforeAction($action)
{
    $event = new ActionEvent($action);
    $this->trigger(self::EVENT_BEFORE_ACTION, $event);
    return $event->isValid;
}

            
behaviors() public method

Defined in: yii\base\Component::behaviors()

Returns a list of behaviors that this component should behave as.

Child classes may override this method to specify the behaviors they want to behave as.

The return value of this method should be an array of behavior objects or configurations indexed by behavior names. A behavior configuration can be either a string specifying the behavior class or an array of the following structure:

'behaviorName' => [
    'class' => 'BehaviorClass',
    'property1' => 'value1',
    'property2' => 'value2',
]

Note that a behavior class must extend from yii\base\Behavior. Behaviors can be attached using a name or anonymously. When a name is used as the array key, using this name, the behavior can later be retrieved using getBehavior() or be detached using detachBehavior(). Anonymous behaviors can not be retrieved or detached.

Behaviors declared in this method will be attached to the component automatically (on demand).

public array behaviors ( )
return array

The behavior configurations.

                public function behaviors()
{
    return [];
}

            
bootstrap() protected method

Defined in: luya\traits\ApplicationTrait::bootstrap()

Initializes extensions and executes bootstrap components.

This method is called by init() after the application has been fully configured. If you override this method, make sure you also call the parent implementation.

protected void bootstrap ( )

                protected function bootstrap()
{
    foreach ($this->getPackageInstaller()->getConfigs() as $config) {
        $this->bootstrap = array_merge($this->bootstrap, $config->bootstrap);
    }
    
    parent::bootstrap();
}

            
canGetProperty() public method

Defined in: yii\base\Component::canGetProperty()

Returns a value indicating whether a property can be read.

A property can be read if:

  • the class has a getter method associated with the specified name (in this case, property name is case-insensitive);
  • the class has a member variable with the specified name (when $checkVars is true);
  • an attached behavior has a readable property of the given name (when $checkBehaviors is true).

See also canSetProperty().

public boolean canGetProperty ( $name, $checkVars true, $checkBehaviors true )
$name string

The property name

$checkVars boolean

Whether to treat member variables as properties

$checkBehaviors boolean

Whether to treat behaviors' properties as properties of this component

return boolean

Whether the property can be read

                public function canGetProperty($name, $checkVars = true, $checkBehaviors = true)
{
    if (method_exists($this, 'get' . $name) || $checkVars && property_exists($this, $name)) {
        return true;
    } elseif ($checkBehaviors) {
        $this->ensureBehaviors();
        foreach ($this->_behaviors as $behavior) {
            if ($behavior->canGetProperty($name, $checkVars)) {
                return true;
            }
        }
    }
    return false;
}

            
canSetProperty() public method

Defined in: yii\base\Component::canSetProperty()

Returns a value indicating whether a property can be set.

A property can be written if:

  • the class has a setter method associated with the specified name (in this case, property name is case-insensitive);
  • the class has a member variable with the specified name (when $checkVars is true);
  • an attached behavior has a writable property of the given name (when $checkBehaviors is true).

See also canGetProperty().

public boolean canSetProperty ( $name, $checkVars true, $checkBehaviors true )
$name string

The property name

$checkVars boolean

Whether to treat member variables as properties

$checkBehaviors boolean

Whether to treat behaviors' properties as properties of this component

return boolean

Whether the property can be written

                public function canSetProperty($name, $checkVars = true, $checkBehaviors = true)
{
    if (method_exists($this, 'set' . $name) || $checkVars && property_exists($this, $name)) {
        return true;
    } elseif ($checkBehaviors) {
        $this->ensureBehaviors();
        foreach ($this->_behaviors as $behavior) {
            if ($behavior->canSetProperty($name, $checkVars)) {
                return true;
            }
        }
    }
    return false;
}

            
className() public static method
Deprecated since 2.0.14. On PHP >=5.5, use ::class instead.

Defined in: yii\base\BaseObject::className()

Returns the fully qualified name of this class.

public static string className ( )
return string

The fully qualified name of this class.

                public static function className()
{
    return get_called_class();
}

            
clear() public method

Defined in: yii\di\ServiceLocator::clear()

Removes the component from the locator.

public void clear ( $id )
$id string

The component ID

                public function clear($id)
{
    unset($this->_definitions[$id], $this->_components[$id]);
}

            
coreCommands() public method

Provides an array with all LUYA core commands.

Instead of overriding the core command application and merged the value we directly copied them.

See also yii\console\Application::coreCommands().

public void coreCommands ( )

                public function coreCommands()
{
    return [
        // yii default commands
        'asset' => 'yii\console\controllers\AssetController',
        'cache' => 'yii\console\controllers\CacheController',
        'fixture' => 'yii\console\controllers\FixtureController',
        'help' => 'yii\console\controllers\HelpController',
        'message' => 'yii\console\controllers\MessageController',
        'serve' => [
            'class' => 'yii\console\controllers\ServeController',
            'docroot' => '@app/public_html',
        ],
        // luya default commands
        'migrate' => 'luya\console\commands\MigrateController',
        'module' => 'luya\console\commands\ModuleController',
        'theme' => 'luya\console\commands\ThemeController',
        'import' => 'luya\console\commands\ImportController',
        'health' => 'luya\console\commands\HealthController',
    ];
}

            
coreComponents() public method

Returns the configuration of core application components.

public array coreComponents ( )

                public function coreComponents()
{
    return array_merge($this->luyaCoreComponents(), [
        'errorHandler' => ['class' => 'luya\console\ErrorHandler'],
    ]);
}

            
createController() public method

Defined in: yii\base\Module::createController()

Creates a controller instance based on the given route.

The route should be relative to this module. The method implements the following algorithm to resolve the given route:

  1. If the route is empty, use $defaultRoute;
  2. If the first segment of the route is found in $controllerMap, create a controller based on the corresponding configuration found in $controllerMap;
  3. If the first segment of the route is a valid module ID as declared in $modules, call the module's createController() with the rest part of the route;
  4. The given route is in the format of abc/def/xyz. Try either abc\DefController or abc\def\XyzController class within the controller namespace.

If any of the above steps resolves into a controller, it is returned together with the rest part of the route which will be treated as the action ID. Otherwise, false will be returned.

public array|boolean createController ( $route )
$route string

The route consisting of module, controller and action IDs.

return array|boolean

If the controller is created successfully, it will be returned together with the requested action ID. Otherwise false will be returned.

throws yii\base\InvalidConfigException

if the controller class and its file do not match.

                public function createController($route)
{
    if ($route === '') {
        $route = $this->defaultRoute;
    }
    // double slashes or leading/ending slashes may cause substr problem
    $route = trim($route, '/');
    if (strpos($route, '//') !== false) {
        return false;
    }
    if (strpos($route, '/') !== false) {
        list($id, $route) = explode('/', $route, 2);
    } else {
        $id = $route;
        $route = '';
    }
    // module and controller map take precedence
    if (isset($this->controllerMap[$id])) {
        $controller = Yii::createObject($this->controllerMap[$id], [$id, $this]);
        return [$controller, $route];
    }
    $module = $this->getModule($id);
    if ($module !== null) {
        return $module->createController($route);
    }
    if (($pos = strrpos($route, '/')) !== false) {
        $id .= '/' . substr($route, 0, $pos);
        $route = substr($route, $pos + 1);
    }
    $controller = $this->createControllerByID($id);
    if ($controller === null && $route !== '') {
        $controller = $this->createControllerByID($id . '/' . $route);
        $route = '';
    }
    return $controller === null ? false : [$controller, $route];
}

            
createControllerByID() public method

Defined in: yii\base\Module::createControllerByID()

Creates a controller based on the given controller ID.

The controller ID is relative to this module. The controller class should be namespaced under $controllerNamespace.

Note that this method does not check $modules or $controllerMap.

public yii\base\Controller|null createControllerByID ( $id )
$id string

The controller ID.

return yii\base\Controller|null

The newly created controller instance, or null if the controller ID is invalid.

throws yii\base\InvalidConfigException

if the controller class and its file name do not match. This exception is only thrown when in debug mode.

                public function createControllerByID($id)
{
    $pos = strrpos($id, '/');
    if ($pos === false) {
        $prefix = '';
        $className = $id;
    } else {
        $prefix = substr($id, 0, $pos + 1);
        $className = substr($id, $pos + 1);
    }
    if ($this->isIncorrectClassNameOrPrefix($className, $prefix)) {
        return null;
    }
    $className = preg_replace_callback('%-([a-z0-9_])%i', function ($matches) {
            return ucfirst($matches[1]);
        }, ucfirst($className)) . 'Controller';
    $className = ltrim($this->controllerNamespace . '\\' . str_replace('/', '\\', $prefix) . $className, '\\');
    if (strpos($className, '-') !== false || !class_exists($className)) {
        return null;
    }
    if (is_subclass_of($className, 'yii\base\Controller')) {
        $controller = Yii::createObject($className, [$id, $this]);
        return get_class($controller) === $className ? $controller : null;
    } elseif (YII_DEBUG) {
        throw new InvalidConfigException('Controller class must extend from \\yii\\base\\Controller.');
    }
    return null;
}

            
defaultVersion() protected method (available since version 2.0.11)

Defined in: yii\base\Module::defaultVersion()

Returns default module version.

Child class may override this method to provide more specific version detection.

protected string defaultVersion ( )
return string

The version of this module.

                protected function defaultVersion()
{
    if ($this->module === null) {
        return '1.0';
    }
    return $this->module->getVersion();
}

            
detachBehavior() public method

Defined in: yii\base\Component::detachBehavior()

Detaches a behavior from the component.

The behavior's yii\base\Behavior::detach() method will be invoked.

public yii\base\Behavior|null detachBehavior ( $name )
$name string

The behavior's name.

return yii\base\Behavior|null

The detached behavior. Null if the behavior does not exist.

                public function detachBehavior($name)
{
    $this->ensureBehaviors();
    if (isset($this->_behaviors[$name])) {
        $behavior = $this->_behaviors[$name];
        unset($this->_behaviors[$name]);
        $behavior->detach();
        return $behavior;
    }
    return null;
}

            
detachBehaviors() public method

Defined in: yii\base\Component::detachBehaviors()

Detaches all behaviors from the component.

public void detachBehaviors ( )

                public function detachBehaviors()
{
    $this->ensureBehaviors();
    foreach ($this->_behaviors as $name => $behavior) {
        $this->detachBehavior($name);
    }
}

            
end() public method

Defined in: yii\base\Application::end()

Terminates the application.

This method replaces the exit() function by ensuring the application life cycle is completed before terminating the application.

public void end ( $status 0, $response null )
$status integer

The exit status (value 0 means normal exit while other values mean abnormal exit).

$response yii\base\Response|null

The response to be sent. If not set, the default application $response component will be used.

throws yii\base\ExitException

if the application is in testing mode

                public function end($status = 0, $response = null)
{
    if ($this->state === self::STATE_BEFORE_REQUEST || $this->state === self::STATE_HANDLING_REQUEST) {
        $this->state = self::STATE_AFTER_REQUEST;
        $this->trigger(self::EVENT_AFTER_REQUEST);
    }
    if ($this->state !== self::STATE_SENDING_RESPONSE && $this->state !== self::STATE_END) {
        $this->state = self::STATE_END;
        $response = $response ?: $this->getResponse();
        $response->send();
    }
    if (YII_ENV_TEST) {
        throw new ExitException($status);
    }
    exit($status);
}

            
ensureBehaviors() public method

Defined in: yii\base\Component::ensureBehaviors()

Makes sure that the behaviors declared in behaviors() are attached to this component.

public void ensureBehaviors ( )

                public function ensureBehaviors()
{
    if ($this->_behaviors === null) {
        $this->_behaviors = [];
        foreach ($this->behaviors() as $name => $behavior) {
            $this->attachBehaviorInternal($name, $behavior);
        }
    }
}

            
ensureLocale() public method

Defined in: luya\traits\ApplicationTrait::ensureLocale()

Transform the $language into a locale sign to set php env settings.

Example transform input de to de_CH when available $locales property as

'locales' => ['de' => 'de_CH']
public string ensureLocale ( $lang )
$lang string

Find the locale for the provided $lang short code.

return string

The localisation code for the provided lang short code.

                public function ensureLocale($lang)
{
    // see if the $lang is available in the $locales map.
    if (array_key_exists($lang, $this->locales)) {
        return $this->locales[$lang];
    }
    
    // generate from `de` the locale `de_DE` or from `en` `en_EN` only if $lang is 2 chars.
    if (strlen($lang) == 2) {
        return strtolower($lang) . '_' . strtoupper($lang);
    }
    
    return $lang;
}

            
get() public method

Defined in: yii\base\Module::get()

Returns the component instance with the specified ID.

Since version 2.0.13, if a component isn't defined in the module, it will be looked up in the parent module. The parent module may be the application.

public object|null get ( $id, $throwException true )
$id string

Component ID (e.g. db).

$throwException boolean

Whether to throw an exception if $id is not registered with the locator before.

return object|null

The component of the specified ID. If $throwException is false and $id is not registered before, null will be returned.

throws yii\base\InvalidConfigException

if $id refers to a nonexistent component ID

                public function get($id, $throwException = true)
{
    if (!isset($this->module)) {
        return parent::get($id, $throwException);
    }
    $component = parent::get($id, false);
    if ($component === null) {
        $component = $this->module->get($id, $throwException);
    }
    return $component;
}

            
getAdminModules() public method

Defined in: luya\traits\ApplicationTrait::getAdminModules()

Return all Admin Module Interface implementing modules.

public luya\base\AdminModuleInterface getAdminModules ( )

                public function getAdminModules()
{
    if ($this->_adminModules === null) {
        $this->_adminModules = [];
        foreach ($this->getModules() as $id => $obj) {
            if ($obj instanceof Module && $obj instanceof AdminModuleInterface) {
                $this->_adminModules[$id] = $obj;
            }
        }
    }
    return $this->_adminModules;
}

            
getAdminModulesAssets() public method (available since version 1.7.0)

Defined in: luya\traits\ApplicationTrait::getAdminModulesAssets()

Get all assets files from all admin modules

public array getAdminModulesAssets ( )

                public function getAdminModulesAssets()
{
    $assets = [];
    foreach ($this->getAdminModules() as $module) {
        $assets = array_merge($module->getAdminAssets(), $assets);
    }
    return $assets;
}

            
getAdminModulesJsTranslationMessages() public method (available since version 1.7.0)

Defined in: luya\traits\ApplicationTrait::getAdminModulesJsTranslationMessages()

Get all js translations from all admin modules

public array getAdminModulesJsTranslationMessages ( )

                public function getAdminModulesJsTranslationMessages()
{
    $jsTranslations = [];
    foreach ($this->getAdminModules() as $id => $module) {
        $jsTranslations[$id] = $module->getJsTranslationMessages();
    }
    return $jsTranslations;
}

            
getAdminModulesMenus() public method (available since version 1.7.0)

Defined in: luya\traits\ApplicationTrait::getAdminModulesMenus()

Get all admin menu modules

public array getAdminModulesMenus ( )
return array

An array where the key is the module id and value the menu array.

                public function getAdminModulesMenus()
{
    $menu = [];
    foreach($this->getAdminModules() as $module) {
        if ($module->getMenu()) {
            $menu[$module->id] = $module->getMenu();
        }
    }
    return $menu;
}

            
getApplicationModules() public method

Defined in: luya\traits\ApplicationTrait::getApplicationModules()

Get an array with all modules which are an instance of the luya\base\Module.

public luya\base\Module[] getApplicationModules ( )

                public function getApplicationModules()
{
    $modules = [];
    foreach ($this->getModules() as $id => $obj) {
        if ($obj instanceof Module) {
            $modules[$id] = $obj;
        }
    }
    return $modules;
}

            
getAssetManager() public method

Defined in: yii\base\Application::getAssetManager()

Returns the asset manager.

public yii\web\AssetManager getAssetManager ( )
return yii\web\AssetManager

The asset manager application component.

                public function getAssetManager()
{
    return $this->get('assetManager');
}

            
getAuthManager() public method

Defined in: yii\base\Application::getAuthManager()

Returns the auth manager for this application.

public yii\rbac\ManagerInterface|null getAuthManager ( )
return yii\rbac\ManagerInterface|null

The auth manager application component or null if it's not configured.

                public function getAuthManager()
{
    return $this->get('authManager', false);
}

            
getBasePath() public method

Defined in: yii\base\Module::getBasePath()

Returns the root directory of the module.

It defaults to the directory containing the module class file.

public string getBasePath ( )
return string

The root directory of the module.

                public function getBasePath()
{
    if ($this->_basePath === null) {
        $class = new \ReflectionClass($this);
        $this->_basePath = dirname($class->getFileName());
    }
    return $this->_basePath;
}

            
getBehavior() public method

Defined in: yii\base\Component::getBehavior()

Returns the named behavior object.

public yii\base\Behavior|null getBehavior ( $name )
$name string

The behavior name

return yii\base\Behavior|null

The behavior object, or null if the behavior does not exist

                public function getBehavior($name)
{
    $this->ensureBehaviors();
    return isset($this->_behaviors[$name]) ? $this->_behaviors[$name] : null;
}

            
getBehaviors() public method

Defined in: yii\base\Component::getBehaviors()

Returns all behaviors attached to this component.

public yii\base\Behavior[] getBehaviors ( )
return yii\base\Behavior[]

List of behaviors attached to this component

                public function getBehaviors()
{
    $this->ensureBehaviors();
    return $this->_behaviors;
}

            
getCache() public method

Defined in: yii\base\Application::getCache()

Returns the cache component.

public yii\caching\CacheInterface|null getCache ( )
return yii\caching\CacheInterface|null

The cache application component. Null if the component is not enabled.

                public function getCache()
{
    return $this->get('cache', false);
}

            
getComponents() public method

Defined in: yii\di\ServiceLocator::getComponents()

Returns the list of the component definitions or the loaded component instances.

public array getComponents ( $returnDefinitions true )
$returnDefinitions boolean

Whether to return component definitions instead of the loaded component instances.

return array

The list of the component definitions or the loaded component instances (ID => definition or instance).

                public function getComponents($returnDefinitions = true)
{
    return $returnDefinitions ? $this->_definitions : $this->_components;
}

            
getControllerPath() public method

Defined in: yii\base\Module::getControllerPath()

Returns the directory that contains the controller classes according to $controllerNamespace.

Note that in order for this method to return a value, you must define an alias for the root namespace of $controllerNamespace.

public string getControllerPath ( )
return string

The directory that contains the controller classes.

throws yii\base\InvalidArgumentException

if there is no alias defined for the root namespace of $controllerNamespace.

                public function getControllerPath()
{
    if ($this->_controllerPath === null) {
        $this->_controllerPath = Yii::getAlias('@' . str_replace('\\', '/', $this->controllerNamespace));
    }
    return $this->_controllerPath;
}

            
getDb() public method

Defined in: yii\base\Application::getDb()

Returns the database connection component.

public yii\db\Connection getDb ( )
return yii\db\Connection

The database connection.

                public function getDb()
{
    return $this->get('db');
}

            
getErrorHandler() public method

Defined in: yii\console\Application::getErrorHandler()

Returns the error handler component.

public yii\console\ErrorHandler getErrorHandler ( )
return yii\console\ErrorHandler

The error handler application component.

                public function getErrorHandler()
{
    return $this->get('errorHandler');
}

            
getFormatter() public method

Defined in: yii\base\Application::getFormatter()

Returns the formatter component.

public yii\i18n\Formatter getFormatter ( )
return yii\i18n\Formatter

The formatter application component.

                public function getFormatter()
{
    return $this->get('formatter');
}

            
getFrontendModules() public method

Defined in: luya\traits\ApplicationTrait::getFrontendModules()

Return a list with all registered frontend modules except 'luya' and 'cms'. This is needed in the module block.

public luya\base\Module getFrontendModules ( )

                public function getFrontendModules()
{
    $modules = [];
    foreach ($this->getModules() as $id => $obj) {
        if ($obj instanceof Module && !$obj instanceof AdminModuleInterface && !$obj instanceof CoreModuleInterface) {
            $modules[$id] = $obj;
        }
    }
    return $modules;
}

            
getI18n() public method

Defined in: yii\base\Application::getI18n()

Returns the internationalization (i18n) component.

public yii\i18n\I18N getI18n ( )
return yii\i18n\I18N

The internationalization application component.

                public function getI18n()
{
    return $this->get('i18n');
}

            
getInstance() public static method

Defined in: yii\base\Module::getInstance()

Returns the currently requested instance of this module class.

If the module class is not currently requested, null will be returned. This method is provided so that you access the module instance from anywhere within the module.

public static static|null getInstance ( )
return yii\base\Module|null

The currently requested instance of this module class, or null if the module class is not requested.

                public static function getInstance()
{
    $class = get_called_class();
    return isset(Yii::$app->loadedModules[$class]) ? Yii::$app->loadedModules[$class] : null;
}

            
getLayoutPath() public method

Defined in: yii\base\Module::getLayoutPath()

Returns the directory that contains layout view files for this module.

public string getLayoutPath ( )
return string

The root directory of layout files. Defaults to "$viewPath/layouts".

                public function getLayoutPath()
{
    if ($this->_layoutPath === null) {
        $this->_layoutPath = $this->getViewPath() . DIRECTORY_SEPARATOR . 'layouts';
    }
    return $this->_layoutPath;
}

            
getLog() public method

Defined in: yii\base\Application::getLog()

Returns the log dispatcher component.

public yii\log\Dispatcher getLog ( )
return yii\log\Dispatcher

The log dispatcher application component.

                public function getLog()
{
    return $this->get('log');
}

            
getMailer() public method

Defined in: yii\base\Application::getMailer()

Returns the mailer component.

public yii\mail\MailerInterface getMailer ( )
return yii\mail\MailerInterface

The mailer application component.

throws yii\base\InvalidConfigException

If this component is not configured.

                public function getMailer()
{
    return $this->get('mailer');
}

            
getModule() public method

Defined in: yii\base\Module::getModule()

Retrieves the child module of the specified ID.

This method supports retrieving both child modules and grand child modules.

See also hasModule().

public yii\base\Module|null getModule ( $id, $load true )
$id string

Module ID (case-sensitive). To retrieve grand child modules, use ID path relative to this module (e.g. admin/content).

$load boolean

Whether to load the module if it is not yet loaded.

return yii\base\Module|null

The module instance, null if the module does not exist.

                public function getModule($id, $load = true)
{
    if (($pos = strpos($id, '/')) !== false) {
        // sub-module
        $module = $this->getModule(substr($id, 0, $pos));
        return $module === null ? null : $module->getModule(substr($id, $pos + 1), $load);
    }
    if (isset($this->_modules[$id])) {
        if ($this->_modules[$id] instanceof self) {
            return $this->_modules[$id];
        } elseif ($load) {
            Yii::debug("Loading module: $id", __METHOD__);
            /* @var $module Module */
            $module = Yii::createObject($this->_modules[$id], [$id, $this]);
            $module::setInstance($module);
            return $this->_modules[$id] = $module;
        }
    }
    return null;
}

            
getModules() public method

Defined in: yii\base\Module::getModules()

Returns the sub-modules in this module.

public array getModules ( $loadedOnly false )
$loadedOnly boolean

Whether to return the loaded sub-modules only. If this is set false, then all sub-modules registered in this module will be returned, whether they are loaded or not. Loaded modules will be returned as objects, while unloaded modules as configuration arrays.

return array

The modules (indexed by their IDs).

                public function getModules($loadedOnly = false)
{
    if ($loadedOnly) {
        $modules = [];
        foreach ($this->_modules as $module) {
            if ($module instanceof self) {
                $modules[] = $module;
            }
        }
        return $modules;
    }
    return $this->_modules;
}

            
getPackageInstaller() public method

Defined in: luya\traits\ApplicationTrait::getPackageInstaller()

Get the package Installer

public luya\base\PackageInstaller getPackageInstaller ( )

                public function getPackageInstaller()
{
    if ($this->_packageInstaller == null) {
        $file = Yii::getAlias('@vendor/luyadev/installer.php');
    
        $data = is_file($file) ? include $file : [];
    
        $this->_packageInstaller = new PackageInstaller($data);
    }
    
    return $this->_packageInstaller;
}

            
getRequest() public method

Defined in: yii\console\Application::getRequest()

Returns the request component.

public yii\console\Request getRequest ( )
return yii\console\Request

The request component.

                public function getRequest()
{
    return $this->get('request');
}

            
getResponse() public method

Defined in: yii\console\Application::getResponse()

Returns the response component.

public yii\console\Response getResponse ( )
return yii\console\Response

The response component.

                public function getResponse()
{
    return $this->get('response');
}

            
getRuntimePath() public method

Defined in: yii\base\Application::getRuntimePath()

Returns the directory that stores runtime files.

public string getRuntimePath ( )
return string

The directory that stores runtime files. Defaults to the "runtime" subdirectory under $basePath.

                public function getRuntimePath()
{
    if ($this->_runtimePath === null) {
        $this->setRuntimePath($this->getBasePath() . DIRECTORY_SEPARATOR . 'runtime');
    }
    return $this->_runtimePath;
}

            
getSecurity() public method

Defined in: yii\base\Application::getSecurity()

Returns the security component.

public yii\base\Security getSecurity ( )
return yii\base\Security

The security application component.

                public function getSecurity()
{
    return $this->get('security');
}

            
getTimeZone() public method

Defined in: yii\base\Application::getTimeZone()

Returns the time zone used by this application.

This is a simple wrapper of PHP function date_default_timezone_get(). If time zone is not configured in php.ini or application config, it will be set to UTC by default.

See also https://www.php.net/manual/en/function.date-default-timezone-get.php.

public string getTimeZone ( )
return string

The time zone used by this application.

                public function getTimeZone()
{
    return date_default_timezone_get();
}

            
getUniqueId() public method

Defined in: yii\base\Application::getUniqueId()

Returns an ID that uniquely identifies this module among all modules within the current application.

Since this is an application instance, it will always return an empty string.

public string getUniqueId ( )
return string

The unique ID of the module.

                public function getUniqueId()
{
    return '';
}

            
getUrlManager() public method

Defined in: yii\base\Application::getUrlManager()

Returns the URL manager for this application.

public yii\web\UrlManager getUrlManager ( )
return yii\web\UrlManager

The URL manager for this application.

                public function getUrlManager()
{
    return $this->get('urlManager');
}

            
getVendorPath() public method

Defined in: yii\base\Application::getVendorPath()

Returns the directory that stores vendor files.

public string getVendorPath ( )
return string

The directory that stores vendor files. Defaults to "vendor" directory under $basePath.

                public function getVendorPath()
{
    if ($this->_vendorPath === null) {
        $this->setVendorPath($this->getBasePath() . DIRECTORY_SEPARATOR . 'vendor');
    }
    return $this->_vendorPath;
}

            
getVersion() public method (available since version 2.0.11)

Defined in: yii\base\Module::getVersion()

Returns current module version.

If version is not explicitly set, defaultVersion() method will be used to determine its value.

public string getVersion ( )
return string

The version of this module.

                public function getVersion()
{
    if ($this->_version === null) {
        $this->_version = $this->defaultVersion();
    } else {
        if (!is_scalar($this->_version)) {
            $this->_version = call_user_func($this->_version, $this);
        }
    }
    return $this->_version;
}

            
getView() public method

Defined in: yii\base\Application::getView()

Returns the view object.

public yii\base\View|yii\web\View getView ( )
return yii\base\View|yii\web\View

The view application component that is used to render various view files.

                public function getView()
{
    return $this->get('view');
}

            
getViewPath() public method

Defined in: yii\base\Module::getViewPath()

Returns the directory that contains the view files for this module.

public string getViewPath ( )
return string

The root directory of view files. Defaults to "$basePath/views".

                public function getViewPath()
{
    if ($this->_viewPath === null) {
        $this->_viewPath = $this->getBasePath() . DIRECTORY_SEPARATOR . 'views';
    }
    return $this->_viewPath;
}

            
getWebroot() public method

Defined in: luya\traits\ApplicationTrait::getWebroot()

Read only property which is used in cli bootstrap process to set the @webroot alias

Yii::setAlias('@webroot', $app->webroot);
public string getWebroot ( )
return string

The webroot of the application.

                public function getWebroot()
{
    if ($this->_webroot === null) {
        $this->_webroot = realpath(realpath($this->basePath) . DIRECTORY_SEPARATOR . $this->webrootDirectory);
    }
    
    return $this->_webroot;
}

            
handleRequest() public method

Defined in: yii\console\Application::handleRequest()

Handles the specified request.

public yii\console\Response handleRequest ( $request )
$request yii\console\Request

The request to be handled

return yii\console\Response

The resulting response

                public function handleRequest($request)
{
    list($route, $params) = $request->resolve();
    $this->requestedRoute = $route;
    $result = $this->runAction($route, $params);
    if ($result instanceof Response) {
        return $result;
    }
    $response = $this->getResponse();
    $response->exitStatus = $result;
    return $response;
}

            
has() public method

Defined in: yii\base\Module::has()

Returns a value indicating whether the locator has the specified component definition or has instantiated the component.

Since version 2.0.13, if a component isn't defined in the module, it will be looked up in the parent module. The parent module may be the application.

This method may return different results depending on the value of $checkInstance.

  • If $checkInstance is false (default), the method will return a value indicating whether the locator has the specified component definition.
  • If $checkInstance is true, the method will return a value indicating whether the locator has instantiated the specified component.
public boolean has ( $id, $checkInstance false )
$id string

Component ID (e.g. db).

$checkInstance boolean

Whether the method should check if the component is shared and instantiated.

return boolean

Whether the locator has the specified component definition or has instantiated the component.

                public function has($id, $checkInstance = false)
{
    return parent::has($id, $checkInstance) || (isset($this->module) && $this->module->has($id, $checkInstance));
}

            
hasEventHandlers() public method

Defined in: yii\base\Component::hasEventHandlers()

Returns a value indicating whether there is any handler attached to the named event.

public boolean hasEventHandlers ( $name )
$name string

The event name

return boolean

Whether there is any handler attached to the event.

                public function hasEventHandlers($name)
{
    $this->ensureBehaviors();
    if (!empty($this->_events[$name])) {
        return true;
    }
    foreach ($this->_eventWildcards as $wildcard => $handlers) {
        if (!empty($handlers) && StringHelper::matchWildcard($wildcard, $name)) {
            return true;
        }
    }
    return Event::hasHandlers($this, $name);
}

            
hasMethod() public method

Defined in: yii\base\Component::hasMethod()

Returns a value indicating whether a method is defined.

A method is defined if:

  • the class has a method with the specified name
  • an attached behavior has a method with the given name (when $checkBehaviors is true).
public boolean hasMethod ( $name, $checkBehaviors true )
$name string

The property name

$checkBehaviors boolean

Whether to treat behaviors' methods as methods of this component

return boolean

Whether the method is defined

                public function hasMethod($name, $checkBehaviors = true)
{
    if (method_exists($this, $name)) {
        return true;
    } elseif ($checkBehaviors) {
        $this->ensureBehaviors();
        foreach ($this->_behaviors as $behavior) {
            if ($behavior->hasMethod($name)) {
                return true;
            }
        }
    }
    return false;
}

            
hasModule() public method

Defined in: yii\base\Module::hasModule()

Checks whether the child module of the specified ID exists.

This method supports checking the existence of both child and grand child modules.

public boolean hasModule ( $id )
$id string

Module ID. For grand child modules, use ID path relative to this module (e.g. admin/content).

return boolean

Whether the named module exists. Both loaded and unloaded modules are considered.

                public function hasModule($id)
{
    if (($pos = strpos($id, '/')) !== false) {
        // sub-module
        $module = $this->getModule(substr($id, 0, $pos));
        return $module === null ? false : $module->hasModule(substr($id, $pos + 1));
    }
    return isset($this->_modules[$id]);
}

            
hasProperty() public method

Defined in: yii\base\Component::hasProperty()

Returns a value indicating whether a property is defined for this component.

A property is defined if:

  • the class has a getter or setter method associated with the specified name (in this case, property name is case-insensitive);
  • the class has a member variable with the specified name (when $checkVars is true);
  • an attached behavior has a property of the given name (when $checkBehaviors is true).

See also:

public boolean hasProperty ( $name, $checkVars true, $checkBehaviors true )
$name string

The property name

$checkVars boolean

Whether to treat member variables as properties

$checkBehaviors boolean

Whether to treat behaviors' properties as properties of this component

return boolean

Whether the property is defined

                public function hasProperty($name, $checkVars = true, $checkBehaviors = true)
{
    return $this->canGetProperty($name, $checkVars, $checkBehaviors) || $this->canSetProperty($name, false, $checkBehaviors);
}

            
init() public method

Defined in: luya\traits\ApplicationTrait::init()

Add trace info to luya application trait

public void init ( )

                public function init()
{
    parent::init();
    
    // add trace info
    Yii::debug('initialize LUYA Application', __METHOD__);
    
    $this->setLocale($this->language);
}

            
loadConfig() protected method

Defined in: yii\console\Application::loadConfig()

Loads the configuration.

This method will check if the command line option OPTION_APPCONFIG is specified. If so, the corresponding file will be loaded as the application configuration. Otherwise, the configuration provided as the parameter will be returned back.

protected array loadConfig ( $config )
$config array

The configuration provided in the constructor.

return array

The actual configuration to be used by the application.

                protected function loadConfig($config)
{
    if (!empty($_SERVER['argv'])) {
        $option = '--' . self::OPTION_APPCONFIG . '=';
        foreach ($_SERVER['argv'] as $param) {
            if (strpos($param, $option) !== false) {
                $path = substr($param, strlen($option));
                if (!empty($path) && is_file($file = Yii::getAlias($path))) {
                    return require $file;
                }
                exit("The configuration file does not exist: $path\n");
            }
        }
    }
    return $config;
}

            
luyaCoreComponents() public method

Defined in: luya\traits\ApplicationTrait::luyaCoreComponents()

Add additional core components to the yii2 base core components.

public array luyaCoreComponents ( )

                public function luyaCoreComponents()
{
    return array_merge(parent::coreComponents(), [
        'mail' => ['class' => 'luya\components\Mail'],
        'formatter' => ['class' => 'luya\components\Formatter'],
        'themeManager' => ['class' => 'luya\theme\ThemeManager'],
    ]);
}

            
off() public method

Defined in: yii\base\Component::off()

Detaches an existing event handler from this component.

This method is the opposite of on().

Note: in case wildcard pattern is passed for event name, only the handlers registered with this wildcard will be removed, while handlers registered with plain names matching this wildcard will remain.

See also on().

public boolean off ( $name, $handler null )
$name string

Event name

$handler callable|null

The event handler to be removed. If it is null, all handlers attached to the named event will be removed.

return boolean

If a handler is found and detached

                public function off($name, $handler = null)
{
    $this->ensureBehaviors();
    if (empty($this->_events[$name]) && empty($this->_eventWildcards[$name])) {
        return false;
    }
    if ($handler === null) {
        unset($this->_events[$name], $this->_eventWildcards[$name]);
        return true;
    }
    $removed = false;
    // plain event names
    if (isset($this->_events[$name])) {
        foreach ($this->_events[$name] as $i => $event) {
            if ($event[0] === $handler) {
                unset($this->_events[$name][$i]);
                $removed = true;
            }
        }
        if ($removed) {
            $this->_events[$name] = array_values($this->_events[$name]);
            return true;
        }
    }
    // wildcard event names
    if (isset($this->_eventWildcards[$name])) {
        foreach ($this->_eventWildcards[$name] as $i => $event) {
            if ($event[0] === $handler) {
                unset($this->_eventWildcards[$name][$i]);
                $removed = true;
            }
        }
        if ($removed) {
            $this->_eventWildcards[$name] = array_values($this->_eventWildcards[$name]);
            // remove empty wildcards to save future redundant regex checks:
            if (empty($this->_eventWildcards[$name])) {
                unset($this->_eventWildcards[$name]);
            }
        }
    }
    return $removed;
}

            
on() public method

Defined in: yii\base\Component::on()

Attaches an event handler to an event.

The event handler must be a valid PHP callback. The following are some examples:

function ($event) { ... }         // anonymous function
[$object, 'handleClick']          // $object->handleClick()
['Page', 'handleClick']           // Page::handleClick()
'handleClick'                     // global function handleClick()

The event handler must be defined with the following signature,

function ($event)

where $event is an yii\base\Event object which includes parameters associated with the event.

Since 2.0.14 you can specify event name as a wildcard pattern:

$component->on('event.group.*', function ($event) {
    Yii::trace($event->name . ' is triggered.');
});

See also off().

public void on ( $name, $handler, $data null, $append true )
$name string

The event name

$handler callable

The event handler

$data mixed

The data to be passed to the event handler when the event is triggered. When the event handler is invoked, this data can be accessed via yii\base\Event::$data.

$append boolean

Whether to append new event handler to the end of the existing handler list. If false, the new handler will be inserted at the beginning of the existing handler list.

                public function on($name, $handler, $data = null, $append = true)
{
    $this->ensureBehaviors();
    if (strpos($name, '*') !== false) {
        if ($append || empty($this->_eventWildcards[$name])) {
            $this->_eventWildcards[$name][] = [$handler, $data];
        } else {
            array_unshift($this->_eventWildcards[$name], [$handler, $data]);
        }
        return;
    }
    if ($append || empty($this->_events[$name])) {
        $this->_events[$name][] = [$handler, $data];
    } else {
        array_unshift($this->_events[$name], [$handler, $data]);
    }
}

            
preInit() public method

Defined in: yii\base\Application::preInit()

Pre-initializes the application.

This method is called at the beginning of the application constructor. It initializes several important application properties. If you override this method, please make sure you call the parent implementation.

public void preInit ( &$config )
$config array

The application configuration

throws yii\base\InvalidConfigException

if either $id or $basePath configuration is missing.

                public function preInit(&$config)
{
    if (!isset($config['id'])) {
        throw new InvalidConfigException('The "id" configuration for the Application is required.');
    }
    if (isset($config['basePath'])) {
        $this->setBasePath($config['basePath']);
        unset($config['basePath']);
    } else {
        throw new InvalidConfigException('The "basePath" configuration for the Application is required.');
    }
    if (isset($config['vendorPath'])) {
        $this->setVendorPath($config['vendorPath']);
        unset($config['vendorPath']);
    } else {
        // set "@vendor"
        $this->getVendorPath();
    }
    if (isset($config['runtimePath'])) {
        $this->setRuntimePath($config['runtimePath']);
        unset($config['runtimePath']);
    } else {
        // set "@runtime"
        $this->getRuntimePath();
    }
    if (isset($config['timeZone'])) {
        $this->setTimeZone($config['timeZone']);
        unset($config['timeZone']);
    } elseif (!ini_get('date.timezone')) {
        $this->setTimeZone('UTC');
    }
    if (isset($config['container'])) {
        $this->setContainer($config['container']);
        unset($config['container']);
    }
    // merge core components with custom components
    foreach ($this->coreComponents() as $id => $component) {
        if (!isset($config['components'][$id])) {
            $config['components'][$id] = $component;
        } elseif (is_array($config['components'][$id]) && !isset($config['components'][$id]['class'])) {
            $config['components'][$id]['class'] = $component['class'];
        }
    }
}

            
registerErrorHandler() protected method

Defined in: yii\base\Application::registerErrorHandler()

Registers the errorHandler component as a PHP error handler.

protected void registerErrorHandler ( &$config )
$config array

Application config

                protected function registerErrorHandler(&$config)
{
    if (YII_ENABLE_ERROR_HANDLER) {
        if (!isset($config['components']['errorHandler']['class'])) {
            echo "Error: no errorHandler component is configured.\n";
            exit(1);
        }
        $this->set('errorHandler', $config['components']['errorHandler']);
        unset($config['components']['errorHandler']);
        $this->getErrorHandler()->register();
    }
}

            
run() public method

Defined in: yii\base\Application::run()

Runs the application.

This is the main entrance of an application.

public integer run ( )
return integer

The exit status (0 means normal, non-zero values mean abnormal)

                public function run()
{
    try {
        $this->state = self::STATE_BEFORE_REQUEST;
        $this->trigger(self::EVENT_BEFORE_REQUEST);
        $this->state = self::STATE_HANDLING_REQUEST;
        $response = $this->handleRequest($this->getRequest());
        $this->state = self::STATE_AFTER_REQUEST;
        $this->trigger(self::EVENT_AFTER_REQUEST);
        $this->state = self::STATE_SENDING_RESPONSE;
        $response->send();
        $this->state = self::STATE_END;
        return $response->exitStatus;
    } catch (ExitException $e) {
        $this->end($e->statusCode, isset($response) ? $response : null);
        return $e->statusCode;
    }
}

            
runAction() public method

Defined in: yii\console\Application::runAction()

Runs a controller action specified by a route.

This method parses the specified route and creates the corresponding child module(s), controller and action instances. It then calls yii\console\Controller::runAction() to run the action with the given parameters. If the route is empty, the method will use $defaultRoute.

For example, to run public function actionTest($a, $b) assuming that the controller has options the following code should be used:

\Yii::$app->runAction('controller/test', ['option' => 'value', $a, $b]);
public integer|yii\console\Response|null runAction ( $route, $params = [] )
$route string

The route that specifies the action.

$params array

The parameters to be passed to the action

return integer|yii\console\Response|null

The result of the action. This can be either an exit code or Response object. Exit code 0 means normal, and other values mean abnormal. Exit code of null is treated as 0 as well.

throws yii\console\Exception

if the route is invalid

                public function runAction($route, $params = [])
{
    try {
        $res = parent::runAction($route, $params);
        return is_object($res) ? $res : (int) $res;
    } catch (InvalidRouteException $e) {
        throw new UnknownCommandException($route, $this, 0, $e);
    }
}

            
set() public method

Defined in: yii\di\ServiceLocator::set()

Registers a component definition with this locator.

For example,

// a class name
$locator->set('cache', 'yii\caching\FileCache');

// a configuration array
$locator->set('db', [
    'class' => 'yii\db\Connection',
    'dsn' => 'mysql:host=127.0.0.1;dbname=demo',
    'username' => 'root',
    'password' => '',
    'charset' => 'utf8',
]);

// an anonymous function
$locator->set('cache', function ($params) {
    return new \yii\caching\FileCache;
});

// an instance
$locator->set('cache', new \yii\caching\FileCache);

If a component definition with the same ID already exists, it will be overwritten.

public void set ( $id, $definition )
$id string

Component ID (e.g. db).

$definition mixed

The component definition to be registered with this locator. It can be one of the following:

  • a class name
  • a configuration array: the array contains name-value pairs that will be used to initialize the property values of the newly created object when get() is called. The class element is required and stands for the the class of the object to be created.
  • a PHP callable: either an anonymous function or an array representing a class method (e.g. ['Foo', 'bar']). The callable will be called by get() to return an object associated with the specified component ID.
  • an object: When get() is called, this object will be returned.
throws yii\base\InvalidConfigException

if the definition is an invalid configuration array

                public function set($id, $definition)
{
    unset($this->_components[$id]);
    if ($definition === null) {
        unset($this->_definitions[$id]);
        return;
    }
    if (is_object($definition) || is_callable($definition, true)) {
        // an object, a class name, or a PHP callable
        $this->_definitions[$id] = $definition;
    } elseif (is_array($definition)) {
        // a configuration array
        if (isset($definition['__class'])) {
            $this->_definitions[$id] = $definition;
            $this->_definitions[$id]['class'] = $definition['__class'];
            unset($this->_definitions[$id]['__class']);
        } elseif (isset($definition['class'])) {
            $this->_definitions[$id] = $definition;
        } else {
            throw new InvalidConfigException("The configuration for the \"$id\" component must contain a \"class\" element.");
        }
    } else {
        throw new InvalidConfigException("Unexpected configuration type for the \"$id\" component: " . gettype($definition));
    }
}

            
setAliases() public method

Defined in: yii\base\Module::setAliases()

Defines path aliases.

This method calls Yii::setAlias() to register the path aliases. This method is provided so that you can define path aliases when configuring a module.

public void setAliases ( $aliases )
$aliases array

List of path aliases to be defined. The array keys are alias names (must start with @) and the array values are the corresponding paths or aliases. For example,

[
    '@models' => '@app/models', // an existing alias
    '@backend' => __DIR__ . '/../backend',  // a directory
]

                public function setAliases($aliases)
{
    foreach ($aliases as $name => $alias) {
        Yii::setAlias($name, $alias);
    }
}

            
setBasePath() public method

Defined in: yii\base\Application::setBasePath()

Sets the root directory of the application and the @app alias.

This method can only be invoked at the beginning of the constructor.

public void setBasePath ( $path )
$path string

The root directory of the application.

throws yii\base\InvalidArgumentException

if the directory does not exist.

                public function setBasePath($path)
{
    parent::setBasePath($path);
    Yii::setAlias('@app', $this->getBasePath());
}

            
setComponents() public method

Defined in: yii\di\ServiceLocator::setComponents()

Registers a set of component definitions in this locator.

This is the bulk version of set(). The parameter should be an array whose keys are component IDs and values the corresponding component definitions.

For more details on how to specify component IDs and definitions, please refer to set().

If a component definition with the same ID already exists, it will be overwritten.

The following is an example for registering two component definitions:

[
    'db' => [
        'class' => 'yii\db\Connection',
        'dsn' => 'sqlite:path/to/file.db',
    ],
    'cache' => [
        'class' => 'yii\caching\DbCache',
        'db' => 'db',
    ],
]
public void setComponents ( $components )
$components array

Component definitions or instances

                public function setComponents($components)
{
    foreach ($components as $id => $component) {
        $this->set($id, $component);
    }
}

            
setContainer() public method (available since version 2.0.11)

Defined in: yii\base\Application::setContainer()

Configures Yii::$container with the $config.

public void setContainer ( $config )
$config array

Values given in terms of name-value pairs

                public function setContainer($config)
{
    Yii::configure(Yii::$container, $config);
}

            
setControllerPath() public method (available since version 2.0.44)

Defined in: yii\base\Module::setControllerPath()

Sets the directory that contains the controller classes.

public void setControllerPath ( $path )
$path string

The root directory that contains the controller classes.

throws yii\base\InvalidArgumentException

if the directory is invalid.

                public function setControllerPath($path)
{
    $this->_controllerPath = Yii::getAlias($path);
}

            
setInstance() public static method

Defined in: yii\base\Module::setInstance()

Sets the currently requested instance of this module class.

public static void setInstance ( $instance )
$instance yii\base\Module|null

The currently requested instance of this module class. If it is null, the instance of the calling class will be removed, if any.

                public static function setInstance($instance)
{
    if ($instance === null) {
        unset(Yii::$app->loadedModules[get_called_class()]);
    } else {
        Yii::$app->loadedModules[get_class($instance)] = $instance;
    }
}

            
setLayoutPath() public method

Defined in: yii\base\Module::setLayoutPath()

Sets the directory that contains the layout files.

public void setLayoutPath ( $path )
$path string

The root directory or path alias of layout files.

throws yii\base\InvalidArgumentException

if the directory is invalid

                public function setLayoutPath($path)
{
    $this->_layoutPath = Yii::getAlias($path);
}

            
setLocale() public method

Defined in: luya\traits\ApplicationTrait::setLocale()

Set the application localisation trough setlocale.

The value will be parsed trough {{ensureLocale()}} in order to generated different possible localisation values like en_EN or en_EN.utf8 and it will generate from de a locale value like de_DE.

setlocale() can have multiple arguments:

If locale is an array or followed by additional parameters then each array element or parameter is tried to be set as new locale until success. This is useful if a locale is known under different names on different systems or for providing a fallback for a possibly not available locale.

public void setLocale ( $lang )
$lang string

The language short code to set the locale for.

                public function setLocale($lang)
{
    $locale = str_replace(['.utf8', '.UTF-8'], '', $this->ensureLocale($lang));
    setlocale(LC_ALL, $locale.'.utf8', $locale.'UTF-8', $locale);
}

            
setModule() public method

Defined in: yii\base\Module::setModule()

Adds a sub-module to this module.

public void setModule ( $id, $module )
$id string

Module ID.

$module yii\base\Module|array|null

The sub-module to be added to this module. This can be one of the following:

  • a yii\base\Module object
  • a configuration array: when getModule() is called initially, the array will be used to instantiate the sub-module
  • null: the named sub-module will be removed from this module

                public function setModule($id, $module)
{
    if ($module === null) {
        unset($this->_modules[$id]);
    } else {
        $this->_modules[$id] = $module;
        if ($module instanceof self) {
            $module->module = $this;
        }
    }
}

            
setModules() public method

Defined in: yii\base\Module::setModules()

Registers sub-modules in the current module.

Each sub-module should be specified as a name-value pair, where name refers to the ID of the module and value the module or a configuration array that can be used to create the module. In the latter case, Yii::createObject() will be used to create the module.

If a new sub-module has the same ID as an existing one, the existing one will be overwritten silently.

The following is an example for registering two sub-modules:

[
    'comment' => [
        'class' => 'app\modules\comment\CommentModule',
        'db' => 'db',
    ],
    'booking' => ['class' => 'app\modules\booking\BookingModule'],
]
public void setModules ( $modules )
$modules array

Modules (id => module configuration or instances).

                public function setModules($modules)
{
    foreach ($modules as $id => $module) {
        $this->_modules[$id] = $module;
        if ($module instanceof self) {
            $module->module = $this;
        }
    }
}

            
setRuntimePath() public method

Defined in: yii\base\Application::setRuntimePath()

Sets the directory that stores runtime files.

public void setRuntimePath ( $path )
$path string

The directory that stores runtime files.

                public function setRuntimePath($path)
{
    $this->_runtimePath = Yii::getAlias($path);
    Yii::setAlias('@runtime', $this->_runtimePath);
}

            
setTimeZone() public method

Defined in: yii\base\Application::setTimeZone()

Sets the time zone used by this application.

This is a simple wrapper of PHP function date_default_timezone_set(). Refer to the php manual for available timezones.

See also https://www.php.net/manual/en/function.date-default-timezone-set.php.

public void setTimeZone ( $value )
$value string

The time zone used by this application.

                public function setTimeZone($value)
{
    date_default_timezone_set($value);
}

            
setVendorPath() public method

Defined in: yii\base\Application::setVendorPath()

Sets the directory that stores vendor files.

public void setVendorPath ( $path )
$path string

The directory that stores vendor files.

                public function setVendorPath($path)
{
    $this->_vendorPath = Yii::getAlias($path);
    Yii::setAlias('@vendor', $this->_vendorPath);
    Yii::setAlias('@bower', $this->_vendorPath . DIRECTORY_SEPARATOR . 'bower');
    Yii::setAlias('@npm', $this->_vendorPath . DIRECTORY_SEPARATOR . 'npm');
}

            
setVersion() public method (available since version 2.0.11)

Defined in: yii\base\Module::setVersion()

Sets current module version.

public void setVersion ( $version )
$version string|callable|null

The version of this module. Version can be specified as a PHP callback, which can accept module instance as an argument and should return the actual version. For example:

function (Module $module) {
    //return string
}

                public function setVersion($version)
{
    $this->_version = $version;
}

            
setViewPath() public method

Defined in: yii\base\Module::setViewPath()

Sets the directory that contains the view files.

public void setViewPath ( $path )
$path string

The root directory of view files.

throws yii\base\InvalidArgumentException

if the directory is invalid.

                public function setViewPath($path)
{
    $this->_viewPath = Yii::getAlias($path);
}

            
trigger() public method

Defined in: yii\base\Component::trigger()

Triggers an event.

This method represents the happening of an event. It invokes all attached handlers for the event including class-level handlers.

public void trigger ( $name, yii\base\Event $event null )
$name string

The event name

$event yii\base\Event|null

The event instance. If not set, a default yii\base\Event object will be created.

                public function trigger($name, Event $event = null)
{
    $this->ensureBehaviors();
    $eventHandlers = [];
    foreach ($this->_eventWildcards as $wildcard => $handlers) {
        if (StringHelper::matchWildcard($wildcard, $name)) {
            $eventHandlers[] = $handlers;
        }
    }
    if (!empty($this->_events[$name])) {
        $eventHandlers[] = $this->_events[$name];
    }
    if (!empty($eventHandlers)) {
        $eventHandlers = call_user_func_array('array_merge', $eventHandlers);
        if ($event === null) {
            $event = new Event();
        }
        if ($event->sender === null) {
            $event->sender = $this;
        }
        $event->handled = false;
        $event->name = $name;
        foreach ($eventHandlers as $handler) {
            $event->data = $handler[1];
            call_user_func($handler[0], $event);
            // stop further handling if the event is handled
            if ($event->handled) {
                return;
            }
        }
    }
    // invoke class-level attached handlers
    Event::trigger($this, $name, $event);
}