Versions
Look up a class, method, property or event

CConsoleCommandRunner

Package system.console
Inheritance class CConsoleCommandRunner » CComponent
Since 1.0
Version $Id: CConsoleCommandRunner.php 1799 2010-02-07 19:03:33Z qiang.xue $
CConsoleCommandRunner manages commands and executes the requested command.

Public Properties

Hide inherited properties

PropertyTypeDescriptionDefined By
commands array list of all available commands (command name=>command configuration). CConsoleCommandRunner
scriptName string the entry script name CConsoleCommandRunner

Public Methods

Hide inherited methods

MethodDescriptionDefined By
__call() Calls the named method which is not a class method. CComponent
__get() Returns a property value, an event handler list or a behavior based on its name. CComponent
__isset() Checks if a property value is null. CComponent
__set() Sets value of a component property. CComponent
__unset() Sets a component property to be null. CComponent
addCommands() Adds commands from the specified command path. CConsoleCommandRunner
asa() Returns the named behavior object. CComponent
attachBehavior() Attaches a behavior to this component. CComponent
attachBehaviors() Attaches a list of behaviors to the component. CComponent
attachEventHandler() Attaches an event handler to an event. CComponent
canGetProperty() Determines whether a property can be read. CComponent
canSetProperty() Determines whether a property can be set. CComponent
createCommand() CConsoleCommandRunner
detachBehavior() Detaches a behavior from the component. CComponent
detachBehaviors() Detaches all behaviors from the component. CComponent
detachEventHandler() Detaches an existing event handler. CComponent
disableBehavior() Disables an attached behavior. CComponent
disableBehaviors() Disables all behaviors attached to this component. CComponent
enableBehavior() Enables an attached behavior. CComponent
enableBehaviors() Enables all behaviors attached to this component. CComponent
findCommands() Searches for commands under the specified directory. CConsoleCommandRunner
getEventHandlers() Returns the list of attached event handlers for an event. CComponent
getScriptName() CConsoleCommandRunner
hasEvent() Determines whether an event is defined. CComponent
hasEventHandler() Checks whether the named event has attached handlers. CComponent
hasProperty() Determines whether a property is defined. CComponent
raiseEvent() Raises an event. CComponent
run() Executes the requested command. CConsoleCommandRunner

Property Details

commands property
public array $commands;

list of all available commands (command name=>command configuration). Each command configuration can be either a string or an array. If the former, the string should be the class name or class path alias of the command. If the latter, the array must contain a 'class' element which specifies the command's class name or class path alias. The rest name-value pairs in the array are used to initialize the corresponding command properties. For example,

array(
  'email'=>array(
     'class'=>'path.to.Mailer',
     'interval'=>3600,
  ),
  'log'=>'path.to.LoggerCommand',
)

scriptName property read-only
public string getScriptName()

the entry script name

Method Details

addCommands() method
public void addCommands(string $path)
$path string the alias of the directory containing the command class files.

Adds commands from the specified command path. If a command already exists, the new one will be ignored.

createCommand() method
public CConsoleCommand createCommand(string $name)
$name string command name (case-insensitive)
{return} CConsoleCommand the command object. Null if the name is invalid.

findCommands() method
public array findCommands(string $path)
$path string the directory containing the command class files.
{return} array list of commands (command name=>command class file)

Searches for commands under the specified directory.

getScriptName() method
public string getScriptName()
{return} string the entry script name

run() method
public void run(array $args)
$args array list of user supplied parameters (including the entry script name and the command name).

Executes the requested command.

Be the first person to leave a comment

Please to leave your comment.