From 6bffc7b44e89f492a65c48e2ec2f3735e6f526a8 Mon Sep 17 00:00:00 2001 From: marco Date: Mon, 10 Aug 2015 17:30:30 +0200 Subject: [PATCH] PHP and closures. It's 1990 again. --- lib/config/activator.php | 9 +++------ lib/config/migrator.php | 5 +++-- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/lib/config/activator.php b/lib/config/activator.php index 7f0f75fb3e..baf809a2ec 100644 --- a/lib/config/activator.php +++ b/lib/config/activator.php @@ -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(); } } diff --git a/lib/config/migrator.php b/lib/config/migrator.php index 5191f8fb46..e6dbe34621 100644 --- a/lib/config/migrator.php +++ b/lib/config/migrator.php @@ -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);