Final Class luya\admin\Module

Inheritanceluya\admin\Module » luya\admin\base\Module » luya\base\Module » yii\base\Module » yii\di\ServiceLocator » yii\base\Component » yii\base\BaseObject
Implementsluya\base\AdminModuleInterface, luya\base\CoreModuleInterface, yii\base\Configurable
Available since version1.0.0

Admin Module.

The Admin Module provides options to configure. In order to add the Admin module to your config use:

'modules' => [
    // ...
    'admin' => [
        'class' => 'luya\admin\Module',
        'secureLogin' => true,
    ]
]

Public Properties

Hide inherited properties

Property Type Description Defined By
$adminAssets array An array with with assets files where the array has no key and the value is the path to the asset class. luya\admin\Module
$aliases array List of path aliases to be defined. yii\base\Module
$apiDefintions array An array with all apis from every module, this property is assigned by the {{luya\web\Bootstrap::run()}} method. luya\admin\Module
$apiRules luya\admin\Module
$apiUserAllowActionsWithoutPermissions boolean Defines whether Api Users can access a method which is not protected from the permission system. luya\admin\Module
$apis array The available api endpoints within the admin module. luya\admin\Module
$authApis array luya\admin\base\Module
$authRoutes array luya\admin\base\Module
$autoBootstrapQueue boolean If enabled, the admin bootstrap process will check whether the queue job was runing within the last 30min or not. luya\admin\Module
$basePath string The root directory of the module. yii\base\Module
$behaviors yii\base\Behavior[] List of behaviors attached to this component. yii\base\Component
$bootstrapQueueCli boolean Whether the queue command should be bootstraped automatically. luya\admin\Module
$components array The list of the component definitions or the loaded component instances (ID => definition or instance). yii\di\ServiceLocator
$context string If this/the module is included via another module (parent module), the parent module will write its name inside the child modules $context variable. luya\base\Module
$controllerFiles array Returns an array where the key is the controller id and value the original file. luya\base\Module
$controllerMap array Mapping from controller ID to controller configurations. yii\base\Module
$controllerNamespace string|null The namespace that controller classes are in. yii\base\Module
$controllerPath string The directory that contains the controller classes. yii\base\Module
$cors boolean Whether CORS filter is enabled or not. luya\admin\Module
$dashboardLogDisplayApiUserData boolean Whether the api user log entries should be display in the module dashboard or not. luya\admin\Module
$dashboardObjects array Provide dashboard objects from last user logins. luya\admin\Module
$defaultRoute string The default route of this module. yii\base\Module
$disableLogin boolean If enabled, the login form is diabled and maintenance message is displayed, which can be configured trough $disableLoginMessage. luya\admin\Module
$disableLoginMessage string An optional message which is disapyled when the login is disabled. luya\admin\Module
$emailVerification boolean If enabled an user can only change the email adresse by entering the secure code which is sent to the users given (current) email adresse. luya\admin\Module
$emailVerificationTokenExpirationTime integer If {{luya\admin\Module::$emailVerification}} is enabled this property defines the number seconds until the validation token expires. luya\admin\Module
$fileDefaultInlineDisposition boolean The default value for {{luya\admin\models\StorageFile::$inline_disposition}} when uploading a new file. luya\admin\Module
$filterOpenApiPaths array An array with filter conditions, see {{luya\admin\openapi\Generator::$filterPaths}} for more detailes luya\admin\Module
$id string An ID that uniquely identifies this module among other modules which have the same parent. yii\base\Module
$interfaceLanguage string The default language for the admin interrace (former known as luyaLanguage). luya\admin\Module
$interfaceLanguageDropdown array Available translation messages. luya\admin\Module
$jsTranslationMessages array An array with values of the message keys based on the Yii translation system. luya\admin\Module
$jsTranslations array Take a look at {{luya\admin\Module::getJsTranslations()}}. luya\admin\Module
$jsonCruft boolean Whether each json rest response contains an unparsable cruft in order to prevent JSON Vulnerabilities. luya\admin\Module
$layout string|boolean|null The layout that should be applied for views within this module. yii\base\Module
$layoutPath string The root directory of layout files. yii\base\Module
$loginSessionAttemptCount integer The number of attempts a user can make without knowing the login email. luya\admin\Module
$loginSessionAttemptLockoutTime integer If the session based {{luya\admin\Module::$loginSessionAttemptCount}} expire the user is locked out for this given time in seconds, defaults to 30min. luya\admin\Module
$loginUserAttemptCount integer When the username is identified correctly this property limit number of attempts for the given user and lock out the user for a given time defined in {{luya\admin\Module::$loginUserAttemptLockoutTime}}. luya\admin\Module
$loginUserAttemptLockoutTime integer When the {{luya\admin\Module::$loginUserAttemptCount}} exceeded the number of seconds where the user is locked out, defaults to 30 min. luya\admin\Module
$logoutOnUserIpChange boolean If enabled (which is default) the user will be logged out when the ip changes, this makes it harder to overtake tokens as they will be destroyed when the user is logged out. luya\admin\Module
$menu luya\admin\components\AdminMenuBuilderInterface Get the menu builder object. luya\admin\Module
$module yii\base\Module|null The parent module of this module. yii\base\Module
$moduleLayout string The default name of the moduleLayout luya\base\Module
$modules array The modules (indexed by their IDs). yii\base\Module
$namespace string luya\base\Module
$params array Custom module parameters (name => value). yii\base\Module
$proxyDbConnection string The component/connection name from application. luya\admin\Module
$proxyExpirationTime integer The expiration timeout for a proxy build in seconds. luya\admin\Module
$proxyRowsPerRequest integer The number of rows which should be transferd for each request. luya\admin\Module
$publicOpenApi boolean Whether a PUBLIC available endpoint should created returning an OpenAPI definition for current LUYA System (including all registered modules) or not. luya\admin\Module
$queueMutexClass string The mutex class which should be used for the admin queue component. luya\admin\Module
$reloadButtons array Take a look at {{luya\admin\Module::setReloadButtons()}}. luya\admin\Module
$requiredComponents array An array containing all components which should be registered for the current module. luya\admin\base\Module
$resetPassword boolean If enabled, the login screen contains a "lost password" form, where the user can enter his email adresse and recieves an email with a link where the user can enter a new password. luya\admin\Module
$resetPasswordExpirationTime integer The number of seconds the reset token link is valid. luya\admin\Module
$secureLogin boolean Enables a 2FA system before logging into the admin panel sending a token to the given email adress of the user. luya\admin\Module
$secureTokenExpirationTime integer When {{luya\admin\Module::$secureLogin}} is enabled a secure token is sent to the users email, the expiration time is defined in seconds and defaults to 10 min. luya\admin\Module
$strongPasswordPolicy boolean If enabled, the admin user passwords require strength input with special chars, lower, upper, digits and numbers. luya\admin\Module
$tags array A configuration array with all tags shipped by default with the admin module. luya\admin\Module
$uniqueId string The unique ID of the module. yii\base\Module
$urlRules array Contains all urlRules for this module. luya\base\Module
$useAppLayoutPath boolean Defines the location of the layout file whether in the @app namespace or a module: - true = looking for layout file in @app/views/<ID>/layouts. luya\base\Module
$useAppViewPath boolean Define the location of the view files inside the controller actions - true = the view path of the @app/views - false = the view path of the @modulename/views luya\base\Module
$userIdleTimeout integer The number of seconds inactivity until the user is logged out. luya\admin\Module
$version string The version of this module. yii\base\Module
$viewMap array Mapping from action ID to view configurations. luya\base\Module
$viewPath string The root directory of view files. yii\base\Module

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\base\Module
__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
baseT() Base translation method which invokes the onLoad function. luya\base\Module
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
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
ensureBehaviors() Makes sure that the behaviors declared in behaviors() are attached to this component. yii\base\Component
extendPermissionApis() Extend the permission apis with none menu based items. luya\admin\base\Module
extendPermissionRoutes() Extend the permission route with a none menu route the set permissions. luya\admin\base\Module
get() Returns the component instance with the specified ID. yii\base\Module
getAdminAssets() Returns all Asset files to registered in the administration interfaces. luya\admin\Module
getAuthApis() Get an array with all api routes based on the menu builder. luya\admin\base\Module
getAuthRoutes() Get an array with all routes based on the menu builder. luya\admin\base\Module
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
getComponents() Returns the list of the component definitions or the loaded component instances. yii\di\ServiceLocator
getControllerFiles() Returns all controller files of this module from the getControllerPath() folder, where the key is the reusable id of this controller and value the file on the server. luya\base\Module
getControllerPath() Overrides the yii2 default behavior by not throwing an exception if no alias has been defined for the controller namespace. Otherwise each module requires an alias for its first namepsace entry which results into exception for external modules without an alias. luya\base\Module
getInstance() Returns the currently requested instance of this module class. yii\base\Module
getJsTranslationMessages() Returns all message identifier for the current module which should be assigned to the javascript admin interface. luya\admin\Module
getJsTranslations() Getter method for the js translations array. luya\admin\Module
getLayoutPath() Override the default implementation of Yii's getLayoutPath(). If the property $useAppLayoutPath is true, the @app namespace views will be looked up for view files. luya\base\Module
getMenu() Get the admin module interface menu. luya\admin\Module
getModule() Retrieves the child module of the specified ID. yii\base\Module
getModules() Returns the sub-modules in this module. yii\base\Module
getNamespace() Returns "luya\base" for example. luya\base\Module
getReloadButtons() Return array with {{luya\admin\base\ReloadButton}} objects luya\admin\Module
getUniqueId() Returns an ID that uniquely identifies this module among all modules within the current application. yii\base\Module
getUrlRules() Getter method for urlRules. luya\admin\Module
getVersion() Returns current module version. yii\base\Module
getViewPath() Returns the directory that contains the view files for this module. yii\base\Module
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
import() Setup the admin importer classes. luya\admin\Module
init() Initializes the module. luya\base\Module
luyaBootstrap() luya\admin\Module
off() Detaches an existing event handler from this component. yii\base\Component
on() Attaches an event handler to an event. yii\base\Component
onLoad() Internal used to register the translations from the translation array or set alias paths. luya\admin\Module
registerComponents() Registering application components on bootstraping proccess. luya\admin\Module
registerTranslation() Register a Translation to the i18n component. luya\base\Module
resolveRoute() Extract the current module from the route and return the new resolved route. luya\base\Module
runAction() Runs a controller action specified by a route. yii\base\Module
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 module. yii\base\Module
setComponents() Registers a set of component definitions in this locator. yii\di\ServiceLocator
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
setModule() Adds a sub-module to this module. yii\base\Module
setModules() Registers sub-modules in the current module. yii\base\Module
setReloadButtons() Set an array of relaod buttons with a callback function to run on click. luya\admin\Module
setUrlRules() UrlRules for this module. You can either provide a full {{luya\web\UrlRule}} object configuration as array like this: luya\base\Module
setVersion() Sets current module version. yii\base\Module
setViewPath() Sets the directory that contains the view files. yii\base\Module
staticBasePath() Get base path from static view port. luya\base\Module
t() Admin Module translation helper. luya\admin\Module
trigger() Triggers an event. yii\base\Component

Protected Methods

Hide inherited methods

Method Description Defined By
defaultVersion() Returns default module version. yii\base\Module

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_BEFORE_ACTION yii\base\ActionEvent An event raised before executing a controller action. yii\base\Module

Constants

Hide inherited constants

Constant Value Description Defined By
EVENT_BEFORE_FILE_DOWNLOAD 'EVENT_BEFORE_FILE_DOWNLOAD' This event is triggered before a file is downloaded through the {{luya\admin\controllers\FileController}}. luya\admin\Module
EVENT_USER_ACCESS_TOKEN_LOGIN 'eventUserAccessTokenLogin' This event is triggered when an access token is trying to login. luya\admin\Module

Property Details

Hide inherited properties

$adminAssets public read-only property

An array with with assets files where the array has no key and the value is the path to the asset class.

$apiDefintions public property (available since version 1.2.2)

An array with all apis from every module, this property is assigned by the {{luya\web\Bootstrap::run()}} method.

public array $apiDefintions = []
$apiRules public property
public $apiRules = [
    
'api-admin-timestamp' => [
        
'patterns' => [
            
'POST' => 'index',
        ],
    ],
    
'api-admin-user' => [
        
'extraPatterns' => [
            
'POST change-password' => 'change-password',
        ],
    ],
]
$apiUserAllowActionsWithoutPermissions public property (available since version 2.2.0)

Defines whether Api Users can access a method which is not protected from the permission system. When working with JWT or SPA applications this should be disabled.

$apis public property

The available api endpoints within the admin module.

public array $apis = [
    
'api-admin-logger' => 'luya\admin\apis\LoggerController',
    
'api-admin-common' => 'luya\admin\apis\CommonController',
    
'api-admin-remote' => 'luya\admin\apis\RemoteController',
    
'api-admin-storage' => 'luya\admin\apis\StorageController',
    
'api-admin-menu' => 'luya\admin\apis\MenuController',
    
'api-admin-timestamp' => 'luya\admin\apis\TimestampController',
    
'api-admin-search' => 'luya\admin\apis\SearchController',
    
'api-admin-user' => 'luya\admin\apis\UserController',
    
'api-admin-apiuser' => 'luya\admin\apis\ApiUserController',
    
'api-admin-group' => 'luya\admin\apis\GroupController',
    
'api-admin-lang' => 'luya\admin\apis\LangController',
    
'api-admin-effect' => 'luya\admin\apis\EffectController',
    
'api-admin-filter' => 'luya\admin\apis\FilterController',
    
'api-admin-tag' => 'luya\admin\apis\TagController',
    
'api-admin-proxymachine' => 'luya\admin\apis\ProxyMachineController',
    
'api-admin-proxybuild' => 'luya\admin\apis\ProxyBuildController',
    
'api-admin-proxy' => 'luya\admin\apis\ProxyController',
    
'api-admin-config' => 'luya\admin\apis\ConfigController',
    
'api-admin-queuelog' => 'luya\admin\apis\QueueLogController',
    
'api-admin-queuelogerror' => 'luya\admin\apis\QueueLogErrorController',
    
'api-admin-ngrestlog' => 'luya\admin\apis\NgrestLogController',
    
'api-admin-storageimage' => 'luya\admin\apis\StorageImageController',
    
'api-admin-property' => 'luya\admin\apis\PropertyController',
]
$autoBootstrapQueue public property (available since version 2.0.0)

If enabled, the admin bootstrap process will check whether the queue job was runing within the last 30min or not. If you are not setting up any cronjob to run the scheduler and you need to rely on the queue/scheulder system you enable this property which will then do a "dummy frontend user cronjob". So on every request it will check whether to run queue or not. By default this is disabled in order to prevent to have more memory and database usage. If disable setup a cronjob with admin/queue command using {{luya\admin\commands\QueueController}}.

$bootstrapQueueCli public property (available since version 2.0.4)

Whether the queue command should be bootstraped automatically. Defaults to true. If already a queue is configured, this might conflict and override those settings. Therefore you can disable the bootstrap of queue command.

$cors public property

Whether CORS filter is enabled or not. By default its disabled but you can enable this option when using LUYA admin APIs for usage trough direct xhr requests from another Domain.

public boolean $cors false
$dashboardLogDisplayApiUserData public property (available since version 3.2.0)

Whether the api user log entries should be display in the module dashboard or not. This is disabled by default as ApiUsers might create and update a lot of data.

$dashboardObjects public property

Provide dashboard objects from last user logins.

public array $dashboardObjects = [
    [
        
'class' => 'luya\admin\dashboard\ListDashboardObject',
        
'template' => '<li class="list-group-item" ng-repeat="item in data">{{item.user.firstname}} {{item.user.lastname}}<span class="badge badge-info float-right">{{item.maxdate * 1000 | date:\'short\'}}</span></li>',
        
'dataApiUrl' => 'admin/api-admin-common/last-logins',
        
'title' => [
            
'admin',
            
'dashboard_lastlogin_title',
        ],
    ],
]
$disableLogin public property (available since version 4.0.0)

If enabled, the login form is diabled and maintenance message is displayed, which can be configured trough $disableLoginMessage.

public boolean $disableLogin false
$disableLoginMessage public property (available since version 4.0.0)

An optional message which is disapyled when the login is disabled.

$emailVerification public property (available since version 1.2.0)

If enabled an user can only change the email adresse by entering the secure code which is sent to the users given (current) email adresse.

public boolean $emailVerification false
$emailVerificationTokenExpirationTime public property (available since version 1.2.0)

If {{luya\admin\Module::$emailVerification}} is enabled this property defines the number seconds until the validation token expires.

$fileDefaultInlineDisposition public property (available since version 2.0.0)

The default value for {{luya\admin\models\StorageFile::$inline_disposition}} when uploading a new file. By default this is display which will force a download when opening the file url, in order to enable inline disposition (will try to display the file in the browser) set true. > This property will only have an effect when uploading new files and won't work for existing uploaded files or a general default behavior.

$filterOpenApiPaths public property (available since version 3.2.0)

An array with filter conditions, see {{luya\admin\openapi\Generator::$filterPaths}} for more detailes

$interfaceLanguage public property

The default language for the admin interrace (former known as luyaLanguage). Currently supported: en, de, ru, es, fr, ua, it, el, vi, pl, pt, tr, fa, cn, nl, th, hu, id, bg

public string $interfaceLanguage 'en'
$interfaceLanguageDropdown public property

Available translation messages.

public array $interfaceLanguageDropdown = [
    
'en' => 'English',
    
'de' => 'Deutsch',
    
'ru' => 'Pусский',
    
'es' => 'Español',
    
'fr' => 'Français',
    
'ua' => 'Українська',
    
'it' => 'Italiano',
    
'el' => 'Ελληνικά',
    
'vi' => 'Việt Nam',
    
'pl' => 'Polski',
    
'pt' => 'Português',
    
'tr' => 'Türkçe',
    
'fa' => 'فارسی',
    
'cn' => '中文简体',
    
'nl' => 'Dutch',
    
'th' => 'ภาษาไทย',
    
'hu' => 'Magyar',
    
'id' => 'Bahasa',
    
'bg' => 'Български',
]
$jsTranslationMessages public read-only property

An array with values of the message keys based on the Yii translation system.

$jsTranslations public property

Take a look at {{luya\admin\Module::getJsTranslations()}}.

public array $jsTranslations null
$jsonCruft public property (available since version 1.2.0)

Whether each json rest response contains an unparsable cruft in order to prevent JSON Vulnerabilities.

public boolean $jsonCruft true
$loginSessionAttemptCount public property (available since version 1.2.0)

The number of attempts a user can make without knowing the login email. Clearing the session cookie will allow next 20 attempts. But if an user email is known the attempt will swap to a user based attempt lockout handled by {{luya\admin\Module::$loginUserAttemptCount}}.

$loginSessionAttemptLockoutTime public property (available since version 1.2.0)

If the session based {{luya\admin\Module::$loginSessionAttemptCount}} expire the user is locked out for this given time in seconds, defaults to 30min.

$loginUserAttemptCount public property (available since version 1.2.0)

When the username is identified correctly this property limit number of attempts for the given user and lock out the user for a given time defined in {{luya\admin\Module::$loginUserAttemptLockoutTime}}. The {{luya\admin\Module::$loginUserAttemptCount}} stores the login attempts in the database. Keep in mind that the {{luya\admin\Module::$loginSessionAttemptCount}} can lock out the user before or while entering a wrong password.

$loginUserAttemptLockoutTime public property (available since version 1.2.0)

When the {{luya\admin\Module::$loginUserAttemptCount}} exceeded the number of seconds where the user is locked out, defaults to 30 min.

$logoutOnUserIpChange public property (available since version 4.4)

If enabled (which is default) the user will be logged out when the ip changes, this makes it harder to overtake tokens as they will be destroyed when the user is logged out. There can be situations with loadbalancers or vpns where the ip changes a lot. But in generall its recommend to keep this setting enabled.

$menu public read-only property

Get the menu builder object.

$proxyDbConnection public property (available since version 2.0.0)

The component/connection name from application.

public string $proxyDbConnection 'db'
$proxyExpirationTime public property

The expiration timeout for a proxy build in seconds. Default value is 1800 seconds which is 30 minutes.

$proxyRowsPerRequest public property

The number of rows which should be transferd for each request.

$publicOpenApi public property (available since version 3.2.0)

Whether a PUBLIC available endpoint should created returning an OpenAPI definition for current LUYA System (including all registered modules) or not.

public boolean $publicOpenApi false
$queueMutexClass public property (available since version 3.7.0)

The mutex class which should be used for the admin queue component. Changed from yii\mutex\FileMutex to yii\mutex\MysqlMutex as a database connection is required in the admin area and there are no conflicts with file permissions when running in cli mode. In order to ensure the old behavior use the FileMutex class.

public string $queueMutexClass 'yii\mutex\MysqlMutex'
$reloadButtons public property

Take a look at {{luya\admin\Module::setReloadButtons()}}.

public array $reloadButtons null
$resetPassword public property (available since version 3.0.0)

If enabled, the login screen contains a "lost password" form, where the user can enter his email adresse and recieves an email with a link where the user can enter a new password.

public boolean $resetPassword false
$resetPasswordExpirationTime public property (available since version 3.0.0)

The number of seconds the reset token link is valid.

$secureLogin public property

Enables a 2FA system before logging into the admin panel sending a token to the given email adress of the user. If the system is not able to send mails (No configuration or missconfiguration) then you are not able to login. You should test the mail system before enabling secureLogin. To test your smtp connection you can use ./vendor/bin/luya health/mailer command.

public boolean $secureLogin false
$secureTokenExpirationTime public property (available since version 1.2.0)

When {{luya\admin\Module::$secureLogin}} is enabled a secure token is sent to the users email, the expiration time is defined in seconds and defaults to 10 min.

$strongPasswordPolicy public property (available since version 1.1.1)

If enabled, the admin user passwords require strength input with special chars, lower, upper, digits and numbers. If disabled just a min length of 8 chars is required.

$tags public property

A configuration array with all tags shipped by default with the admin module.

public array $tags = [
    
'file' => [
        
'class' => 'luya\admin\tags\FileTag',
    ],
]
$userIdleTimeout public property (available since version 1.2.0)

The number of seconds inactivity until the user is logged out.

public integer $userIdleTimeout 1800

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\base\Module::__construct()

Constructor.

public void __construct ( $id, $parent null, $config = [] )
$id string

The ID of this module.

$parent yii\base\Module|null

The parent module (if any).

$config array

Name-value pairs that will be used to initialize the object properties.

                public function __construct($id, $parent = null, $config = [])
{
    $this->id = $id;
    $this->module = $parent;
    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);
    }
}

            
baseT() public static method

Defined in: luya\base\Module::baseT()

Base translation method which invokes the onLoad function.

This makes it possible to register module translations without adding the module to the components list. This is very important for luya extensions.

public static string baseT ( $category, $message, array $params = [], $language null )
$category string

The message category.

$message string

The message to be translated.

$params array

The parameters that will be used to replace the corresponding placeholders in the message.

$language string

The language code (e.g. en-US, en). If this is null, the current application language will be used.

return string

The translated message.

                public static function baseT($category, $message, array $params = [], $language = null)
{
    static::onLoad();
    return Yii::t($category, $message, $params, $language);
}

            
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 [];
}

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

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

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

            
extendPermissionApis() public method

Defined in: luya\admin\base\Module::extendPermissionApis()

Extend the permission apis with none menu based items.

Example return:

return [
    ['api' => 'api-cms-moveblock', 'alias' => 'Move blocks'],
];
public array extendPermissionApis ( )
return array

An array with an array with keys api and alias.

                public function extendPermissionApis()
{
    return [];
}

            
extendPermissionRoutes() public method

Defined in: luya\admin\base\Module::extendPermissionRoutes()

Extend the permission route with a none menu route the set permissions.

Example return:

public function extendPermissionRoutes()
{
    return [
        ['route' => 'cmsadmin/page/create', 'alias' => 'Page Create'],
        ['route' => 'cmsadmin/page/update', 'alias' => 'Page Edit'],
    ];
}
public void extendPermissionRoutes ( )

                public function extendPermissionRoutes()
{
    return [];
}

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

            
getAdminAssets() public method

Returns all Asset files to registered in the administration interfaces.

As the adminstration UI is written in angular, the assets must be pre assigned to the adminisration there for the getAdminAssets() method exists.

public function getAdminAssets()
{
    return [
         'luya\admin\assets\Main',
         'luya\admin\assets\Flow',
    ];
}
public array getAdminAssets ( )
return array

An array with with assets files where the array has no key and the value is the path to the asset class.

                public function getAdminAssets()
{
    return [
        'luya\admin\assets\Main',
        'luya\admin\assets\AngularI18n',
    ];
}

            
getAuthApis() public method

Defined in: luya\admin\base\Module::getAuthApis()

Get an array with all api routes based on the menu builder.

public array getAuthApis ( )

                public function getAuthApis()
{
    $menu = $this->getMenu();
    if (!$menu) {
        return $this->extendPermissionApis();
    }
    return ArrayHelper::merge($this->extendPermissionApis(), $menu->getPermissionApis());
}

            
getAuthRoutes() public method

Defined in: luya\admin\base\Module::getAuthRoutes()

Get an array with all routes based on the menu builder.

public array getAuthRoutes ( )

                public function getAuthRoutes()
{
    $menu = $this->getMenu();
    if (!$menu) {
        return $this->extendPermissionRoutes();
    }
    return ArrayHelper::merge($this->extendPermissionRoutes(), $menu->getPermissionRoutes());
}

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

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

            
getControllerFiles() public method

Defined in: luya\base\Module::getControllerFiles()

Returns all controller files of this module from the getControllerPath() folder, where the key is the reusable id of this controller and value the file on the server.

public array getControllerFiles ( )
return array

Returns an array where the key is the controller id and value the original file.

                public function getControllerFiles()
{
    return ObjectHelper::getControllers($this);
}

            
getControllerPath() public method

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

Overrides the yii2 default behavior by not throwing an exception if no alias has been defined for the controller namespace. Otherwise each module requires an alias for its first namepsace entry which results into exception for external modules without an alias.

exception.

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()
{
    return Yii::getAlias('@' . str_replace('\\', '/', $this->controllerNamespace), false);
}

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

            
getJsTranslationMessages() public method

Returns all message identifier for the current module which should be assigned to the javascript admin interface.

As the administration UI is written in angular, translations must also be available in different javascript section of the page.

The response array of this method returns all messages keys which will be assigned:

Example:

public function getJsTranslationMessages()
{
    return ['js_ngrest_rm_page', 'js_ngrest_rm_confirm', 'js_ngrest_error'],
}

Assuming the aboved keys are also part of the translation messages files.

public array getJsTranslationMessages ( )
return array

An array with values of the message keys based on the Yii translation system.

                public function getJsTranslationMessages()
{
    return [
        'js_ngrest_rm_page', 'js_ngrest_rm_confirm', 'js_ngrest_error', 'js_ngrest_rm_update', 'js_ngrest_rm_success', 'js_tag_exists', 'js_tag_success', 'js_admin_reload', 'js_dir_till', 'js_dir_set_date', 'js_dir_table_add_row', 'js_dir_table_add_column', 'js_dir_image_description',
        'js_dir_no_selection', 'js_dir_image_upload_ok', 'js_dir_image_filter_error', 'js_dir_upload_wait', 'js_dir_manager_upload_image_ok', 'js_dir_manager_rm_file_confirm', 'js_dir_manager_rm_file_ok', 'js_zaa_server_proccess',
        'ngrest_select_no_selection', 'js_ngrest_toggler_success', 'js_filemanager_count_files_overlay', 'js_link_set_value', 'js_link_not_set', 'js_link_change_value', 'aws_changepassword_succes', 'js_account_update_profile_success', 'layout_filemanager_remove_dir_not_empty',
        'ngrest_button_delete', 'layout_btn_reload', 'js_dir_manager_rm_file_confirm_title', 'ngrest_crud_search_text', 'js_dir_manager_rm_folder_confirm_title', 'js_pagination_page', 'js_dir_manager_rename_success',
        'js_scheduler_show_datepicker', 'js_scheduler_new_value', 'js_scheduler_time', 'js_scheduler_save', 'js_scheduler_title_upcoming', 'js_scheduler_title_completed', 'js_scheduler_table_newvalue', 'js_scheduler_table_timestamp', 'js_dir_manager_file_replace_ok',
        'js_jsonobject_newkey', 'menu_dashboard', 'file_caption_success', 'ngrest_delete_all_button_confirm_message', 'ngrest_delete_all_button_label',
        // cropping
        'crop_source_image', 'crop_preview', 'crop_btn_as_copy', 'crop_btn_as_copy_hint', 'crop_btn_save_copy', 'crop_btn_save_replace','crop_size_free','crop_size_1to1','crop_size_desktop','crop_size_mobile', 'crop_success', 'crop_quality_high', 'crop_quality_medium', 'crop_quality_low'
    ];
}

            
getJsTranslations() public method

Getter method for the js translations array.

public array getJsTranslations ( )
return array

An array with all translated messages to store in the and access from the admin js scripts.

                public function getJsTranslations()
{
    $translations = [];
    foreach (Yii::$app->getAdminModulesJsTranslationMessages() as $module => $data) {
        foreach ($data as $key) {
            $translations[$key] = Yii::t($module, $key, [], Yii::$app->language);
        }
    }
    return $translations;
}

            
getLayoutPath() public method

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

Override the default implementation of Yii's getLayoutPath(). If the property $useAppLayoutPath is true, the @app namespace views will be looked up for view files.

Else the layout path of the active theme will be used.

See also yii\base\Module::getLayoutPath().

public string getLayoutPath ( )

                public function getLayoutPath()
{
    if (Yii::$app->themeManager->hasActiveTheme && $this->useAppLayoutPath) {
        $this->setLayoutPath(Yii::$app->themeManager->activeTheme->layoutPath);
    } elseif ($this->useAppLayoutPath) {
        $this->setLayoutPath('@app/views/'.$this->id.'/layouts');
    }
    return parent::getLayoutPath();
}

            
getMenu() public method

Get the admin module interface menu.

See also luya\admin\base\Module::getMenu().

public luya\admin\components\AdminMenuBuilderInterface getMenu ( )
return luya\admin\components\AdminMenuBuilderInterface

Get the menu builder object.

                public function getMenu()
{
    return (new AdminMenuBuilder($this))
        ->nodeRoute('menu_node_filemanager', 'cloud_upload', 'admin/storage/index')
        ->node('menu_node_system', 'settings_system_daydream')
            ->group('menu_group_access')
                ->itemApi('menu_access_item_user', 'admin/user/index', 'person', 'api-admin-user')
                ->itemApi('menu_access_item_apiuser', 'admin/api-user/index', 'device_hub', 'api-admin-apiuser')
                ->itemApi('menu_access_item_group', 'admin/group/index', 'group', 'api-admin-group')
            ->group('menu_group_system')
                ->itemApi('menu_system_item_config', 'admin/config/index', 'storage', 'api-admin-config')
                ->itemApi('menu_system_item_language', 'admin/lang/index', 'language', 'api-admin-lang')
                ->itemApi('menu_system_item_property', 'admin/property/index', 'widgets', 'api-admin-property')
                ->itemApi('menu_system_item_tags', 'admin/tag/index', 'tag', 'api-admin-tag')
                ->itemApi('menu_system_queue', 'admin/queue-log/index', 'schedule', 'api-admin-queuelog')
            ->group('menu_group_log')
                ->itemApi('menu_system_queue_errors', 'admin/queue-log-error/index', 'bug_report', 'api-admin-queuelogerror')
                ->itemApi('menu_system_logger', 'admin/logger/index', 'notifications', 'api-admin-logger')
                ->itemApi('menu_system_model_event_log', 'admin/ngrest-log/index', 'archive', 'api-admin-ngrestlog')
            ->group('menu_group_contentproxy')
                ->itemApi('menu_group_contentproxy_machines', 'admin/proxy-machine/index', 'devices', 'api-admin-proxymachine')
                ->itemApi('menu_group_contentproxy_builds', 'admin/proxy-build/index', 'import_export', 'api-admin-proxybuild')
            ->group('menu_group_storage')
                ->itemApi('menu_images_item_images', 'admin/storage-image/index', 'photo', 'api-admin-storageimage')
                ->itemApi('menu_images_item_filters', 'admin/filter/index', 'adjust', 'api-admin-filter')
                ->itemApi('menu_images_item_effects', 'admin/effect/index', 'blur_circular', 'api-admin-effect');
}

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

            
getNamespace() public method

Defined in: luya\base\Module::getNamespace()

Returns "luya\base" for example.

public string getNamespace ( )

                public function getNamespace()
{
    return implode('\\', array_slice(explode('\\', get_class($this)), 0, -1));
}

            
getReloadButtons() public method (available since version 2.0.0)

Return array with {{luya\admin\base\ReloadButton}} objects

public array getReloadButtons ( )

                public function getReloadButtons()
{
    return $this->_reloadButtons;
}

            
getUniqueId() public method

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

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

Note that if the module is an application, an empty string will be returned.

public string getUniqueId ( )
return string

The unique ID of the module.

                public function getUniqueId()
{
    return $this->module ? ltrim($this->module->getUniqueId() . '/' . $this->id, '/') : $this->id;
}

            
getUrlRules() public method (available since version 1.0.1)

Getter method for urlRules.

Never use the getter method, use the $urlRules virtual property as it provides backwards compatibility.

public array getUrlRules ( )

                public function getUrlRules()
{
    $rules = [
        ['pattern' => 'file/<id:\d+>/<hash:\w+>/<fileName:(.*?)+>', 'route' => 'admin/file/download'],
        ['pattern' => 'admin', 'route' => 'admin/default/index'],
        ['pattern' => 'admin/login', 'route' => 'admin/login/index'],
    ];
    foreach ($this->apiDefintions as $definition) {
        $definition['class'] = 'luya\admin\components\UrlRule';
        $definition['cacheFlag'] = Yii::$app->request->isAdmin;
        $rules[] = $definition;
    }
    return $rules;
}

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

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

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

            
import() public method

Setup the admin importer classes.

public array import ( luya\console\interfaces\ImportControllerInterface $import )
$import luya\console\interfaces\ImportControllerInterface

The import controller interface.

return array

An array with all importer classes registered for this module.

                public function import(ImportControllerInterface $import)
{
    return [
        AuthImporter::class,
        FilterImporter::class,
        PropertyImporter::class,
    ];
}

            
init() public method

Defined in: luya\base\Module::init()

Initializes the module.

This method is called after the module is created and initialized with property values given in configuration. The default implementation will initialize $controllerNamespace if it is not set.

If you override this method, please make sure you call the parent implementation.

public void init ( )

                public function init()
{
    parent::init();
    // verify all the components
    foreach ($this->requiredComponents as $component) {
        if (!Yii::$app->has($component)) {
            throw new InvalidConfigException(sprintf('The required component "%s" is not registered in the configuration file', $component));
        }
    }
    static::onLoad();
}

            
luyaBootstrap() public method

public void luyaBootstrap ( yii\base\Application $app )
$app

                public function luyaBootstrap(\yii\base\Application $app)
{
    // if console application bootstrap the yii2 queue cli command.
    if ($this->bootstrapQueueCli && $app instanceof Application) {
        $app->controllerMap['queue'] = [
            'class' => Command::class,
            'queue' => $app->adminqueue,
        ];
    }
}

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

            
onLoad() public static method

Internal used to register the translations from the translation array or set alias paths.

This is a static behavior, so we can call this call without the object context, for example when the composer plugin registers blocks but the module is not registered with translations.

public static void onLoad ( )

                public static function onLoad()
{
    self::registerTranslation('admin*', '@admin/messages', [
        'admin' => 'admin.php',
    ]);
}

            
registerComponents() public method

Registering application components on bootstraping proccess.

public array registerComponents ( )
return array

An array where the key is the application component name and value the configuration.

                public function registerComponents()
{
    return [
        'adminLanguage' => [
            'class' => AdminLanguage::class,
        ],
        'adminuser' => [
            'class' => AdminUser::class,
            'defaultLanguage' => $this->interfaceLanguage,
        ],
        'adminmenu' => [
            'class' => AdminMenu::class,
        ],
        'storage' => [
            'class' => LocalFileSystem::class,
        ],
        'auth' => [
            'class' => Auth::class,
        ],
        'adminqueue' => [
            'class' => 'yii\queue\db\Queue',
            'db' => 'db',
            'mutex' => $this->queueMutexClass,
            'tableName' => 'admin_queue',
            'channel' => 'default',
            'as log' => 'luya\admin\behaviors\QueueLogBehavior',
            'attempts' => 5, // allow to attempt 5 times
            'ttr' => 300, // wait 5 minutes, also its the max amount a job can take: The ttr (Time to reserve, TTR) option defines the number of seconds during which a job must be successfully completed.
        ],
    ];
}

            
registerTranslation() public static method

Defined in: luya\base\Module::registerTranslation()

Register a Translation to the i18n component.

In order to register Translations you can register them inside the {{luya\base\Module::onLoad()}} method.

public static function onLoad()
{
    $this->registerTranslation('mymodule*', static::staticBasePath() . '/messages', [
        'mymodule' => 'mymodule.php',
        'mymodule/sub' => 'sub.php',
    ]);
}
public static void registerTranslation ( $prefix, $basePath, array $fileMap )
$prefix string

The prefix of which the messages are indicated

$basePath string

The path to the messages folder where the messages are located.

$fileMap array

The files mapping inside the messages folder.

                public static function registerTranslation($prefix, $basePath, array $fileMap)
{
    if (!isset(Yii::$app->i18n->translations[$prefix])) {
        Yii::$app->i18n->translations[$prefix] = [
            'class' => 'yii\i18n\PhpMessageSource',
            'basePath' => $basePath,
            'fileMap' => $fileMap,
        ];
    }
}

            
resolveRoute() public method

Defined in: luya\base\Module::resolveRoute()

Extract the current module from the route and return the new resolved route.

public string resolveRoute ( $route )
$route string

Route to resolve, e.g. admin/default/index

return string

The resolved route without the module id default/index when input was admin/default/index and the current module id is admin.

                public function resolveRoute($route)
{
    $routeParts = explode('/', $route);
    foreach ($routeParts as $k => $v) {
        if (($k == 0 && $v == $this->id) || (empty($v))) {
            unset($routeParts[$k]);
        }
    }
    if (count($routeParts) == 0) {
        return $this->defaultRoute;
    }
    return implode('/', $routeParts);
}

            
runAction() public method

Defined in: yii\base\Module::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\base\Controller::runAction() to run the action with the given parameters. If the route is empty, the method will use $defaultRoute.

public mixed runAction ( $route, $params = [] )
$route string

The route that specifies the action.

$params array

The parameters to be passed to the action

return mixed

The result of the action.

throws yii\base\InvalidRouteException

if the requested route cannot be resolved into an action successfully.

                public function runAction($route, $params = [])
{
    $parts = $this->createController($route);
    if (is_array($parts)) {
        /* @var $controller Controller */
        list($controller, $actionID) = $parts;
        $oldController = Yii::$app->controller;
        Yii::$app->controller = $controller;
        $result = $controller->runAction($actionID, $params);
        if ($oldController !== null) {
            Yii::$app->controller = $oldController;
        }
        return $result;
    }
    $id = $this->getUniqueId();
    throw new InvalidRouteException('Unable to resolve the request "' . ($id === '' ? $route : $id . '/' . $route) . '".');
}

            
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\Module::setBasePath()

Sets the root directory of the module.

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

public void setBasePath ( $path )
$path string

The root directory of the module. This can be either a directory name or a path alias.

throws yii\base\InvalidArgumentException

if the directory does not exist.

                public function setBasePath($path)
{
    $path = Yii::getAlias($path);
    $p = strncmp($path, 'phar://', 7) === 0 ? $path : realpath($path);
    if (is_string($p) && is_dir($p)) {
        $this->_basePath = $p;
    } else {
        throw new InvalidArgumentException("The directory does not exist: $path");
    }
}

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

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

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

            
setReloadButtons() public method (available since version 2.0.0)

Set an array of relaod buttons with a callback function to run on click.

Every array item needs at least:

  • label: The label which is displayed in the mnu
  • icon: A material icon value from https://material.io/tools/icons/
  • callback: A php callable function which is executed when clicking the button.
'reloadButtons' => [
    ['label' => 'Clear Frontpage Cache', 'icon' => 'clear', 'callback' => function($button) {
        (new \Curl\Curl())->get('https://luya/clear/this/cache');
    }]
]

The first paramter of the callback function is the ReloadButton object itself, this allwos you to change the response message.

'callback' => function(\luya\admin\base\ReloadButton $button) {
    // do something
    // ...

    // change response (success) message.
    $button->response = 'Running this button was a full success!';
}
public void setReloadButtons ( array $buttons )
$buttons array

                public function setReloadButtons(array $buttons)
{
    foreach ($buttons as $buttonConfig) {
        $this->_reloadButtons[] = new ReloadButton($buttonConfig);
    }
}

            
setUrlRules() public method (available since version 1.0.1)

Defined in: luya\base\Module::setUrlRules()

UrlRules for this module. You can either provide a full {{luya\web\UrlRule}} object configuration as array like this:

'urlRules' => [
    ['pattern' => 'mymodule/detail/<id:\d+>', 'route' => 'mymodule/detail/user'],
],

Or you can provide a key value pairing where key is the pattern and the value is the route:

'urlRules' => [
    'mymodule/detail/<id:\d+>' => 'mymodule/detail/user',
],
public void setUrlRules ( array $rules )
$rules

                public function setUrlRules(array $rules)
{
    $this->_urlRules = $rules;
}

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

            
staticBasePath() public static method

Defined in: luya\base\Module::staticBasePath()

Get base path from static view port.

public static string staticBasePath ( )

                public static function staticBasePath()
{
    $class = new \ReflectionClass(get_called_class());
    
    return dirname($class->getFileName());
}

            
t() public static method

Admin Module translation helper.

public static string t ( $message, array $params = [], $language null )
$message string

The message key to translation

$params array

Optional parameters to pass to the translation.

$language
return string

The translated message.

                public static function t($message, array $params = [], $language = null)
{
    return parent::baseT('admin', $message, $params, $language);
}

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