src/Migrator.php
/**
     * Execute a given command in the Phinx application in the WordPress environment
     *
     * @param string $command - Command to execute
     * @param array  $args    - Arguments
     *
     * @return mixed
     */
Execute a given command in the Phinx application in the WordPress environment
@param string $command - Command to execute
@param array  $args    - Arguments

@return mixed
Execute a given command in the Phinx application in the WordPress environment @param string $command - Command to execute @param array $args - Arguments @return mixed
private function execute($command, $args = [])
    {
        $config = $this->generateConfig();
        if (!in_array($command, ['current', 'versions'])) {
            $app = new Application();
            $app->setAutoExit(false);
            $factory = AdapterFactory::instance();
            $factory->registerAdapter('wordpress', WordPressAdapter::class);
            $factory->registerWrapper('wordpress', WordPressWrapper::class);
            $runtimeArgs = ['phinx', $command, '-ewordpress', '-q'];
            foreach ($args as $arg => $value) {
                if ($value !== null) {
                    $runtimeArgs[] = sprintf('--%s=%s', $arg, $value);
                }
            }
            unset($args);
            $cmd = $app->get($command);
            $cmd->setConfig(new Config($config));
            $output = new BufferedOutput();
            $exit = $app->run(new ArgvInput($runtimeArgs), $output);
            if (strtolower($command) == 'status') {
                return $exit;
            }
            if ($exit != 0) {
                $log = trim($output->fetch());
                $log = implode("\n", array_map('trim', array_slice(explode("\n", $log), 0, -1)));
                $log = str_replace("\n", '', $log);
                $log = trim(preg_replace('/\[.+?\]/', "\n", $log));
                throw new \RuntimeException(sprintf('%s did not complete successfully: %s', $command, $log));
            }
        }
        $adapter = new WordPressAdapter(array_merge(
            $config['environments']['wordpress'],
            ['default_migration_table' => $config['environments']['default_migration_table']]
        ));
        $versions = $adapter->getVersions();
        if ($command === 'versions') {
            return $versions;
        }
        if (empty($versions)) {
            return 'NULL';
        }
        return $versions[count($versions) - 1];
    }
private function execute ( $ command , $ args = [ ] ) { $ config = $ this -> generateConfig ( ) ; if ( ! in_array ( $ command , [ 'current' , 'versions' ] ) ) { $ app = new Application ( ) ; $ app -> setAutoExit ( false ) ; $ factory = AdapterFactory :: instance ( ) ; $ factory -> registerAdapter ( 'wordpress' , WordPressAdapter :: class ) ; $ factory -> registerWrapper ( 'wordpress' , WordPressWrapper :: class ) ; $ runtimeArgs = [ 'phinx' , $ command , '-ewordpress' , '-q' ] ; foreach ( $ args as $ arg => $ value ) { if ( $ value !== null ) { $ runtimeArgs [ ] = sprintf ( '--%s=%s' , $ arg , $ value ) ; } } unset ( $ args ) ; $ cmd = $ app -> get ( $ command ) ; $ cmd -> setConfig ( new Config ( $ config ) ) ; $ output = new BufferedOutput ( ) ; $ exit = $ app -> run ( new ArgvInput ( $ runtimeArgs ) , $ output ) ; if ( strtolower ( $ command ) == 'status' ) { return $ exit ; } if ( $ exit != 0 ) { $ log = trim ( $ output -> fetch ( ) ) ; $ log = implode ( " \n " , array_map ( 'trim' , array_slice ( explode ( " \n " , $ log ) , 0 , - 1 ) ) ) ; $ log = str_replace ( " \n " , '' , $ log ) ; $ log = trim ( preg_replace ( '/\[.+?\]/' , " \n " , $ log ) ) ; throw new \ RuntimeException ( sprintf ( '%s did not complete successfully: %s' , $ command , $ log ) ) ; } } $ adapter = new WordPressAdapter ( array_merge ( $ config [ 'environments' ] [ 'wordpress' ] , [ 'default_migration_table' => $ config [ 'environments' ] [ 'default_migration_table' ] ] ) ) ; $ versions = $ adapter -> getVersions ( ) ; if ( $ command === 'versions' ) { return $ versions ; } if ( empty ( $ versions ) ) { return 'NULL' ; } return $ versions [ count ( $ versions ) - 1 ] ; }
Execute a given command in the Phinx application in the WordPress environment
 @param string $command - Command to execute
 @param array  $args    - Arguments
Execute a given command in the Phinx application in the WordPress environment @param string $command - Command to execute @param array $args - Arguments
/** @var \Phinx\Console\Command\AbstractCommand $cmd */ // For the status command, non-zero exit code means available migrations // Non-zero for all other commands means failure