Skip to content
This repository has been archived by the owner on Sep 18, 2024. It is now read-only.

Commit

Permalink
Update feature: Minor refactor to minion module
Browse files Browse the repository at this point in the history
  • Loading branch information
Gleez Technologies committed Jun 2, 2014
1 parent 7cbf731 commit a07ca58
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 7 deletions.
7 changes: 6 additions & 1 deletion modules/minion/classes/migration.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,13 @@ class Migration {
* @param Database $db The database connection that should be passed to migrations
* @param Model_Migration $model Inject an instance of the minion model into the manager
*/
public function __construct(Database $db, Model_Migration $model = NULL)
public function __construct($db = NULL, Model_Migration $model = NULL)
{
if($db == NULL)
{
$db = Database::instance(NULL);

This comment has been minimized.

Copy link
@sergeyklay

sergeyklay Jun 3, 2014

Contributor

it is contrary to freedom from dependency

This comment has been minimized.

Copy link
@sandeepone

sandeepone Jun 8, 2014

Member

Yep! Exactly. I'm able to run with our Database repo by removing this dependency. Will push those changes shortly.

}

if ($model === NULL)
{
$model = new Model_Migration($db);
Expand Down
7 changes: 6 additions & 1 deletion modules/minion/classes/model/migration.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,13 @@ class Model_Migration extends Model
*
* @param Kohana_Database $db Database connection to use
*/
public function __construct(Database $db)
public function __construct($db = NULL)
{
if($db == NULL)
{
$db = Database::instance(NULL);
}

$this->_db = $db;

$this->_table = Config::get('migration.table', 'migrations');
Expand Down
6 changes: 2 additions & 4 deletions modules/minion/classes/task/db/migrate.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,10 @@ protected function _execute(array $options)
}
}

$db = Database::instance();
$model = new Model_Migration($db);

$model = new Model_Migration();
$model->ensure_table_exists();

$manager = new Migration($db, $model);
$manager = new Migration(NULL, $model);

// Sync the available migrations with those in the db
$manager
Expand Down
2 changes: 1 addition & 1 deletion modules/minion/classes/task/db/migrate/status.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class Task_Db_Migrate_Status extends Minion_Task
*/
protected function _execute(array $options)
{
$model = new Model_Migration(Database::instance());
$model = new Model_Migration();
$view = new View('minion/db/status');

$view->groups = $model->get_group_statuses();
Expand Down

0 comments on commit a07ca58

Please sign in to comment.