PHP and closures. It's 1990 again.

This commit is contained in:
marco
2015-08-10 17:30:30 +02:00
parent f9c9da87d6
commit 6bffc7b44e
2 changed files with 6 additions and 8 deletions

View File

@ -9,17 +9,14 @@ class Activator {
}
function init() {
$this->migrator = new Migrator;
}
function register_activation() {
register_activation_hook(
Env::$file,
array($this, 'activate')
);
}
public function activate() {
$this->migrator->up();
function activate() {
$migrator = new Migrator();
$migrator->up();
}
}

View File

@ -19,8 +19,9 @@ class Migrator {
function up() {
global $wpdb;
$migrate = function($model) {
dbDelta($this->$model());
$_this = $this;
$migrate = function($model) use ($_this) {
dbDelta($_this->$model());
};
array_map($migrate, $this->models);