Class craft\web\Application
- Inheritance
- craft\web\Application » yii\web\Application » yii\base\Application » yii\base\Module » yii\di\ServiceLocator » yii\base\Component » yii\base\BaseObject
- Implements
- yii\base\Configurable
- Uses Traits
- craft\base\ApplicationTrait
- Available since version
- 3.0
- Source Code
- https://github.com/craftcms/cms/blob/master/src/web/Application.php
Craft Web Application class
Property | Type | Description | Defined By |
---|---|---|---|
$bootstrap |
array | List of components that should be run during the application bootstrapping process. | yii\base\Application |
$catchAll |
array | The configuration specifying a controller action which should handle all user requests. | yii\web\Application |
$charset |
string | The charset currently used for the application. | yii\base\Application |
$controller |
yii\base\Controller | The currently active controller instance | yii\base\Application |
$controllerMap |
array | Mapping from controller ID to controller configurations. | yii\base\Module |
$controllerNamespace |
string | The namespace that controller classes are located in. | yii\base\Application |
$defaultRoute |
string | The default route of this application. | yii\web\Application |
$env |
string, null | The environment ID Craft is currently running in. | craft\base\ApplicationTrait |
$extensions |
array | List of installed Yii extensions. | yii\base\Application |
$id |
string | An ID that uniquely identifies this module among other modules which have the same parent. | yii\base\Module |
$language |
string | The language that is meant to be used for end users. | yii\base\Application |
$layout |
string, boolean | The layout that should be applied for views in this application. | yii\base\Application |
$loadedModules |
array | List of loaded modules indexed by their class names. | yii\base\Application |
$minVersionRequired |
string, null | The minimum Craft build number required to update to this build. | craft\base\ApplicationTrait |
$module |
yii\base\Module | The parent module of this module. | yii\base\Module |
$name |
string | The application name. | yii\base\Application |
$params |
array | Custom module parameters (name => value). | yii\base\Module |
$requestedAction |
yii\base\Action | The requested Action. | yii\base\Application |
$requestedParams |
array | The parameters supplied to the requested action. | yii\base\Application |
$requestedRoute |
string | The requested route | yii\base\Application |
$schemaVersion |
string, null | Craft’s schema version number. | craft\base\ApplicationTrait |
$sourceLanguage |
string | The language that the application is written in. | yii\base\Application |
$state |
integer | The current application state during a request handling life cycle. | yii\base\Application |
Method | Description | Defined By |
---|---|---|
__call() |
Calls the named method which is not a class method. | yii\base\BaseObject |
__clone() |
This method is called after the object is created by cloning an existing one. | yii\base\Component |
__construct() |
Constructor. | craft\web\Application |
__get() |
Returns the value of an object property. | yii\base\BaseObject |
__isset() |
Checks if a property is set, i.e. defined and not null. | yii\base\BaseObject |
__set() |
Sets value of an object property. | yii\base\BaseObject |
__unset() |
Sets an object property to null. | yii\base\BaseObject |
afterAction() |
This method is invoked right after an action within this module is executed. | yii\base\Module |
attachBehavior() |
Attaches a behavior to this component. | yii\base\Component |
attachBehaviors() |
Attaches a list of behaviors to the component. | yii\base\Component |
beforeAction() |
This method is invoked right before an action within this module is executed. | yii\base\Module |
behaviors() |
Returns a list of behaviors that this component should behave as. | yii\base\Component |
bootstrap() |
{@inheritdoc} | craft\web\Application |
canGetProperty() |
Returns a value indicating whether a property can be read. | yii\base\BaseObject |
canSetProperty() |
Returns a value indicating whether a property can be set. | yii\base\BaseObject |
className() |
Returns the fully qualified name of this class. | yii\base\BaseObject |
clear() |
Removes the component from the locator. | yii\di\ServiceLocator |
coreComponents() |
Returns the configuration of core application components. | yii\base\Application |
createController() |
Creates a controller instance based on the given route. | yii\base\Module |
createControllerByID() |
Creates a controller based on the given controller ID. | yii\base\Module |
detachBehavior() |
Detaches a behavior from the component. | yii\base\Component |
detachBehaviors() |
Detaches all behaviors from the component. | yii\base\Component |
disableMaintenanceMode() |
Disables Maintenance Mode. | craft\base\ApplicationTrait |
enableMaintenanceMode() |
Enables Maintenance Mode. | craft\base\ApplicationTrait |
end() |
Terminates the application. | yii\base\Application |
ensureBehaviors() |
Makes sure that the behaviors declared in behaviors() are attached to this component. | yii\base\Component |
get() |
{@inheritdoc} | craft\web\Application |
getApi() |
Returns the API service. | craft\base\ApplicationTrait |
getAssetIndexer() |
Returns the asset indexing service. | craft\base\ApplicationTrait |
getAssetManager() |
Returns the asset manager. | yii\base\Application |
getAssetTransforms() |
Returns the asset transforms service. | craft\base\ApplicationTrait |
getAssets() |
Returns the assets service. | craft\base\ApplicationTrait |
getAuthManager() |
Returns the auth manager for this application. | yii\base\Application |
getBasePath() |
Returns the root directory of the module. | yii\base\Module |
getBehavior() |
Returns the named behavior object. | yii\base\Component |
getBehaviors() |
Returns all behaviors attached to this component. | yii\base\Component |
getCache() |
Returns the cache component. | yii\base\Application |
getCanTestEditions() |
Returns whether Craft is running on a domain that is eligible to test out the editions. | craft\base\ApplicationTrait |
getCanUpgradeEdition() |
Returns whether Craft is eligible to be upgraded to a different edition. | craft\base\ApplicationTrait |
getCategories() |
Returns the categories service. | craft\base\ApplicationTrait |
getComponents() |
Returns the list of the component definitions or the loaded component instances. | yii\di\ServiceLocator |
getComposer() |
Returns the Composer service. | craft\base\ApplicationTrait |
getConfig() |
Returns the config service. | craft\base\ApplicationTrait |
getContent() |
Returns the content service. | craft\base\ApplicationTrait |
getContentMigrator() |
Returns the content migration manager. | craft\base\ApplicationTrait |
getControllerPath() |
Returns the directory that contains the controller classes according to $controllerNamespace. | yii\base\Module |
getDashboard() |
Returns the dashboard service. | craft\base\ApplicationTrait |
getDb() |
Returns the database connection component. | yii\base\Application |
getDeprecator() |
Returns the deprecator service. | craft\base\ApplicationTrait |
getEdition() |
Returns the Craft edition. | craft\base\ApplicationTrait |
getEditionName() |
Returns the name of the Craft edition. | craft\base\ApplicationTrait |
getElementIndexes() |
Returns the element indexes service. | craft\base\ApplicationTrait |
getElements() |
Returns the elements service. | craft\base\ApplicationTrait |
getEntries() |
Returns the entries service. | craft\base\ApplicationTrait |
getEntryRevisions() |
Returns the entry revisions service. | craft\base\ApplicationTrait |
getErrorHandler() |
Returns the error handler component. | yii\base\Application |
getEt() |
Returns the E.T. service. | craft\base\ApplicationTrait |
getFeeds() |
Returns the feeds service. | craft\base\ApplicationTrait |
getFields() |
Returns the fields service. | craft\base\ApplicationTrait |
getFormatter() |
Returns the formatter component. | yii\base\Application |
getGlobals() |
Returns the globals service. | craft\base\ApplicationTrait |
getHasWrongEdition() |
Returns whether Craft is running with the wrong edition. | craft\base\ApplicationTrait |
getHomeUrl() |
yii\web\Application | |
getI18n() |
Returns the internationalization (i18n) component. | yii\base\Application |
getImages() |
Returns the images service. | craft\base\ApplicationTrait |
getInfo() |
Returns the info model, or just a particular attribute. | craft\base\ApplicationTrait |
getInstance() |
Returns the currently requested instance of this module class. | yii\base\Module |
getIsDbConnectionValid() |
Returns whether the DB connection settings are valid. | craft\base\ApplicationTrait |
getIsInMaintenanceMode() |
Returns whether someone is currently performing a system update. | craft\base\ApplicationTrait |
getIsInstalled() |
Returns whether Craft is installed. | craft\base\ApplicationTrait |
getIsMultiSite() |
Returns whether this Craft install has multiple sites. | craft\base\ApplicationTrait |
getIsSystemOn() |
Returns whether the front end is accepting HTTP requests. | craft\base\ApplicationTrait |
getLayoutPath() |
Returns the directory that contains layout view files for this module. | yii\base\Module |
getLicensedEdition() |
Returns the edition Craft is actually licensed to run in. | craft\base\ApplicationTrait |
getLicensedEditionName() |
Returns the name of the edition Craft is actually licensed to run in. | craft\base\ApplicationTrait |
getLocale() |
Returns a Locale object for the target language. | craft\base\ApplicationTrait |
getLog() |
Returns the log dispatcher component. | yii\base\Application |
getMailer() |
Returns the current mailer. | craft\base\ApplicationTrait |
getMatrix() |
Returns the matrix service. | craft\base\ApplicationTrait |
getMigrator() |
Returns the application’s migration manager. | craft\base\ApplicationTrait |
getModule() |
Retrieves the child module of the specified ID. | yii\base\Module |
getModules() |
Returns the sub-modules in this module. | yii\base\Module |
getMutex() |
Returns the application’s mutex service. | craft\base\ApplicationTrait |
getPath() |
Returns the path service. | craft\base\ApplicationTrait |
getPluginStore() |
Returns the plugin store service. | craft\base\ApplicationTrait |
getPlugins() |
Returns the plugins service. | craft\base\ApplicationTrait |
getQueue() |
Returns the queue service. | craft\base\ApplicationTrait |
getRelations() |
Returns the relations service. | craft\base\ApplicationTrait |
getRequest() |
Returns the request component. | yii\base\Application |
getResponse() |
Returns the response component. | yii\base\Application |
getRoutes() |
Returns the routes service. | craft\base\ApplicationTrait |
getRuntimePath() |
Returns the directory that stores runtime files. | yii\base\Application |
getSearch() |
Returns the search service. | craft\base\ApplicationTrait |
getSections() |
Returns the sections service. | craft\base\ApplicationTrait |
getSecurity() |
Returns the security component. | yii\base\Application |
getSession() |
Returns the session component. | yii\web\Application |
getSites() |
Returns the sites service. | craft\base\ApplicationTrait |
getStructures() |
Returns the structures service. | craft\base\ApplicationTrait |
getSystemMessages() |
Returns the system email messages service. | craft\base\ApplicationTrait |
getSystemSettings() |
Returns the system settings service. | craft\base\ApplicationTrait |
getSystemUid() |
Returns the system's UID. | craft\base\ApplicationTrait |
getTags() |
Returns the tags service. | craft\base\ApplicationTrait |
getTargetLanguage() |
Returns the target app language. | craft\base\ApplicationTrait |
getTemplateCaches() |
Returns the template cache service. | craft\base\ApplicationTrait |
getTimeZone() |
Returns the time zone used by this application. | yii\base\Application |
getTokens() |
Returns the tokens service. | craft\base\ApplicationTrait |
getUniqueId() |
Returns an ID that uniquely identifies this module among all modules within the current application. | yii\base\Application |
getUpdates() |
Returns the updates service. | craft\base\ApplicationTrait |
getUrlManager() |
Returns the URL manager for this application. | yii\base\Application |
getUser() |
Returns the user component. | yii\web\Application |
getUserGroups() |
Returns the user groups service. | craft\base\ApplicationTrait |
getUserPermissions() |
Returns the user permissions service. | craft\base\ApplicationTrait |
getUsers() |
Returns the users service. | craft\base\ApplicationTrait |
getUtilities() |
Returns the utilities service. | craft\base\ApplicationTrait |
getVendorPath() |
Returns the directory that stores vendor files. | yii\base\Application |
getVersion() |
Returns current module version. | yii\base\Module |
getView() |
Returns the view object. | yii\base\Application |
getViewPath() |
Returns the directory that contains the view files for this module. | yii\base\Module |
getVolumes() |
Returns the volumes service. | craft\base\ApplicationTrait |
getYiiVersion() |
Returns the Yii framework version. | craft\base\ApplicationTrait |
handleRequest() |
Handles the specified request. | craft\web\Application |
has() |
{@inheritdoc} | 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\BaseObject |
hasModule() |
Checks whether the child module of the specified ID exists. | yii\base\Module |
hasProperty() |
Returns a value indicating whether a property is defined. | yii\base\BaseObject |
init() |
Initializes the application. | craft\web\Application |
off() |
Detaches an existing event handler from this component. | yii\base\Component |
on() |
Attaches an event handler to an event. | yii\base\Component |
preInit() |
Pre-initializes the application. | yii\base\Application |
requireEdition() |
Requires that Craft is running an equal or better edition than what's passed in | craft\base\ApplicationTrait |
run() |
Runs the application. | yii\base\Application |
runAction() |
Runs a controller action specified by a route. | craft\web\Application |
saveInfo() |
Updates the info row. | craft\base\ApplicationTrait |
set() |
Registers a component definition with this locator. | yii\di\ServiceLocator |
setAliases() |
Defines path aliases. | yii\base\Module |
setBasePath() |
Sets the root directory of the application and the @app alias. | yii\base\Application |
setComponents() |
Registers a set of component definitions in this locator. | yii\di\ServiceLocator |
setContainer() |
Configures Yii::$container with the $config. | yii\base\Application |
setEdition() |
Sets the Craft edition. | craft\base\ApplicationTrait |
setHomeUrl() |
yii\web\Application | |
setInstance() |
Sets the currently requested instance of this module class. | yii\base\Module |
setIsInstalled() |
Sets Craft's record of whether it's installed | craft\base\ApplicationTrait |
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 |
setRuntimePath() |
Sets the directory that stores runtime files. | yii\base\Application |
setTimeZone() |
Sets the time zone used by this application. | yii\base\Application |
setVendorPath() |
Sets the directory that stores vendor files. | craft\web\Application |
setVersion() |
Sets current module version. | yii\base\Module |
setViewPath() |
Sets the directory that contains the view files. | yii\base\Module |
trigger() |
Triggers an event. | yii\base\Component |
updateTargetLanguage() |
Sets the target application language. | craft\base\ApplicationTrait |
Method | Description | Defined By |
---|---|---|
debugBootstrap() |
Bootstraps the Debug Toolbar if necessary. | craft\web\Application |
defaultVersion() |
Returns default module version. | yii\base\Module |
ensureResourcePathExists() |
Ensures that the resources folder exists and is writable. | craft\web\Application |
registerErrorHandler() |
Registers the errorHandler component as a PHP error handler. | yii\base\Application |
Event | Type | Description | Defined By |
---|---|---|---|
EVENT_AFTER_ACTION |
yii\base\ActionEvent | An event raised after executing a controller action. | yii\base\Module |
EVENT_AFTER_EDITION_CHANGE |
craft\events\EditionChangeEvent | The event that is triggered after the edition changes | craft\web\Application |
EVENT_AFTER_REQUEST |
yii\base\Event | An event raised after the application successfully handles a request (before the response is sent out). | yii\base\Application |
EVENT_BEFORE_ACTION |
yii\base\ActionEvent | An event raised before executing a controller action. | yii\base\Module |
EVENT_BEFORE_REQUEST |
yii\base\Event | An event raised before the application starts to handle a request. | yii\base\Application |
EVENT_INIT |
yii\base\Event | The event that is triggered after the application has been initialized | craft\web\Application |
Constant | Value | Description | Defined By |
---|---|---|---|
STATE_AFTER_REQUEST |
4 | Application state used by $state: application is triggering EVENT_AFTER_REQUEST. . | yii\base\Application |
STATE_BEFORE_REQUEST |
2 | Application state used by $state: application is triggering EVENT_BEFORE_REQUEST. | yii\base\Application |
STATE_BEGIN |
0 | Application state used by $state: application just started. | yii\base\Application |
STATE_END |
6 | Application state used by $state: application has ended. | yii\base\Application |
STATE_HANDLING_REQUEST |
3 | Application state used by $state: application is handling the request. | yii\base\Application |
STATE_INIT |
1 | Application state used by $state: application is initializing. | yii\base\Application |
STATE_SENDING_RESPONSE |
5 | Application state used by $state: application is about to send response. | yii\base\Application |
Method Details
__construct()
public method
#
Constructor.
public void __construct ( array $config = [] )
$config |
array |
bootstrap()
public method
#
{@inheritdoc}
public void bootstrap ( )
debugBootstrap()
protected method
#
Bootstraps the Debug Toolbar if necessary.
protected void debugBootstrap ( )
ensureResourcePathExists()
protected method
#
Ensures that the resources folder exists and is writable.
protected void ensureResourcePathExists ( )
throws | yii\base\InvalidConfigException |
---|
get()
public method
#
{@inheritdoc}
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 void get ( $id, $throwException = true )
$id |
||
$throwException |
handleRequest()
public method
#
Handles the specified request.
public yii\web\Response handleRequest ( $request )
$request |
craft\web\Request | The request to be handled |
return | yii\web\Response | The resulting response |
---|---|---|
throws | yii\web\HttpException | |
throws | craft\web\ServiceUnavailableHttpException | |
throws | craft\errors\DbConnectException | |
throws | yii\web\ForbiddenHttpException | |
throws | yii\web\NotFoundHttpException |
init()
public method
#
Initializes the application.
public void init ( )
runAction()
public method
#
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 craft\web\Controller::runAction() to run the action with the given parameters. If the route is empty, the method will use $defaultRoute.
public yii\web\Response, null runAction ( $route, $params = [] )
$route |
string | The route that specifies the action. |
$params |
array | The parameters to be passed to the action |
return | yii\web\Response, null | The result of the action, normalized into a Response object |
---|---|---|
throws | yii\base\InvalidRouteException | if the requested route cannot be resolved into an action successfully. |
setVendorPath()
public method
#
Sets the directory that stores vendor files.
public void setVendorPath ( $path )
$path |
string | The directory that stores vendor files. |
Event Details
EVENT_AFTER_EDITION_CHANGE
event of type craft\events\EditionChangeEvent
#
The event that is triggered after the edition changes
EVENT_INIT
event of type yii\base\Event
#
The event that is triggered after the application has been initialized