Inherited by Doctrine_Task_BuildAll, Doctrine_Task_BuildAllLoad, Doctrine_Task_BuildAllReload, Doctrine_Task_Compile, Doctrine_Task_CreateDb, Doctrine_Task_CreateTables, Doctrine_Task_Dql, Doctrine_Task_DropDb, Doctrine_Task_DumpData, Doctrine_Task_GenerateMigration, Doctrine_Task_GenerateMigrationsDb, Doctrine_Task_GenerateMigrationsDiff, Doctrine_Task_GenerateMigrationsModels, Doctrine_Task_GenerateModelsDb, Doctrine_Task_GenerateModelsYaml, Doctrine_Task_GenerateSql, Doctrine_Task_GenerateYamlDb, Doctrine_Task_GenerateYamlModels, Doctrine_Task_LoadData, Doctrine_Task_Migrate, and Doctrine_Task_RebuildDb.
Definition at line 35 of file Task.php.
| Doctrine_Task::__construct |
( |
|
$dispatcher = null | ) |
|
__construct
Since this is an abstract classes that extend this must follow a patter of Doctrine_Task_{TASK_NAME} This is what determines the task name for executing it.
- Returns
- void
Definition at line 52 of file Task.php.
{
$this->dispatcher = $dispatcher;
if (! strlen($taskName)) {
$taskName = self::deriveTaskName(get_class($this));
}
}
| Doctrine_Task::addArgument |
( |
|
$name, |
|
|
|
$value |
|
) |
| |
addArgument
- Parameters
-
- Returns
- void
Definition at line 166 of file Task.php.
{
$this->arguments[$name] = $value;
}
ask
- Returns
- void
Definition at line 118 of file Task.php.
{
$args = func_get_args();
call_user_func_array(array($this, 'notify'), $args);
$answer = strtolower(trim(fgets(STDIN)));
return $answer;
}
| static Doctrine_Task::deriveTaskName |
( |
|
$className | ) |
|
|
static |
Returns the name of the task the specified class would implement
N.B. This method does not check if the specified class is actually a Doctrine Task
This is public so we can easily test its reactions to fully-qualified class names, without having to add PHP 5.3-specific test code
- Parameters
-
- Returns
- string|bool
Definition at line 81 of file Task.php.
{
$nameParts = explode('\\', $className);
foreach ($nameParts as &$namePart) {
$prefix = __CLASS__ . '_';
$baseName = strpos($namePart, $prefix) === 0 ? substr($namePart, strlen($prefix)) : $namePart;
}
return implode('-', $nameParts);
}
| Doctrine_Task::execute |
( |
| ) |
|
|
abstract |
execute
Override with each task class
- Returns
- void
| Doctrine_Task::getArgument |
( |
|
$name, |
|
|
|
$default = null |
|
) |
| |
getArgument
- Parameters
-
| string | $name | |
| string | $default | |
- Returns
- mixed
Definition at line 178 of file Task.php.
{
if (isset($this->arguments[$name]) && $this->arguments[$name] !== null) {
return $this->arguments[$name];
} else {
return $default;
}
}
| Doctrine_Task::getArguments |
( |
| ) |
|
getArguments
- Returns
- array $arguments
Definition at line 192 of file Task.php.
{
return $this->arguments;
}
| Doctrine_Task::getDescription |
( |
| ) |
|
getDescription
- Returns
- string $description
Definition at line 255 of file Task.php.
{
return $this->description;
}
| Doctrine_Task::getOptionalArguments |
( |
| ) |
|
getOptionalArguments
- Returns
- array $optionalArguments
Definition at line 275 of file Task.php.
{
return array_keys($this->optionalArguments);
}
| Doctrine_Task::getOptionalArgumentsDescriptions |
( |
| ) |
|
getOptionalArgumentsDescriptions
- Returns
- array $optionalArgumentsDescriptions
Definition at line 295 of file Task.php.
{
return $this->optionalArguments;
}
| Doctrine_Task::getRequiredArguments |
( |
| ) |
|
getRequiredArguments
- Returns
- array $requiredArguments
Definition at line 265 of file Task.php.
{
return array_keys($this->requiredArguments);
}
| Doctrine_Task::getRequiredArgumentsDescriptions |
( |
| ) |
|
getRequiredArgumentsDescriptions
- Returns
- array $requiredArgumentsDescriptions
Definition at line 285 of file Task.php.
{
return $this->requiredArguments;
}
| Doctrine_Task::getTaskName |
( |
| ) |
|
getTaskName
- Returns
- string $taskName
Definition at line 245 of file Task.php.
{
return $this->taskName;
}
| Doctrine_Task::notify |
( |
|
$notification = null | ) |
|
notify
- Parameters
-
- Returns
- void
Definition at line 100 of file Task.php.
{
if (is_object($this->dispatcher) && method_exists($this->dispatcher, 'notify')) {
$args = func_get_args();
return call_user_func_array(array($this->dispatcher, 'notify'), $args);
} else if ( $notification !== null ) {
return $notification;
} else {
return false;
}
}
| Doctrine_Task::setArguments |
( |
array |
$args | ) |
|
setArguments
- Parameters
-
- Returns
- void
Definition at line 203 of file Task.php.
{
$this->arguments = $args;
}
| Doctrine_Task::setTaskName |
( |
|
$taskName | ) |
|
|
protected |
Sets the name of the task, the name that's used to invoke it through a CLI
- Parameters
-
- Exceptions
-
| InvalidArgumentException | If the task name is invalid |
Definition at line 229 of file Task.php.
{
if (! self::validateTaskName($taskName)) {
throw new InvalidArgumentException(
sprintf('The task name "%s", in %s, is invalid', $taskName, get_class($this))
);
}
$this->taskName = $taskName;
}
| Doctrine_Task::validate |
( |
| ) |
|
validate
Validates that all required fields are present
- Returns
- bool true
Definition at line 146 of file Task.php.
{
foreach ($requiredArguments as $arg) {
if ( ! isset($this->arguments[$arg])) {
return false;
}
}
return true;
}
| static Doctrine_Task::validateTaskName |
( |
|
$taskName | ) |
|
|
staticprotected |
Returns TRUE if the specified task name is valid, or FALSE otherwise
- Parameters
-
- Returns
- bool
Definition at line 214 of file Task.php.
{
return (bool) preg_match('/^[a-z0-9][a-z0-9\-]*$/', $taskName);
}
The documentation for this class was generated from the following file: