N98\Magento\Command\Database\DumpCommand::execute PHP Метод

execute() защищенный Метод

protected execute ( Symfony\Component\Console\Input\InputInterface $input, Symfony\Component\Console\Output\OutputInterface $output ) : integer | void
$input Symfony\Component\Console\Input\InputInterface
$output Symfony\Component\Console\Output\OutputInterface
Результат integer | void
    protected function execute(InputInterface $input, OutputInterface $output)
    {
        // communicate early what is required for this command to run (is enabled)
        $enabler = new Enabler($this);
        $enabler->functionExists('exec');
        $enabler->functionExists('passthru');
        $enabler->operatingSystemIsNotWindows();
        $this->detectDbSettings($output);
        /* @var $dbHelper DatabaseHelper */
        $dbHelper = $this->getHelper('database');
        if (!$input->getOption('stdout') && !$input->getOption('only-command') && !$input->getOption('print-only-filename')) {
            $this->writeSection($output, 'Dump MySQL Database');
        }
        $compressor = $this->getCompressor($input->getOption('compression'));
        $fileName = $this->getFileName($input, $output, $compressor);
        $stripTables = array();
        if ($input->getOption('strip')) {
            /* @var $database DatabaseHelper */
            $database = $dbHelper;
            $stripTables = $database->resolveTables(explode(' ', $input->getOption('strip')), $dbHelper->getTableDefinitions($this->getCommandConfig()));
            if (!$input->getOption('stdout') && !$input->getOption('only-command') && !$input->getOption('print-only-filename')) {
                $output->writeln('<comment>No-data export for: <info>' . implode(' ', $stripTables) . '</info></comment>');
            }
        }
        $excludeTables = array();
        if ($input->getOption('exclude')) {
            $excludeTables = $dbHelper->resolveTables(explode(' ', $input->getOption('exclude')), $dbHelper->getTableDefinitions($this->getCommandConfig()));
            if (!$input->getOption('stdout') && !$input->getOption('only-command') && !$input->getOption('print-only-filename')) {
                $output->writeln('<comment>Excluded: <info>' . implode(' ', $excludeTables) . '</info></comment>');
            }
        }
        $dumpOptions = '';
        if (!$input->getOption('no-single-transaction')) {
            $dumpOptions = '--single-transaction --quick ';
        }
        if ($input->getOption('human-readable')) {
            $dumpOptions .= '--complete-insert --skip-extended-insert ';
        }
        if ($input->getOption('add-routines')) {
            $dumpOptions .= '--routines ';
        }
        if ($input->getOption('xml')) {
            $dumpOptions .= '--xml ';
        }
        if ($input->getOption('hex-blob')) {
            $dumpOptions .= '--hex-blob ';
        }
        $execs = array();
        $ignore = '';
        foreach (array_merge($excludeTables, $stripTables) as $tableName) {
            $ignore .= '--ignore-table=' . $this->dbSettings['dbname'] . '.' . $tableName . ' ';
        }
        $mysqlClientToolConnectionString = $dbHelper->getMysqlClientToolConnectionString();
        if (count($stripTables) > 0) {
            // dump structure for strip-tables
            $exec = 'mysqldump ' . $dumpOptions . '--no-data ' . $mysqlClientToolConnectionString;
            $exec .= ' ' . implode(' ', $stripTables);
            $exec .= $this->postDumpPipeCommands();
            $exec = $compressor->getCompressingCommand($exec);
            if (!$input->getOption('stdout')) {
                $exec .= ' > ' . escapeshellarg($fileName);
            }
            $execs[] = $exec;
        }
        // dump data for all other tables
        $exec = 'mysqldump ' . $dumpOptions . $mysqlClientToolConnectionString . ' ' . $ignore;
        $exec .= $this->postDumpPipeCommands();
        $exec = $compressor->getCompressingCommand($exec);
        if (!$input->getOption('stdout')) {
            $exec .= (count($stripTables) > 0 ? ' >> ' : ' > ') . escapeshellarg($fileName);
        }
        $execs[] = $exec;
        $this->runExecs($execs, $fileName, $input, $output);
    }