WebApp

Type
Class
Namespace
Craft
Inherits
Craft\WebApp » CWebApplication » CApplication » CModule » CComponent
Since
1.0

See also http://craftcms.com

View source

Public Properties

PropertyDescription
$behaviorsarray – The behaviors that should be attached to the module.
$catchAllRequestarray – The configuration specifying a controller which should handle all user requests.
$charsetstring – The charset currently used for the application.
$componentAliasesarray
$controllerMaparray – Mapping from controller ID to controller configurations.
$controllerNamespacestring – Namespace that should be used when loading controllers.
$defaultController
$layoutmixed – The application-wide layout.
$localeClassstring – The class used to get locale data.
$namestring – The application name.
$preloadarray – The IDs of the application components that should be preloaded.
$sourceLanguagestring

$componentAliases

Signature

public array $componentAliases = null

$sourceLanguage

Signature

public string $sourceLanguage = 'en_us'

Public Methods

MethodDescription
__call()Calls the named method which is not a class method.
__construct()Constructor.
__get()Returns a property value, an event handler list or a behavior based on its name.
__isset()Checks if a property value is null.
__set()Sets value of a component property.
__unset()Sets a component property to be null.
afterControllerAction()The post-filter for controller actions.
asa()Returns the named behavior object.
attachBehavior()Attaches a behavior to this component.
attachBehaviors()Attaches a list of behaviors to the component.
attachEventHandler()Attaches an event handler to an event.
beforeControllerAction()The pre-filter for controller actions.
canGetProperty()Determines whether a property can be read.
canSetProperty()Determines whether a property can be set.
clearGlobalState()Clears a global value.
configure()Configures the module with the specified configuration.
createAbsoluteUrl()Creates an absolute URL based on the given controller and action information.
createController()Creates a controller instance based on a route.
createUrl()Creates a relative URL based on the given controller and action information.
detachBehavior()Detaches a behavior from the component.
detachBehaviors()Detaches all behaviors from the component.
detachEventHandler()Detaches an existing event handler.
disableBehavior()Disables an attached behavior.
disableBehaviors()Disables all behaviors attached to this component.
displayError()Displays the captured PHP error.
displayException()Displays the uncaught PHP exception.
enableBehavior()Enables an attached behavior.
enableBehaviors()Enables all behaviors attached to this component.
end()Terminates the application.
evaluateExpression()Evaluates a PHP expression or callback under the context of this component.
findLocalizedFile()Returns the localized version of a specified file.
findModule()Do not call this method. This method is used internally to search for a module by its ID.
getAssetManager()
getAuthManager()
getBasePath()Returns the root path of the application.
getBaseUrl()Returns the relative URL for the application.
getCache()Returns the cache component.
getClientScript()Returns the client script manager.
getComponent()Override getComponent() so we can attach any pending events if the component is getting initialized as well as do some special logic around creating the craft()->db application component.
getComponents()Returns the application components.
getController()
getControllerPath()
getCoreMessages()Returns the core message translations component.
getDateFormatter()Returns the locale-dependent date formatter.
getDb()Returns the database connection component.
getErrorHandler()Returns the error handler component.
getEventHandlers()Returns the list of attached event handlers for an event.
getExtensionPath()Returns the root directory that holds all third-party extensions.
getFormat()Returns the formatter component.
getGlobalState()Returns a global value.
getHomeUrl()
getId()Returns the unique identifier for the application.
getLanguage()Returns the target application language.
getLayoutPath()
getLocale()Returns the localization data for a given locale.
getLocaleDataPath()Returns the directory that contains the locale data.
getMessages()Returns the application message translations component.
getModule()Retrieves the named application module.
getModulePath()Returns the directory that contains the application modules.
getModules()Returns the configuration of the currently installed modules.
getNumberFormatter()
getParams()Returns user-defined parameters.
getParentModule()Returns the parent module.
getRequest()Returns the request component.
getRuntimePath()Returns the directory that stores runtime files.
getSecurityManager()Returns the security manager component.
getSession()Returns the {@link HttpSessionService} (craft()->httpSession).
getStatePersister()Returns the state persister component.
getSystemViewPath()
getTheme()
getThemeManager()
getTimeZone()Returns the system time zone. Note that this method cannot be in {@link AppBehavior}, because Yii will check {@link \CApplication::getTimeZone()} instead.
getTranslatedBrowserLanguage()Tries to find a match between the browser's preferred locales and the locales Craft has been translated into.
getUrlManager()Returns the URL manager component.
getUser()Returns the {@link UserSessionService} (craft()->userSession).
getViewPath()
getViewRenderer()Returns the view renderer.
getWidgetFactory()Returns the widget factory.
handleError()
handleException()Handles uncaught PHP exceptions.
hasComponent()Checks whether the named component exists.
hasEvent()Determines whether an event is defined.
hasEventHandler()Checks whether the named event has attached handlers.
hasModule()Returns a value indicating whether the specified module is installed.
hasProperty()Determines whether a property is defined.
init()Initializes the application.
isConsole()Returns whether we are executing in the context on a console app.
loadGlobalState()Loads the global state data from persistent storage.
on()Attaches an event handler, or remembers it for later if the component has not been initialized yet.
onBeginRequest()Raised right BEFORE the application processes the request.
onEditionChange()Fires an onEditionChange event.
onEndRequest()Raised right AFTER the application processes the request.
onError()Raised when a PHP execution error occurs.
onException()Raised when an uncaught PHP exception occurs.
processRequest()Processes the request.
raiseEvent()Raises an event.
returnAjaxError()Formats a PHP error into JSON before returning it to the client.
returnAjaxException()Formats an exception into JSON before returning it to the client.
run()Runs the application.
runController()Creates the controller and performs the specified action.
saveGlobalState()Saves the global state data into persistent storage.
setAliases()Defines the root aliases.
setBasePath()Sets the root directory of the application.
setComponent()Override setComponent so we can attach any pending events.
setComponents()Sets the application components.
setController()
setControllerPath()
setExtensionPath()Sets the root directory that holds all third-party extensions.
setGlobalState()Sets a global value.
setHomeUrl()
setId()Sets the unique identifier for the application.
setImport()Sets the aliases that are used in the module.
setLanguage()Sets the target application language.
setLayoutPath()
setLocaleDataPath()Sets the directory that contains the locale data.
setModulePath()Sets the directory that contains the application modules.
setModules()Configures the sub-modules of this module.
setParams()Sets user-defined parameters.
setRuntimePath()Sets the directory that stores runtime files.
setSystemViewPath()
setTheme()
setTimeZone()Sets the time zone used by this application.
setViewPath()

createController()

Creates a controller instance based on a route.

View source

Arguments

Returns

array, null

Signature

public array, null createController ( $route, $owner = null )

getComponent()

Override getComponent() so we can attach any pending events if the component is getting initialized as well as do some special logic around creating the craft()->db application component.

View source

Arguments

Returns

mixed

Signature

public mixed getComponent ( $id, $createIfNull = true )

getLanguage()

Returns the target application language.

View source

Returns

string

Signature

public string getLanguage ( )

getLocale()

Returns the localization data for a given locale.

View source

Arguments

Returns

Craft\LocaleData

Signature

public Craft\LocaleData getLocale ( $localeId = null )

getSession()

Returns the {@link HttpSessionService} (craft()->httpSession).

View source

Returns

Craft\HttpSessionService

Signature

public Craft\HttpSessionService getSession ( )

getTimeZone()

Returns the system time zone. Note that this method cannot be in {@link AppBehavior}, because Yii will check {@link \CApplication::getTimeZone()} instead.

View source

Returns

string

Signature

public string getTimeZone ( )

getTranslatedBrowserLanguage()

Tries to find a match between the browser's preferred locales and the locales Craft has been translated into.

View source

Returns

string

Signature

public string getTranslatedBrowserLanguage ( )

getUser()

Returns the {@link UserSessionService} (craft()->userSession).

View source

Returns

Craft\UserSessionService

Signature

public Craft\UserSessionService getUser ( )

handleError()

View source

Arguments

  • $code (integer) – The level of the error raised.
  • $message (string) – The error message.
  • $file (string) – The filename that the error was raised in.
  • $line (integer) – The line number the error was raised at.

Signature

public void handleError ( $code, $message, $file, $line )

init()

Initializes the application.

View source

Returns

null

Signature

public null init ( )

isConsole()

Returns whether we are executing in the context on a console app.

View source

Returns

boolean

Signature

public boolean isConsole ( )

on()

Attaches an event handler, or remembers it for later if the component has not been initialized yet. The event should be identified in a serviceHandle.eventName format. For example, if you want to add an event handler for {@link EntriesService::onSaveEntry()}, you would do this:

craft()->on('entries.saveEntry', function(Event $event) {
    // ...
});

Note that the actual event name (saveEntry) does not need to include the “on”.

By default, event handlers will not get attached if Craft is current in the middle of updating itself or a plugin. If you want the event to fire even in that condition, pass true to the $evenDuringUpdates argument.

View source

Arguments

  • $event (string) – The event to listen for.
  • $handler (mixed) – The event handler.
  • $evenDuringUpdates (boolean) – Whether the event handler should be attached when Craft’s updater is running. Default is false.

Returns

null

Signature

public null on ( $event, $handler, $evenDuringUpdates = false )

onEditionChange()

Fires an onEditionChange event.

View source

Arguments

Throws

Signature

public void onEditionChange ( Craft\Event $event )

onEndRequest()

Raised right AFTER the application processes the request.

View source

Arguments

  • $event (CEvent) – The event parameter.

Signature

public void onEndRequest ( $event )

processRequest()

Processes the request.

View source

Returns

null

Throws

Signature

public null processRequest ( )

returnAjaxError()

Formats a PHP error into JSON before returning it to the client.

View source

Arguments

  • $code (integer) – The error code.
  • $message (string) – The error message.
  • $file (string) – The error file.
  • $line (string) – The error line.

Returns

null

Signature

public null returnAjaxError ( $code, $message, $file, $line )

returnAjaxException()

Formats an exception into JSON before returning it to the client.

View source

Arguments

Returns

null

Signature

public null returnAjaxException ( $data )

setComponent()

Override setComponent so we can attach any pending events.

View source

Arguments

Returns

null

Signature

public null setComponent ( $id, $component, $merge = true )

setComponents()

Sets the application components.

View source

Arguments

Returns

null

Signature

public null setComponents ( $components, $merge = true )

setLanguage()

Sets the target application language.

View source

Arguments

Returns

null

Signature

public null setLanguage ( $language )

Protected Methods

MethodDescription
initSystemHandlers()Initializes the error handlers.
parseActionParams()Parses a path info into an action ID and GET variables.
preinit()Preinitializes the module.
preloadComponents()Loads static application components.
registerCoreComponents()Registers the core application components.