ConsoleApp

Type
Class
Namespace
Craft
Inherits
Craft\ConsoleApp » CConsoleApplication (opens new window) » CApplication (opens new window) » CModule (opens new window) » CComponent (opens new window)
Since
1.0

Class ConsoleApp

See also http://craftcms.com

View source (opens new window)

# Public Properties

Property Description
$behaviors (opens new window) array (opens new window) – The behaviors that should be attached to the module.
$charset (opens new window) string (opens new window) – The charset currently used for the application.
$commandMap (opens new window) array (opens new window) – Mapping from command name to command configurations.
$componentAliases
$localeClass (opens new window) string (opens new window) – The class used to get locale data.
$name (opens new window) string (opens new window) – The application name.
$preload (opens new window) array (opens new window) – The IDs of the application components that should be preloaded.
$sourceLanguage (opens new window) string (opens new window) – The language that the application is written in.

# $componentAliases

Signature

public  $componentAliases = null

# Public Methods

Method Description
__call() (opens new window) Calls the named method which is not a class method.
__construct() (opens new window) Constructor.
__get() (opens new window) Returns a property value, an event handler list or a behavior based on its name.
__isset() (opens new window) Checks if a property value is null.
__set() (opens new window) Sets value of a component property.
__unset() (opens new window) Sets a component property to be null.
asa() (opens new window) Returns the named behavior object.
attachBehavior() (opens new window) Attaches a behavior to this component.
attachBehaviors() (opens new window) Attaches a list of behaviors to the component.
attachEventHandler() (opens new window) Attaches an event handler to an event.
canGetProperty() (opens new window) Determines whether a property can be read.
canSetProperty() (opens new window) Determines whether a property can be set.
clearGlobalState() (opens new window) Clears a global value.
configure() (opens new window) Configures the module with the specified configuration.
createAbsoluteUrl() (opens new window) Creates an absolute URL based on the given controller and action information.
createUrl() (opens new window) Creates a relative URL based on the given controller and action information.
detachBehavior() (opens new window) Detaches a behavior from the component.
detachBehaviors() (opens new window) Detaches all behaviors from the component.
detachEventHandler() (opens new window) Detaches an existing event handler.
disableBehavior() (opens new window) Disables an attached behavior.
disableBehaviors() (opens new window) Disables all behaviors attached to this component.
displayError() (opens new window) Displays the captured PHP error.
displayException() (opens new window) Displays the uncaught PHP exception.
enableBehavior() (opens new window) Enables an attached behavior.
enableBehaviors() (opens new window) Enables all behaviors attached to this component.
end() (opens new window) Terminates the application.
evaluateExpression() (opens new window) Evaluates a PHP expression or callback under the context of this component.
findLocalizedFile() (opens new window) Returns the localized version of a specified file.
getBasePath() (opens new window) Returns the root path of the application.
getBaseUrl() (opens new window) Returns the relative URL for the application.
getCache() (opens new window) Returns the cache component.
getCommand() (opens new window) Returns the currently running command.
getCommandPath() (opens new window)
getCommandRunner() (opens new window) Returns the command runner.
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() (opens new window) Returns the application components.
getController() (opens new window)
getCoreMessages() (opens new window) Returns the core message translations component.
getDateFormatter() (opens new window) Returns the locale-dependent date formatter.
getDb() (opens new window) Returns the database connection component.
getErrorHandler() (opens new window) Returns the error handler component.
getEventHandlers() (opens new window) Returns the list of attached event handlers for an event.
getExtensionPath() (opens new window) Returns the root directory that holds all third-party extensions.
getFormat() (opens new window) Returns the formatter component.
getGlobalState() (opens new window) Returns a global value.
getHomeUrl() (opens new window)
getId() (opens new window) Returns the unique identifier for the application.
getLanguage() Returns the target application language.
getLocale() (opens new window) Returns the locale instance.
getLocaleDataPath() (opens new window) Returns the directory that contains the locale data.
getMessages() (opens new window) Returns the application message translations component.
getModule() (opens new window) Retrieves the named application module.
getModulePath() (opens new window) Returns the directory that contains the application modules.
getModules() (opens new window) Returns the configuration of the currently installed modules.
getNumberFormatter() (opens new window)
getParams() (opens new window) Returns user-defined parameters.
getParentModule() (opens new window) Returns the parent module.
getRequest() (opens new window) Returns the request component.
getRuntimePath() (opens new window) Returns the directory that stores runtime files.
getSecurityManager() (opens new window) Returns the security manager component.
getStatePersister() (opens new window) Returns the state persister component.
getTimeZone() Returns the system time zone. Note that this method cannot be in {@link AppBehavior}, because Yii will check {@link \CApplication::getTimeZone()} instead.
getUrlManager() (opens new window) Returns the URL manager component.
handleError()
handleException() (opens new window) Handles uncaught PHP exceptions.
hasComponent() (opens new window) Checks whether the named component exists.
hasEvent() (opens new window) Determines whether an event is defined.
hasEventHandler() (opens new window) Checks whether the named event has attached handlers.
hasModule() (opens new window) Returns a value indicating whether the specified module is installed.
hasProperty() (opens new window) Determines whether a property is defined.
init() Initializes the console app by creating the command runner.
isConsole() Returns whether we are executing in the context on a console app.
loadGlobalState() (opens new window) 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() (opens new window) Raised right BEFORE the application processes the request.
onEndRequest() (opens new window) Raised right AFTER the application processes the request.
onError() (opens new window) Raised when a PHP execution error occurs.
onException() (opens new window) Raised when an uncaught PHP exception occurs.
processRequest() (opens new window) Processes the request.
raiseEvent() (opens new window) Raises an event.
run() (opens new window) Runs the application.
saveGlobalState() (opens new window) Saves the global state data into persistent storage.
setAliases() (opens new window) Defines the root aliases.
setBasePath() (opens new window) Sets the root directory of the application.
setCommand() (opens new window) This is shortcut method for {@link CConsoleCommandRunner::setCommand()}.
setCommandPath() (opens new window)
setComponent() (opens new window) Puts a component under the management of the module.
setComponents() Sets the application components.
setExtensionPath() (opens new window) Sets the root directory that holds all third-party extensions.
setGlobalState() (opens new window) Sets a global value.
setHomeUrl() (opens new window)
setId() (opens new window) Sets the unique identifier for the application.
setImport() (opens new window) Sets the aliases that are used in the module.
setLanguage() Sets the target application language.
setLocaleDataPath() (opens new window) Sets the directory that contains the locale data.
setModulePath() (opens new window) Sets the directory that contains the application modules.
setModules() (opens new window) Configures the sub-modules of this module.
setParams() (opens new window) Sets user-defined parameters.
setRuntimePath() (opens new window) Sets the directory that stores runtime files.
setTimeZone() (opens new window) Sets the time zone used by this application.

# 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 (opens new window)

Arguments

Returns

mixed

Signature

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

# getLanguage()

Returns the target application language.

View source (opens new window)

Returns

string (opens new window)

Signature

public string getLanguage ( )

# 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 (opens new window)

Returns

string (opens new window)

Signature

public string getTimeZone ( )

# handleError()

View source (opens new window)

Arguments

Signature

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

# init()

Initializes the console app by creating the command runner.

View source (opens new window)

Returns

null (opens new window)

Signature

public null init ( )

# isConsole()

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

View source (opens new window)

Returns

boolean (opens new window)

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 (opens new window)

Arguments

Returns

null (opens new window)

Signature

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

# setComponents()

Sets the application components.

View source (opens new window)

Arguments

Returns

null (opens new window)

Signature

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

# setLanguage()

Sets the target application language.

View source (opens new window)

Arguments

Returns

null (opens new window)

Signature

public null setLanguage ( $language )

# Protected Methods

Method Description
createCommandRunner()
initSystemHandlers() (opens new window) Initializes the error handlers.
preinit() (opens new window) Preinitializes the module.
preloadComponents() (opens new window) Loads static application components.
registerCoreComponents() (opens new window) Registers the core application components.

# createCommandRunner()

Signature

protected Craft\ConsoleCommandRunner createCommandRunner ( )