1
0
Fork 0
mirror of https://github.com/Oreolek/kohana-migrations.git synced 2024-06-16 15:01:08 +03:00

moved generating of migration to public method so it can be used for other tasks

This commit is contained in:
Michał Matyas 2011-06-30 14:40:24 +02:00
parent 3c8d16ce55
commit f30cca150b

View file

@ -45,6 +45,20 @@ class Minion_Task_Db_Generate extends Minion_Task
* @param array Configuration
*/
public function execute(array $config)
{
try
{
$file = $this->generate($config);
Minion_CLI::write('Migration generated: '.$file);
}
catch(ErrorException $e)
{
Minion_CLI::write($e->getMessage());
}
}
public function generate($config)
{
$defaults = array(
'location' => APPPATH,
@ -59,9 +73,7 @@ class Minion_Task_Db_Generate extends Minion_Task
if ( ! $this->_valid_group($config['group']))
{
Minion_CLI::write('Please provide a valid --group');
Minion_CLI::write('See help for more info');
return;
throw new ErrorException("Please provide a valid --group\nSee help for more info");
}
$group = $config['group'].'/';
@ -86,8 +98,7 @@ class Minion_Task_Db_Generate extends Minion_Task
file_put_contents($file, $data);
Minion_CLI::write('Migration generated: '.$file);
return;
return $file;
}
/**