ApplicationTrait

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

ApplicationTrait

View source

# Public Properties

Property Description
env string, null – The environment ID Craft is currently running in.
minVersionRequired string, null – The minimum Craft build number required to update to this build.
schemaVersion string, null – Craft’s schema version number.

# env

Type
string, null

The environment ID Craft is currently running in.

View source

# minVersionRequired

Type
string, null

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

View source

# schemaVersion

Type
string, null

Craft’s schema version number.

View source

# Public Methods

Method Description
disableMaintenanceMode() Disables Maintenance Mode.
enableMaintenanceMode() Enables Maintenance Mode.
getApi() Returns the API service.
getAssetIndexer() Returns the asset indexing service.
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.
getDeprecator() Returns the deprecator service.
getDrafts() Returns the drafts service.
getEdition() Returns 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.
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.
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.
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.
getVolumes() Returns the volumes 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

# 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

# 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

# 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

# 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

# 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

# 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 – 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

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

# 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

# getVolumes()

Returns the volumes service.

View source

Returns

craft\services\Volumes – 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.