1
0
Fork 0
mirror of https://github.com/Oreolek/kohana-migrations.git synced 2024-07-02 22:55:03 +03:00
kohana-migrations/classes/minion/task.php
Matt Button c026cbb415 Limiting command line to executing a single task.
This reduces both the complexity for the end user (no pesky task namespace on config options)
and also removes a good few LOC

Minion_Master has been removed in favour of Controller_Minion + Minion_Test::factory()
2010-12-29 01:01:32 +00:00

75 lines
1.3 KiB
PHP

<?php
/**
* Interface that all minion tasks must implement
*
*/
abstract class Minion_Task {
/**
* Factory for loading minion tasks
*
* @throws Kohana_Exception
* @param string The task to load
* @return Minion_Task The Minion task
*/
public static function factory($task)
{
if(is_string($task))
{
$class = Minion_Util::convert_task_to_class_name($task);
$task = new $class;
}
if( ! $task instanceof Minion_Task)
{
throw new Kohana_Exception(
"Task ':task' is not a valid minion task",
array(':task' => get_class($task))
);
}
return $task;
}
/**
* A set of config options that the task accepts on the command line
* @var array
*/
protected $_config = array();
/**
* Gets the task name for the task
*
* @return string
*/
public function __toString()
{
static $task_name = NULL;
if($task_name === NULL)
{
$task_name = Minion_Util::convert_class_to_task($this);
}
return $task_name;
}
/**
* Get a set of config options that this task can accept
*
* @return array
*/
public function get_config_options()
{
return $this->_config;
}
/**
* Execute the task with the specified set of config
*
* @return boolean TRUE if task executed successfully, else FALSE
*/
abstract public function execute(array $config);
}