PHP and closures. It's 1990 again.
This commit is contained in:
@ -9,17 +9,14 @@ class Activator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function init() {
|
function init() {
|
||||||
$this->migrator = new Migrator;
|
|
||||||
}
|
|
||||||
|
|
||||||
function register_activation() {
|
|
||||||
register_activation_hook(
|
register_activation_hook(
|
||||||
Env::$file,
|
Env::$file,
|
||||||
array($this, 'activate')
|
array($this, 'activate')
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function activate() {
|
function activate() {
|
||||||
$this->migrator->up();
|
$migrator = new Migrator();
|
||||||
|
$migrator->up();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,8 +19,9 @@ class Migrator {
|
|||||||
function up() {
|
function up() {
|
||||||
global $wpdb;
|
global $wpdb;
|
||||||
|
|
||||||
$migrate = function($model) {
|
$_this = $this;
|
||||||
dbDelta($this->$model());
|
$migrate = function($model) use ($_this) {
|
||||||
|
dbDelta($_this->$model());
|
||||||
};
|
};
|
||||||
|
|
||||||
array_map($migrate, $this->models);
|
array_map($migrate, $this->models);
|
||||||
|
Reference in New Issue
Block a user