/** * Executa todos os migrations do phinx * * @param InputInterface $input * @param OutputInterface $output * @return bool|int|null */ protected function execute(InputInterface $input, OutputInterface $output) { $migrations = []; //migrations app $migrations[] = APPDIR . 'migrations'; //find migrations extensions $migrations_extensions = glob(Util::pathExtension() . '*/app/migrations', GLOB_ONLYDIR); $migrations = array_merge($migrations, $migrations_extensions); foreach ($migrations as $migration) { $migration = str_replace('//', '/', $migration); $_SERVER['PHINX_MIGRATION_PATH'] = $migration; //init phinx $app = new \Phinx\Console\PhinxApplication(); $wrap = new \Phinx\Wrapper\TextWrapper($app); //set parser $wrap->setOption('parser', 'php'); //set config file $wrap->setOption('configuration', APPDIR . 'phinx.php'); // Get the environment and target version parameters. $env = ENV; //execute migrate $output_func = $wrap->getMigrate($env); $output->writeln($output_func); } return true; }
/** * instala arquivos do tema se tiver na extensao * @param $extension * @param $output */ private function installThemeFiles($extension, $output) { $theme_files = Util::getFilesTheme($extension); if (count($theme_files)) { $table = new Table($output); $table->setHeaders(array('Theme Files')); $themes = Util::getThemesPath(); foreach ($themes as $theme) { foreach ($theme_files as $theme_file) { $dest = str_replace($extension . '/theme/', $theme . '/', $theme_file); $dir = dirname($dest); if (!is_dir($dir)) { mkdir($dir, 0755, true); } if (!file_exists($dest)) { $table->addRow(['<info>' . $dest . '</info>']); } else { $table->addRow(['<comment>' . $dest . '</comment>']); } @copy($theme_file, $dest); } } $table->render(); } }
/** * remove arquivos do tema * @param $extension * @param $output */ private function removeThemeFiles($extension, $output) { $theme_files = Util::getFilesTheme($extension); if (count($theme_files)) { $table = new Table($output); $table->setHeaders(array('Theme Files')); $themes = Util::getThemesPath(); foreach ($themes as $theme) { foreach ($theme_files as $theme_file) { $dest = str_replace($extension . '/theme/', $theme . '/', $theme_file); $dir = dirname($dest); if (file_exists($dest)) { $table->addRow(['<info>' . $dest . '</info>']); } else { $table->addRow(['<error>' . $dest . '</error>']); } @unlink($dest); //limpa a pasta se estiver vazia $dir_status = glob($dir . '/*'); if (empty($dir_status)) { @rmdir($dir); } } } $table->render(); } }