public function __call($name, $arguments) { $config_path = Registry::get('config.dir.root') . '/app/Tygh/UpgradeCenter/Migrations/config.migrations.php'; switch ($name) { case 'migrate': $_SERVER['argv'] = array('phinx', 'migrate', '-c' . $config_path, '-edevelopment'); break; case 'rollback': $_SERVER['argv'] = array('phinx', 'rollback', '-c' . $config_path, '-edevelopment'); break; default: return false; } $output = new Output(); $output->setConfig($this->config); $output->setVerbosity(Output::VERBOSITY_VERBOSE); $app = new PhinxApplication('0.4.3'); AdapterFactory::instance()->registerAdapter('mysqli', '\\Tygh\\UpgradeCenter\\Phinx\\MysqliAdapter'); $app->setAutoExit(false); $app->setCatchExceptions(false); try { $exit_code = $app->run(null, $output); } catch (\Exception $e) { // Convert PDOException to DatabaseException if (class_exists('\\PDOException') && $e instanceof \PDOException) { throw new DatabaseException($e->getMessage(), $e->getCode(), $e); } else { throw $e; } } return $exit_code === 0; }
public function __call($name, $arguments) { $config_path = Registry::get('config.dir.root') . '/app/Tygh/UpgradeCenter/Migrations/config.migrations.php'; switch ($name) { case 'migrate': $_SERVER['argv'] = array('phinx', 'migrate', '-c' . $config_path, '-edevelopment'); break; case 'rollback': $_SERVER['argv'] = array('phinx', 'rollback', '-c' . $config_path, '-edevelopment'); break; default: return false; } $output = new Output(); $output->setConfig($this->config); $app = new \Phinx\Console\PhinxApplication('0.3.7'); $app->setAutoExit(false); $app->run(null, $output); }