updateOutput

Add ModelManager output lines to the CLI output.

@access protected
@param  OutputInterface  $output
@param  array            $lines
@return RelationAwareCommand
332617
protected function updateOutput(OutputInterface $output, array $lines = [])
    {
        foreach ($lines as $line) {
            $status = $line["status"] == "ok" ? "<fg=green>✓</fg=green>" : "<fg=red>✗</fg=red>";

            switch ($line['operation']) {
            case "creating":
                $operation = sprintf("<fg=green>%s</fg=green>", ucwords($line['operation']));
                break;
            case "overwriting":
                $operation = sprintf("<fg=cyan>%s</fg=cyan>", ucwords($line['operation']));
                break;
            case "deleting":
                $operation = sprintf("<fg=red>%s</fg=red>", ucwords($line['operation']));
                break;
            default:
                $operation = ucwords($line['operation']);
            }

            $output->writeln(
                sprintf(
                    " %s  %s file <fg=yellow>'%s'</fg=yellow>.",
                    $status,
                    $operation,
                    $line['file']
                )
            );
        }

        return $this;
    }
1261486
protected function newProgressBar(OutputInterface $output)
    {
        // If the console output is not decorated (i.e. it does not support
        // ANSI), use NullOutput to suppress the progress bar entirely.
        $progressOutput = $output->isDecorated() ? $output : new NullOutput();

        return new ProgressBar($progressOutput);
    }
965643
protected function addOutputFormatterStyles(OutputInterface $output)
    {
        foreach ($this->getOutputFormatterStyles() as $name => $style) {
            $output->getFormatter()->setStyle($name, $style);
        }
    }
489334
protected function configureFormatter(OutputInterface $output)
    {
        $formatter = $output->getFormatter();
        $formatter->setStyle('header', new OutputFormatterStyle('green'));
        $formatter->setStyle('failheader', new OutputFormatterStyle('red'));
        $formatter->setStyle('body', new OutputFormatterStyle('white'));
    }
224271
protected function execute(InputInterface $input, OutputInterface $output): void
    {
        try {
            $this->checkOptions($input);
            $entityManager = $this->getEntityManager();

            /**
             * @var ClassMetadata[] $metadatas
             */
            $metadatas = $entityManager->getMetadataFactory()->getAllMetadata();
            $metadatas = MetadataFilter::filter($metadatas, $input->getOption('filter'));
            $this->relationsGenerator
                ->setPathToProjectRoot($input->getOption(AbstractCommand::OPT_PROJECT_ROOT_PATH))
                ->setProjectRootNamespace($input->getOption(AbstractCommand::OPT_PROJECT_ROOT_NAMESPACE));

            $output->writeln(
                '<comment>Starting relations generation for '
                . implode(
                    ' ',
                    $input->getOption('filter')
                ) . '</comment>'
            );
            $progress = new ProgressBar($output, count($metadatas));
            $progress::setFormatDefinition('custom', ' %current%/%max% -- %message%');
            $progress->start();
            foreach ($metadatas as $metadata) {
                $progress->setMessage('<comment>Generating for ' . $metadata->name . '</comment>');
                $this->relationsGenerator->generateRelationCodeForEntity($metadata->name);
                $progress->setMessage('<info>done</info>');
                $progress->advance();
            }
            $progress->finish();
            $output->writeln('completed');
        } catch (\Exception $e) {
            throw new DoctrineStaticMetaException(
                'Exception in ' . __METHOD__ . ': ' . $e->getMessage(),
                $e->getCode(),
                $e
            );
        }
    }
488791
public function write(OutputInterface $output): void
    {
        $outputPath = $this->outputDir.'/'.$output->permalink()->relativeFilePath();
        if ($output->hasFileReference()) {
            $this->filesystem->copy($output->file(), $outputPath, true);
        } else {
            $this->filesystem->mkdir(dirname($outputPath));
            $this->filesystem->dumpFile($outputPath, $output->formattedContent());
        }
    }
93182
private function dumpAssetic(OutputInterface $output)
    {
        $command = $this->getApplication()->find('assetic:dump');

        $arguments = [
            'command' => 'assetic:dump',
            '--env' => 'prod',
            '--no-debug' => true,
        ];

        $input = new ArrayInput($arguments);

        return $command->run($input, $output);
    }
588559
protected function createConsoleLogger(OutputInterface $output)
    {
        return new ConsoleLogger(
            $output,
            [
                // aways output notice, info and debug
                LogLevel::NOTICE => OutputInterface::VERBOSITY_NORMAL,
                LogLevel::INFO   => OutputInterface::VERBOSITY_NORMAL,
                LogLevel::DEBUG  => OutputInterface::VERBOSITY_NORMAL
            ],
            [
                // redirect messages to stderr
                LogLevel::WARNING => ConsoleLogger::INFO,
                LogLevel::NOTICE  => ConsoleLogger::ERROR,
                LogLevel::INFO    => ConsoleLogger::ERROR,
                LogLevel::DEBUG   => ConsoleLogger::ERROR
            ]
        );
    }
370830
public static function createFromOutputLines(Repository $repository, array $outputLines)
    {
        $tree = new self($repository);
        $tree->parseOutputLines($outputLines);

        return $tree;
    }
1193953
protected function processQueue(OutputInterface &$output)
    {
        $manager = $this->getManager();
        $queue = $this->getQueue();
        $path = array();
        $records = $queue->getPending();

        $output->writeln('<info>'.count($records).' records found.</info>');
        if (count($records) == 0) {
            $output->writeln('<error>No records found to process!</error>');
        } else {
            $output->writeln('<info>Processing '.count($records).' records</info>');
        }

        foreach ($records as $record) {
            $manager->runFilters($record['data'], $path);
            $queue->markProcessed($record['_id']);
        }

        $reports = $manager->getReports();
        foreach ($reports as $index => $report) {
            $reports[$index] = $report->toArray(true);
        }
        return $reports;
    }
1116572
protected function execute(InputInterface $input, OutputInterface $output)
    {
        $em = $this->entityManager;
        $force = $input->getOption('force');
        $fixDepth = $input->getOption('fix-depth');

        $repo = $this->accountRepository;
        $verify = $repo->verify();

        $success = false;

        // fix nested tree
        if (true !== $verify) {
            $output->writeln(sprintf('<comment>%s errors were found.</comment>', count($verify)));

            if ($force) {
                $repo->recover();
                $em->flush();
                $success = true;
            }
        } else {
            $output->writeln('<info>Your tree is fine. No errors found.<info>');
        }

        // fix depths if -depth is defined
        if ($fixDepth) {
            // fix nodes without parents
            $numberParentLess = $this->findNodesWithoutParents();
            if ($numberParentLess > 0) {
                $output->writeln(
                    sprintf('<comment>%s nodes without parent were found.</comment>', $numberParentLess)
                );
                if ($force) {
                    $this->fixNodesWithoutParents();
                    $success = true;
                    $em->flush();
                }
            } else {
                $output->writeln('<info>No wrong depth gaps detected<info>');
            }

            // fix depth gaps
            $numberWrongDepth = $this->findInitialWrongDepthGap();
            if ($numberWrongDepth > 0) {
                $output->writeln(sprintf('<comment>%s wrong depths were found.</comment>', $numberWrongDepth));
                if ($force) {
                    // update depths
                    $affected = 1;
                    while ($affected > 0) {
                        $affected = $this->fixWrongDepthGap();
                    }
                    $success = true;
                    $em->flush();
                }
            } else {
                $output->writeln('<info>No nodes without parents detected<info>');
            }
        }

        if (!$force) {
            $output->writeln(sprintf('Call this command with <info>--force</info> option to perform recovery.'));
        }

        if (true === $success) {
            $output->writeln('<info>Recovery complete<info>');
        }
    }
1184158
public function initializeInstallOutput(OutputInterface $output)
    {
        $progressBar = null;
        if ($output->getVerbosity() < OutputInterface::VERBOSITY_VERY_VERBOSE) {
            // Low verbosity, use progress bar.
            $progressBar = new ProgressBar($output);
            $progressBar->setFormat(' %current%/%max% [%bar%] %percent:3s%% %elapsed:6s% [%message%]');
        }

        return new InstallOutput(new ConsoleLogger($output), $progressBar);
    }
571362
private function createDB(OutputInterface $output)
    {
        $output->write('> Loading the schema of the DB', true);

        $arguments = [
            'command' => 'doctrine:schema:update',
            '--force' => true,
        ];

        $input = new ArrayInput($arguments);

        return $this->getApplication()->run($input);
    }
1302758
protected function setOutput(Connection $connection)
	{
		$output = php_sapi_name() == 'cli' ? new ConsoleOutput : new NullOutput;

		$connection->setOutput($output);
	}
141113
public function setOutput(\Symfony\Component\Console\Output\OutputInterface $output)
    {
        $this->output = $output;
    }
1120516
protected function executeCommand(Command $command, array $arguments, OutputInterface $output)
    {
        $output = clone $output;
        if ($output->getVerbosity() >= OutputInterface::VERBOSITY_VERBOSE) {
            $output->setVerbosity($output->getVerbosity());
        } else {
            $output->setVerbosity(OutputInterface::VERBOSITY_QUIET);
        }

        return $command->run(new ArrayInput($arguments), $output);
    }
924523
private function createOperationOutput(array &$output, OperationInterface $operation)
    {
        $operationHandler = $this->getOperationHandler($operation);

        if (!$operationHandler) {
            return;
        }

        $output[] = '';

        $urlGenerator = $this->getUrlGenerator(
            $operationHandler->extractSourceUrl($operation)
        );

        $output = array_merge(
            $output,
            $operationHandler->getOutput($operation, $urlGenerator)
        );
    }