Skip to content

ApplicationTrait ​

Type
Trait
Namespace
craft\base
Implemented by
craft\console\Application, craft\web\Application
Since
3.0.0

ApplicationTrait

View source

Public Properties ​

PropertyDescription
announcementscraft\services\Announcements – The announcements service
apicraft\services\Api – The API service
assetIndexercraft\services\AssetIndexer – The asset indexer service
assetManagercraft\web\AssetManager – The asset manager component
assetTransformscraft\services\AssetTransforms – The asset transforms service
assetscraft\services\Assets – The assets service
canTestEditionsboolean – Whether Craft is running on a domain that is eligible to test out the editions
canUpgradeEditionboolean – Whether Craft is eligible to be upgraded to a different edition
categoriescraft\services\Categories – The categories service
composercraft\services\Composer – The Composer service
configcraft\services\Config – The config service
contentcraft\services\Content – The content service
contentMigratorcraft\db\MigrationManager – The content migration manager
dashboardcraft\services\Dashboard – The dashboard service
dbcraft\db\Connection – The database connection component
deprecatorcraft\services\Deprecator – The deprecator service
draftscraft\services\Drafts – The drafts service
editioninteger – The active Craft edition
elementIndexescraft\services\ElementIndexes – The element indexes service
elementscraft\services\Elements – The elements service
entriescraft\services\Entries – The entries service
envstring, null – The environment ID Craft is currently running in.
feedscraft\feeds\Feeds – The feeds service
fieldscraft\services\Fields – The fields service
formattercraft\i18n\Formatter – The formatter component
formattingLocalecraft\i18n\Locale – The Locale object that should be used to define the formatter
gccraft\services\Gc – The garbage collection service
globalscraft\services\Globals – The globals service
gqlcraft\services\Gql – The GraphQl service
hasWrongEditionboolean – Whether Craft is running with the wrong edition
i18ncraft\i18n\I18N – The internationalization (i18n) component
imagescraft\services\Images – The images service
installedSchemaVersionstring – The installed schema version
isInMaintenanceModeboolean – Whether someone is currently performing a system update
isInitializedboolean – Whether Craft is fully initialized
isInstalledboolean – Whether Craft is installed
isMultiSiteboolean – Whether this site has multiple sites
isSystemLiveboolean – Whether the system is live
localecraft\i18n\Locale – The Locale object for the target language
mailercraft\mail\Mailer – The mailer component
matrixcraft\services\Matrix – The matrix service
migratorcraft\db\MigrationManager – The application’s migration manager
minVersionRequiredstring, null – The minimum Craft build number required to update to this build.
mutexyii\mutex\Mutex – The application’s mutex service
pathcraft\services\Path – The path service
pluginStorecraft\services\PluginStore – The plugin store service
pluginscraft\services\Plugins – The plugins service
projectConfigcraft\services\ProjectConfig – The project config service
queuecraft\queue\Queue, craft\queue\QueueInterface – The job queue
relationscraft\services\Relations – The relations service
revisionscraft\services\Revisions – The revisions service
routescraft\services\Routes – The routes service
schemaVersionstring, null – Craft’s schema version number.
searchcraft\services\Search – The search service
sectionscraft\services\Sections – The sections service
securitycraft\services\Security – The security component
sitescraft\services\Sites – The sites service
structurescraft\services\Structures – The structures service
systemMessagescraft\services\SystemMessages – The system email messages service
systemSettingscraft\services\SystemSettings – The system settings service
tagscraft\services\Tags – The tags service
templateCachescraft\services\TemplateCaches – The template caches service
tokenscraft\services\Tokens – The tokens service
updatescraft\services\Updates – The updates service
userGroupscraft\services\UserGroups – The user groups service
userPermissionscraft\services\UserPermissions – The user permissions service
userscraft\services\Users – The users service
utilitiescraft\services\Utilities – The utilities service
viewcraft\web\View – The view component
volumescraft\services\Volumes – The volumes service
webpackcraft\services\Webpack – The webpack service

announcements ​

Type
craft\services\Announcements
Default value
null

The announcements service

View source

api ​

Type
craft\services\Api
Default value
null

The API service

View source

assetIndexer ​

Type
craft\services\AssetIndexer
Default value
null

The asset indexer service

View source

assetManager ​

Type
craft\web\AssetManager
Default value
null

The asset manager component

View source

assetTransforms ​

Type
craft\services\AssetTransforms
Default value
null

The asset transforms service

View source

assets ​

Type
craft\services\Assets
Default value
null

The assets service

View source

canTestEditions ​

Type
boolean
Default value
null

Whether Craft is running on a domain that is eligible to test out the editions

View source

canUpgradeEdition ​

Type
boolean
Default value
null

Whether Craft is eligible to be upgraded to a different edition

View source

categories ​

Type
craft\services\Categories
Default value
null

The categories service

View source

composer ​

Type
craft\services\Composer
Default value
null

The Composer service

View source

config ​

Type
craft\services\Config
Default value
null

The config service

View source

content ​

Type
craft\services\Content
Default value
null

The content service

View source

contentMigrator ​

Type
craft\db\MigrationManager
Default value
null

The content migration manager

View source

dashboard ​

Type
craft\services\Dashboard
Default value
null

The dashboard service

View source

db ​

Type
craft\db\Connection
Default value
null

The database connection component

View source

deprecator ​

Type
craft\services\Deprecator
Default value
null

The deprecator service

View source

drafts ​

Type
craft\services\Drafts
Default value
null

The drafts service

View source

edition ​

Type
integer
Default value
null

The active Craft edition

View source

elementIndexes ​

Type
craft\services\ElementIndexes
Default value
null

The element indexes service

View source

elements ​

Type
craft\services\Elements
Default value
null

The elements service

View source

entries ​

Type
craft\services\Entries
Default value
null

The entries service

View source

env ​

Type
string, null
Default value
null

The environment ID Craft is currently running in.

View source

feeds ​

Type
craft\feeds\Feeds
Default value
null

The feeds service

View source

fields ​

Type
craft\services\Fields
Default value
null

The fields service

View source

formatter ​

Type
craft\i18n\Formatter
Default value
null

The formatter component

View source

formattingLocale ​

Type
craft\i18n\Locale
Default value
null

The Locale object that should be used to define the formatter

View source

gc ​

Type
craft\services\Gc
Default value
null

The garbage collection service

View source

globals ​

Type
craft\services\Globals
Default value
null

The globals service

View source

gql ​

Type
craft\services\Gql
Default value
null

The GraphQl service

View source

hasWrongEdition ​

Type
boolean
Default value
null

Whether Craft is running with the wrong edition

View source

i18n ​

Type
craft\i18n\I18N
Default value
null

The internationalization (i18n) component

View source

images ​

Type
craft\services\Images
Default value
null

The images service

View source

installedSchemaVersion ​

Type
string
Default value
null

The installed schema version

View source

isInMaintenanceMode ​

Type
boolean
Default value
null

Whether someone is currently performing a system update

View source

isInitialized ​

Type
boolean
Default value
null

Whether Craft is fully initialized

View source

isInstalled ​

Type
boolean
Default value
null

Whether Craft is installed

View source

isMultiSite ​

Type
boolean
Default value
null

Whether this site has multiple sites

View source

isSystemLive ​

Type
boolean
Default value
null

Whether the system is live

View source

locale ​

Type
craft\i18n\Locale
Default value
null

The Locale object for the target language

View source

mailer ​

Type
craft\mail\Mailer
Default value
null

The mailer component

View source

matrix ​

Type
craft\services\Matrix
Default value
null

The matrix service

View source

migrator ​

Type
craft\db\MigrationManager
Default value
null

The application’s migration manager

View source

minVersionRequired ​

Type
string, null
Default value
null

The minimum Craft build number required to update to this build.

View source

mutex ​

Type
yii\mutex\Mutex
Default value
null

The application’s mutex service

View source

path ​

Type
craft\services\Path
Default value
null

The path service

View source

pluginStore ​

Type
craft\services\PluginStore
Default value
null

The plugin store service

View source

plugins ​

Type
craft\services\Plugins
Default value
null

The plugins service

View source

projectConfig ​

Type
craft\services\ProjectConfig
Default value
null

The project config service

View source

queue ​

Type
craft\queue\Queue, craft\queue\QueueInterface
Default value
null

The job queue

View source

relations ​

Type
craft\services\Relations
Default value
null

The relations service

View source

revisions ​

Type
craft\services\Revisions
Default value
null

The revisions service

View source

routes ​

Type
craft\services\Routes
Default value
null

The routes service

View source

schemaVersion ​

Type
string, null
Default value
null

Craft’s schema version number.

View source

Type
craft\services\Search
Default value
null

The search service

View source

sections ​

Type
craft\services\Sections
Default value
null

The sections service

View source

security ​

Type
craft\services\Security
Default value
null

The security component

View source

sites ​

Type
craft\services\Sites
Default value
null

The sites service

View source

structures ​

Type
craft\services\Structures
Default value
null

The structures service

View source

systemMessages ​

Type
craft\services\SystemMessages
Default value
null

The system email messages service

View source

systemSettings ​

Type
craft\services\SystemSettings
Default value
null

The system settings service

View source

tags ​

Type
craft\services\Tags
Default value
null

The tags service

View source

templateCaches ​

Type
craft\services\TemplateCaches
Default value
null

The template caches service

View source

tokens ​

Type
craft\services\Tokens
Default value
null

The tokens service

View source

updates ​

Type
craft\services\Updates
Default value
null

The updates service

View source

userGroups ​

Type
craft\services\UserGroups
Default value
null

The user groups service

View source

userPermissions ​

Type
craft\services\UserPermissions
Default value
null

The user permissions service

View source

users ​

Type
craft\services\Users
Default value
null

The users service

View source

utilities ​

Type
craft\services\Utilities
Default value
null

The utilities service

View source

view ​

Type
craft\web\View
Default value
null

The view component

View source

volumes ​

Type
craft\services\Volumes
Default value
null

The volumes service

View source

webpack ​

Type
craft\services\Webpack
Default value
null

The webpack service

View source

Public Methods ​

MethodDescription
disableMaintenanceMode()Disables Maintenance Mode.
enableMaintenanceMode()Enables Maintenance Mode.
getAnnouncements()Returns the announcements service.
getApi()Returns the API service.
getAssetIndexer()Returns the asset indexing service.
getAssetManager()Returns the asset manager component.
getAssetTransforms()Returns the asset transforms service.
getAssets()Returns the assets service.
getCanTestEditions()Returns whether Craft is running on a domain that is eligible to test out the editions.
getCanUpgradeEdition()Returns whether Craft is eligible to be upgraded to a different edition.
getCategories()Returns the categories service.
getComposer()Returns the Composer service.
getConfig()Returns the config service.
getContent()Returns the content service.
getContentMigrator()Returns the content migration manager.
getDashboard()Returns the dashboard service.
getDb()Returns the database connection component.
getDeprecator()Returns the deprecator service.
getDrafts()Returns the drafts service.
getEdition()Returns the Craft edition.
getEditionHandle()Returns the handle of the Craft edition.
getEditionName()Returns the name of the Craft edition.
getElementIndexes()Returns the element indexes service.
getElements()Returns the elements service.
getEntries()Returns the entries service.
getEntryRevisions()Returns the entry revisions service.
getFeeds()Returns the feeds service.
getFields()Returns the fields service.
getFormatter()Returns the formatter component.
getFormattingLocale()Returns the locale that should be used to define the formatter.
getGc()Returns the garbage collection service.
getGlobals()Returns the globals service.
getGql()Returns the GraphQL service.
getHasWrongEdition()Returns whether Craft is running with the wrong edition.
getI18n()Returns the internationalization (i18n) component.
getImages()Returns the images service.
getInfo()Returns the info model, or just a particular attribute.
getInstalledSchemaVersion()Returns the installed schema version.
getIsInMaintenanceMode()Returns whether someone is currently performing a system update.
getIsInitialized()Returns whether Craft has been fully initialized.
getIsInstalled()Returns whether Craft is installed.
getIsLive()Returns whether the system is currently live.
getIsMultiSite()Returns whether this Craft install has multiple sites.
getIsSystemOn()Returns whether the system is currently live.
getLicensedEdition()Returns the edition Craft is actually licensed to run in.
getLicensedEditionName()Returns the name of the edition Craft is actually licensed to run in.
getLocale()Returns a Locale object for the target language.
getMailer()Returns the current mailer.
getMatrix()Returns the matrix service.
getMigrator()Returns the application’s migration manager.
getMutex()Returns the application’s mutex service.
getPath()Returns the path service.
getPluginStore()Returns the plugin store service.
getPlugins()Returns the plugins service.
getProjectConfig()Returns the system config service.
getQueue()Returns the queue service.
getRelations()Returns the relations service.
getRevisions()Returns the revisions service.
getRoutes()Returns the routes service.
getSearch()Returns the search service.
getSections()Returns the sections service.
getSecurity()Returns the security component.
getSites()Returns the sites service.
getStructures()Returns the structures service.
getSystemMessages()Returns the system email messages service.
getSystemName()Returns the system name.
getSystemSettings()Returns the system settings service.
getSystemUid()Returns the system's UID.
getTags()Returns the tags service.
getTargetLanguage()Returns the target app language.
getTemplateCaches()Returns the template cache service.
getTokens()Returns the tokens service.
getUpdates()Returns the updates service.
getUserGroups()Returns the user groups service.
getUserPermissions()Returns the user permissions service.
getUsers()Returns the users service.
getUtilities()Returns the utilities service.
getView()Returns the view component.
getVolumes()Returns the volumes service.
getWebpack()Returns the webpack service.
getYiiVersion()Returns the Yii framework version.
requireEdition()Requires that Craft is running an equal or better edition than what's passed in
saveInfo()Updates the info row.
saveInfoAfterRequest()Updates the info row at the end of the request.
setEdition()Sets the Craft edition.
setIsInstalled()Sets Craft's record of whether it's installed
updateTargetLanguage()Sets the target application language.

disableMaintenanceMode() ​

Disables Maintenance Mode.

See also:

View source

Returns ​

boolean

enableMaintenanceMode() ​

Enables Maintenance Mode.

See also:

View source

Returns ​

boolean

getAnnouncements() ​

Since
3.7.0

Returns the announcements service.

View source

Returns ​

craft\services\Announcements – The announcements service

getApi() ​

Returns the API service.

View source

Returns ​

craft\services\Api – The API service

getAssetIndexer() ​

Returns the asset indexing service.

View source

Returns ​

craft\services\AssetIndexer – The asset indexing service

getAssetManager() ​

Returns the asset manager component.

View source

Returns ​

craft\web\AssetManager –

getAssetTransforms() ​

Returns the asset transforms service.

View source

Returns ​

craft\services\AssetTransforms – The asset transforms service

getAssets() ​

Returns the assets service.

View source

Returns ​

craft\services\Assets – The assets service

getCanTestEditions() ​

Returns whether Craft is running on a domain that is eligible to test out the editions.

View source

Returns ​

boolean

getCanUpgradeEdition() ​

Returns whether Craft is eligible to be upgraded to a different edition.

View source

Returns ​

boolean

getCategories() ​

Returns the categories service.

View source

Returns ​

craft\services\Categories – The categories service

getComposer() ​

Returns the Composer service.

View source

Returns ​

craft\services\Composer – The Composer service

getConfig() ​

Returns the config service.

View source

Returns ​

craft\services\Config – The config service

getContent() ​

Returns the content service.

View source

Returns ​

craft\services\Content – The content service

getContentMigrator() ​

Returns the content migration manager.

View source

Returns ​

craft\db\MigrationManager – The content migration manager

getDashboard() ​

Returns the dashboard service.

View source

Returns ​

craft\services\Dashboard – The dashboard service

getDb() ​

Returns the database connection component.

View source

Returns ​

craft\db\Connection –

getDeprecator() ​

Returns the deprecator service.

View source

Returns ​

craft\services\Deprecator – The deprecator service

getDrafts() ​

Since
3.2.0

Returns the drafts service.

View source

Returns ​

craft\services\Drafts – The drafts service

getEdition() ​

Returns the Craft edition.

View source

Returns ​

integer

getEditionHandle() ​

Since
3.8.0

Returns the handle of the Craft edition.

View source

Returns ​

string

getEditionName() ​

Returns the name of the Craft edition.

View source

Returns ​

string

getElementIndexes() ​

Returns the element indexes service.

View source

Returns ​

craft\services\ElementIndexes – The element indexes service

getElements() ​

Returns the elements service.

View source

Returns ​

craft\services\Elements – The elements service

getEntries() ​

Returns the entries service.

View source

Returns ​

craft\services\Entries – The entries service

getEntryRevisions() ​

DEPRECATED

Deprecated in 3.2.0.

Returns the entry revisions service.

View source

Returns ​

craft\services\EntryRevisions – The entry revisions service

getFeeds() ​

DEPRECATED

Deprecated in 3.4.24

Returns the feeds service.

View source

Returns ​

craft\feeds\Feeds – The feeds service

getFields() ​

Returns the fields service.

View source

Returns ​

craft\services\Fields – The fields service

getFormatter() ​

Returns the formatter component.

View source

Returns ​

craft\i18n\Formatter –

getFormattingLocale() ​

Since
3.6.0

Returns the locale that should be used to define the formatter.

View source

Returns ​

craft\i18n\Locale

getGc() ​

Returns the garbage collection service.

View source

Returns ​

craft\services\Gc – The garbage collection service

getGlobals() ​

Returns the globals service.

View source

Returns ​

craft\services\Globals – The globals service

getGql() ​

Since
3.3.0

Returns the GraphQL service.

View source

Returns ​

craft\services\Gql – The GraphQL service

getHasWrongEdition() ​

Returns whether Craft is running with the wrong edition.

View source

Returns ​

boolean

getI18n() ​

Returns the internationalization (i18n) component.

View source

Returns ​

craft\i18n\I18N –

getImages() ​

Returns the images service.

View source

Returns ​

craft\services\Images – The images service

getInfo() ​

Returns the info model, or just a particular attribute.

View source

Arguments ​

  • $throwException (boolean) – Whether an exception should be thrown if the info table doesn't exist

Returns ​

craft\models\Info

Throws ​

getInstalledSchemaVersion() ​

Since
3.2.0

Returns the installed schema version.

View source

Returns ​

string

getIsInMaintenanceMode() ​

Returns whether someone is currently performing a system update.

See also:

View source

Returns ​

boolean

getIsInitialized() ​

Since
3.0.13

Returns whether Craft has been fully initialized.

View source

Returns ​

boolean

getIsInstalled() ​

Returns whether Craft is installed.

View source

Arguments ​

  • $strict (boolean) – Whether to ignore the cached value and explicitly check from the default schema.

Returns ​

boolean

getIsLive() ​

Since
3.1.0

Returns whether the system is currently live.

View source

Returns ​

boolean

getIsMultiSite() ​

Returns whether this Craft install has multiple sites.

View source

Arguments ​

  • $refresh (boolean) – Whether to ignore the cached result and check again
  • $withTrashed (boolean) – Whether to factor in soft-deleted sites

Returns ​

boolean

getIsSystemOn() ​

DEPRECATED

Deprecated in 3.1.0. Use getIsLive() instead.

Returns whether the system is currently live.

View source

Returns ​

boolean

getLicensedEdition() ​

Returns the edition Craft is actually licensed to run in.

View source

Returns ​

integer, null

getLicensedEditionName() ​

Returns the name of the edition Craft is actually licensed to run in.

View source

Returns ​

string, null

getLocale() ​

Returns a Locale object for the target language.

View source

Returns ​

craft\i18n\Locale – The Locale object for the target language

getMailer() ​

Returns the current mailer.

View source

Returns ​

craft\mail\Mailer – The mailer component

getMatrix() ​

Returns the matrix service.

View source

Returns ​

craft\services\Matrix – The matrix service

getMigrator() ​

Returns the application’s migration manager.

View source

Returns ​

craft\db\MigrationManager – The application’s migration manager

getMutex() ​

Returns the application’s mutex service.

View source

Returns ​

yii\mutex\Mutex – The application’s mutex service

getPath() ​

Returns the path service.

View source

Returns ​

craft\services\Path – The path service

getPluginStore() ​

Returns the plugin store service.

View source

Returns ​

craft\services\PluginStore – The plugin store service

getPlugins() ​

Returns the plugins service.

View source

Returns ​

craft\services\Plugins – The plugins service

getProjectConfig() ​

Returns the system config service.

View source

Returns ​

craft\services\ProjectConfig – The system config service

getQueue() ​

Returns the queue service.

View source

Returns ​

craft\queue\Queue, craft\queue\QueueInterface – The queue service

getRelations() ​

Returns the relations service.

View source

Returns ​

craft\services\Relations – The relations service

getRevisions() ​

Since
3.2.0

Returns the revisions service.

View source

Returns ​

craft\services\Revisions – The revisions service

getRoutes() ​

Returns the routes service.

View source

Returns ​

craft\services\Routes – The routes service

getSearch() ​

Returns the search service.

View source

Returns ​

craft\services\Search – The search service

getSections() ​

Returns the sections service.

View source

Returns ​

craft\services\Sections – The sections service

getSecurity() ​

Returns the security component.

View source

Returns ​

craft\services\Security –

getSites() ​

Returns the sites service.

View source

Returns ​

craft\services\Sites – The sites service

getStructures() ​

Returns the structures service.

View source

Returns ​

craft\services\Structures – The structures service

getSystemMessages() ​

Returns the system email messages service.

View source

Returns ​

craft\services\SystemMessages – The system email messages service

getSystemName() ​

Since
3.1.4

Returns the system name.

View source

Returns ​

string

getSystemSettings() ​

Returns the system settings service.

View source

Returns ​

craft\services\SystemSettings – The system settings service

getSystemUid() ​

Returns the system's UID.

View source

Returns ​

string, null

getTags() ​

Returns the tags service.

View source

Returns ​

craft\services\Tags – The tags service

getTargetLanguage() ​

Returns the target app language.

View source

Arguments ​

  • $useUserLanguage (boolean) – Whether the user's preferred language should be used.

Returns ​

string

getTemplateCaches() ​

Returns the template cache service.

View source

Returns ​

craft\services\TemplateCaches – The template caches service

getTokens() ​

Returns the tokens service.

View source

Returns ​

craft\services\Tokens – The tokens service

getUpdates() ​

Returns the updates service.

View source

Returns ​

craft\services\Updates – The updates service

getUserGroups() ​

Returns the user groups service.

View source

Returns ​

craft\services\UserGroups – The user groups service

getUserPermissions() ​

Returns the user permissions service.

View source

Returns ​

craft\services\UserPermissions – The user permissions service

getUsers() ​

Returns the users service.

View source

Returns ​

craft\services\Users – The users service

getUtilities() ​

Returns the utilities service.

View source

Returns ​

craft\services\Utilities – The utilities service

getView() ​

Returns the view component.

View source

Returns ​

craft\web\View –

getVolumes() ​

Returns the volumes service.

View source

Returns ​

craft\services\Volumes – The volumes service

getWebpack() ​

Since
3.7.22

Returns the webpack service.

View source

Returns ​

craft\services\Webpack – The volumes service

getYiiVersion() ​

Returns the Yii framework version.

View source

Returns ​

string

requireEdition() ​

Requires that Craft is running an equal or better edition than what's passed in

View source

Arguments ​

  • $edition (integer) – The Craft edition to require.
  • $orBetter (boolean) – If true, makes $edition the minimum edition required.

Throws ​

saveInfo() ​

Updates the info row.

View source

Arguments ​

Returns ​

boolean

saveInfoAfterRequest() ​

Since
3.1.33

Updates the info row at the end of the request.

View source

setEdition() ​

Sets the Craft edition.

View source

Arguments ​

  • $edition (integer) – The edition to set.

Returns ​

boolean

setIsInstalled() ​

Sets Craft's record of whether it's installed

View source

Arguments ​

updateTargetLanguage() ​

Sets the target application language.

View source

Arguments ​

  • $useUserLanguage (boolean, null) – Whether the user's preferred language should be used. If null, the user’s preferred language will be used if this is a control panel request or a console request.