Doctrine 1.2.4
Doctrine_Task_GenerateMigration Class Reference

Inherits Doctrine_Task.

Public Member Functions

 addArgument ($name, $value)
 
 ask ()
 
 getArgument ($name, $default=null)
 
 getArguments ()
 
 getDescription ()
 
 getOptionalArguments ()
 
 getOptionalArgumentsDescriptions ()
 
 getRequiredArguments ()
 
 getRequiredArgumentsDescriptions ()
 
 getTaskName ()
 
 notify ($notification=null)
 
 setArguments (array $args)
 
 validate ()
 

Static Public Member Functions

static deriveTaskName ($className)
 

Protected Member Functions

 setTaskName ($taskName)
 

Static Protected Member Functions

static validateTaskName ($taskName)
 

Detailed Description

Definition at line 33 of file GenerateMigration.php.

Member Function Documentation

Doctrine_Task::addArgument (   $name,
  $value 
)
inherited

addArgument

Parameters
string$name
string$value
Returns
void

Definition at line 166 of file Task.php.

{
$this->arguments[$name] = $value;
}
Doctrine_Task::ask ( )
inherited

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)
staticinherited

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
string$className
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;
$namePart = str_replace('_', '-', Doctrine_Inflector::tableize($baseName));
}
return implode('-', $nameParts);
}
Doctrine_Task::getArgument (   $name,
  $default = null 
)
inherited

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 ( )
inherited

getArguments

Returns
array $arguments

Definition at line 192 of file Task.php.

{
return $this->arguments;
}
Doctrine_Task::getDescription ( )
inherited

getDescription

Returns
string $description

Definition at line 255 of file Task.php.

{
return $this->description;
}
Doctrine_Task::getOptionalArguments ( )
inherited

getOptionalArguments

Returns
array $optionalArguments

Definition at line 275 of file Task.php.

{
return array_keys($this->optionalArguments);
}
Doctrine_Task::getOptionalArgumentsDescriptions ( )
inherited

getOptionalArgumentsDescriptions

Returns
array $optionalArgumentsDescriptions

Definition at line 295 of file Task.php.

{
return $this->optionalArguments;
}
Doctrine_Task::getRequiredArguments ( )
inherited

getRequiredArguments

Returns
array $requiredArguments

Definition at line 265 of file Task.php.

{
return array_keys($this->requiredArguments);
}
Doctrine_Task::getRequiredArgumentsDescriptions ( )
inherited

getRequiredArgumentsDescriptions

Returns
array $requiredArgumentsDescriptions

Definition at line 285 of file Task.php.

{
return $this->requiredArguments;
}
Doctrine_Task::getTaskName ( )
inherited

getTaskName

Returns
string $taskName

Definition at line 245 of file Task.php.

{
return $this->taskName;
}
Doctrine_Task::notify (   $notification = null)
inherited

notify

Parameters
string$notification
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)
inherited

setArguments

Parameters
array$args
Returns
void

Definition at line 203 of file Task.php.

{
$this->arguments = $args;
}
Doctrine_Task::setTaskName (   $taskName)
protectedinherited

Sets the name of the task, the name that's used to invoke it through a CLI

Parameters
string$taskName
Exceptions
InvalidArgumentExceptionIf 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 ( )
inherited

validate

Validates that all required fields are present

Returns
bool true

Definition at line 146 of file Task.php.

{
$requiredArguments = $this->getRequiredArguments();
foreach ($requiredArguments as $arg) {
if ( ! isset($this->arguments[$arg])) {
return false;
}
}
return true;
}
static Doctrine_Task::validateTaskName (   $taskName)
staticprotectedinherited

Returns TRUE if the specified task name is valid, or FALSE otherwise

Parameters
string$taskName
Returns
bool

Definition at line 214 of file Task.php.

{
/*
* This follows the _apparent_ naming convention. The key thing is to prevent the use of characters that would
* break a command string - we definitely can't allow spaces, for example.
*/
return (bool) preg_match('/^[a-z0-9][a-z0-9\-]*$/', $taskName);
}

The documentation for this class was generated from the following file: