public function testConstructor() { $output = new NullOutput(); $output->write('foo'); $this->assertTrue(true, '->write() does nothing'); // FIXME }
public function testVerbosity() { $output = new NullOutput(); $this->assertSame(OutputInterface::VERBOSITY_QUIET, $output->getVerbosity(), '->getVerbosity() returns VERBOSITY_QUIET for NullOutput by default'); $output->setVerbosity(OutputInterface::VERBOSITY_VERBOSE); $this->assertSame(OutputInterface::VERBOSITY_QUIET, $output->getVerbosity(), '->getVerbosity() always returns VERBOSITY_QUIET for NullOutput'); }
public function execute(InputInterface $input, OutputInterface $output) { $consoleOutput = $output; $reports = $input->getOption('report'); $dump = $input->getOption('dump'); $parametersJson = $input->getOption('parameters'); $iterations = $input->getOption('iterations'); $revs = $input->getOption('revs'); $configPath = $input->getOption('config'); $subjects = $input->getOption('subject'); $groups = $input->getOption('group'); $dumpfile = $input->getOption('dump-file'); $progressLoggerName = $input->getOption('progress') ?: $this->progressLoggerName; $path = $input->getArgument('path') ?: $this->benchPath; $reportNames = $this->reportManager->processCliReports($reports); if (null === $path) { throw new \InvalidArgumentException('You must either specify or configure a path where your benchmarks can be found.'); } $parameters = array(); if ($parametersJson) { $parameters = json_decode($parametersJson, true); if (null === $parameters) { throw new \InvalidArgumentException(sprintf('Could not decode parameters JSON string: "%s"', $parametersJson)); } } if ($dump) { $consoleOutput = new NullOutput(); } $consoleOutput->writeln('PhpBench ' . PhpBench::VERSION . '. Running benchmarks.'); if ($this->configPath) { $consoleOutput->writeln(sprintf('Using configuration file: %s', $this->configPath)); } $progressLogger = $this->loggerRegistry->getProgressLogger($progressLoggerName); $progressLogger->setOutput($consoleOutput); $consoleOutput->writeln(''); $startTime = microtime(true); $suiteResult = $this->executeBenchmarks($path, $subjects, $groups, $parameters, $iterations, $revs, $configPath, $progressLogger); $consoleOutput->writeln(''); $consoleOutput->writeln(sprintf('<greenbg>Done (%s subjects, %s iterations) in %ss</greenbg>', $suiteResult->getNbSubjects(), $suiteResult->getNbIterations(), number_format(microtime(true) - $startTime, 2))); if ($dumpfile) { $xml = $suiteResult->saveXml(); file_put_contents($dumpfile, $xml); $consoleOutput->writeln('Dumped result to ' . $dumpfile); } $consoleOutput->writeln(''); if ($dump) { $xml = $suiteResult->saveXml(); $output->write($xml); } elseif ($reportNames) { $this->reportManager->generateReports($consoleOutput, $suiteResult, $reportNames); } }
/** * Returns a instance of composer * * @param InputInterface $input * @param OutputInterface $output * @param unknown_type $pathToComposer */ public static function getComposer(InputInterface $input = null, OutputInterface $output = null, $pathToComposer = null, $required = true, $localConfig = null) { if ($input == null) { $input = new ArrayInput(array()); } if ($output == null) { $output = new NullOutput(); } if (null === self::$composer) { self::checkComposer($pathToComposer); $output->write("Initializing composer ... "); try { self::$composer = self::createComposer($input, $output, $localConfig); } catch (\InvalidArgumentException $e) { if ($required) { throw $e; } } $output->writeln("<info>done</info>."); } return self::$composer; }
public function writeln($messages, $type = self::OUTPUT_NORMAL) { $this->outputs[] = $messages; parent::writeln($messages, $type); // TODO: Change the autogenerated stub }
protected function execute(InputInterface $input, OutputInterface $output) { if (true === $input->getOption('quiet')) { $output = new NullOutput(); } $manager = new DisconnectedMetadataFactory($this->getContainer()->get('doctrine')); $configFilePath = $this->getConfigFilePath($manager, $input); $entities = []; try { $bundle = $this->getApplication()->getKernel()->getBundle($input->getArgument('entityOrBundle')); $bundleName = $bundle->getName(); $bundleMetadata = $manager->getBundleMetadata($bundle); foreach ($bundleMetadata->getMetadata() as $metadata) { $entities[] = $metadata->getName(); } } catch (\InvalidArgumentException $e) { try { $model = $this->getContainer()->get("model_factory")->getModel($input->getArgument('entityOrBundle')); $metadata = $model->getMetadata(); $bundleName = str_replace('\\', '', str_replace('\\Entity', null, $metadata->namespace)); $entities[] = $metadata->getName(); } catch (\Exception $e) { $output->writeln("<error>Element \"" . $input->getArgument('entityOrBundle') . "\" not exist.</error>"); exit; } } $withConfigServices = true === $input->getOption('withConfigServices'); $withGridServices = true === $input->getOption('withGridServices'); $withFormTypeServices = true === $input->getOption('withFormTypeServices'); $withFormTypes = true === $input->getOption('withFormTypes'); $withGridConfig = true === $input->getOption('withGridConfig'); $withTranslation = true === $input->getOption('withTranslation'); $withReadElementTwig = true === $input->getOption('withReadElementTwig'); $withUpdateElementTwig = true === $input->getOption('withUpdateElementTwig'); $withViewElementTwig = true === $input->getOption('withViewElementTwig'); $withCreateElementTwig = true === $input->getOption('withCreateElementTwig'); $withReadContainerTwig = true === $input->getOption('withReadContainerTwig'); $withCreateContainerTwig = true === $input->getOption('withCreateContainerTwig'); $withUpdateContainerTwig = true === $input->getOption('withUpdateContainerTwig'); $withViewContainerTwig = true === $input->getOption('withViewContainerTwig'); $withGridContainerTwig = true === $input->getOption('withGridContainerTwig'); $withListServices = true === $input->getOption('withListServices'); $withViewServices = true === $input->getOption('withViewServices'); $withViewConfig = true === $input->getOption('withViewConfig'); $withListConfig = true === $input->getOption('withListConfig'); $withListContainerTwig = true === $input->getOption('withListContainerTwig'); $withListElementTwig = true === $input->getOption('withListElementTwig'); $withAll = true === $input->getOption('withAll'); foreach ($entities as $entity) { $output->writeln(sprintf('Entity: "<info>%s</info>"', $entity)); //services if ($withConfigServices || $withAll) { $output->writeln('Generate grid services.'); $command = $this->getApplication()->find('prototype:generate:services'); $arguments = array('configBundle' => $input->getArgument('configBundle'), 'applicationName' => $input->getArgument('applicationName'), 'rootSpace' => $input->getArgument('rootFolder'), 'entity' => $entity, 'tag' => 'prototype.config', 'route' => 'core_prototype_', 'parentEntity' => '', '--withAssociated' => null); $inputCommand = new ArrayInput($arguments); $returnCode = $command->run($inputCommand, $output); } if ($withGridServices || $withAll) { $output->writeln('Generate grid services.'); $command = $this->getApplication()->find('prototype:generate:services'); $arguments = array('configBundle' => $input->getArgument('configBundle'), 'applicationName' => $input->getArgument('applicationName'), 'rootSpace' => $input->getArgument('rootFolder'), 'entity' => $entity, 'tag' => 'prototype.gridconfig', 'route' => 'core_prototype_', 'parentEntity' => '', '--withAssociated' => null); $inputCommand = new ArrayInput($arguments); $returnCode = $command->run($inputCommand, $output); } if ($withListServices || $withAll) { $output->writeln('Generate grid services.'); $command = $this->getApplication()->find('prototype:generate:services'); $arguments = array('configBundle' => $input->getArgument('configBundle'), 'applicationName' => $input->getArgument('applicationName'), 'rootSpace' => $input->getArgument('rootFolder'), 'entity' => $entity, 'tag' => 'prototype.listconfig', 'route' => 'core_prototype_', 'parentEntity' => '', '--withAssociated' => null); $inputCommand = new ArrayInput($arguments); $returnCode = $command->run($inputCommand, $output); } if ($withViewServices || $withAll) { $output->writeln('Generate grid services.'); $command = $this->getApplication()->find('prototype:generate:services'); $arguments = array('configBundle' => $input->getArgument('configBundle'), 'applicationName' => $input->getArgument('applicationName'), 'rootSpace' => $input->getArgument('rootFolder'), 'entity' => $entity, 'tag' => 'prototype.viewconfig', 'route' => 'core_prototype_', 'parentEntity' => '', '--withAssociated' => null); $inputCommand = new ArrayInput($arguments); $returnCode = $command->run($inputCommand, $output); } if ($withFormTypeServices || $withAll) { $output->writeln('Generate formtype services.'); $command = $this->getApplication()->find('prototype:generate:services'); $arguments = array('configBundle' => $input->getArgument('configBundle'), 'applicationName' => $input->getArgument('applicationName'), 'rootSpace' => $input->getArgument('rootFolder'), 'entity' => $entity, 'tag' => 'prototype.formtype', 'route' => 'core_prototype_', 'parentEntity' => '', '--withAssociated' => null); $inputCommand = new ArrayInput($arguments); $returnCode = $command->run($inputCommand, $output); } //formtypes if ($withFormTypes || $withAll) { $output->writeln('Generate form types.'); $command = $this->getApplication()->find('prototype:generate:formtype'); $pathArr = explode('\\', $entity); $path = array_pop($pathArr); $arguments = array('configBundle' => $input->getArgument('configBundle'), 'entity' => $entity, 'rootFolder' => $input->getArgument('rootFolder'), 'path' => $path, '--withAssociated' => null); $inputCommand = new ArrayInput($arguments); $returnCode = $command->run($inputCommand, $output); } if ($withGridConfig || $withAll) { $output->writeln(sprintf('Generate Gridconfig file for <info>%s</info>', $entity)); $command = $this->getApplication()->find('datagrid:generate:grid:config'); $pathArr = explode('\\', $entity); $path = array_pop($pathArr); $arguments = array('configBundle' => $input->getArgument('configBundle'), 'entity' => $entity, 'rootFolder' => $input->getArgument('rootFolder'), 'path' => $path, '--associated' => null); $inputCommand = new ArrayInput($arguments); $returnCode = $command->run($inputCommand, $output); } if ($withListConfig || $withAll) { $output->writeln(sprintf('Generate Listconfig file for <info>%s</info>', $entity)); $command = $this->getApplication()->find('prototype:generate:listconfig'); $pathArr = explode('\\', $entity); $path = array_pop($pathArr); $arguments = array('configBundle' => $input->getArgument('configBundle'), 'entity' => $entity, 'rootFolder' => $input->getArgument('rootFolder'), 'path' => $path, '--associated' => null); $inputCommand = new ArrayInput($arguments); $returnCode = $command->run($inputCommand, $output); } if ($withViewConfig || $withAll) { $output->writeln(sprintf('Generate Viewconfig file for <info>%s</info>', $entity)); $command = $this->getApplication()->find('prototype:generate:viewconfig'); $pathArr = explode('\\', $entity); $path = array_pop($pathArr); $arguments = array('configBundle' => $input->getArgument('configBundle'), 'entity' => $entity, 'rootFolder' => $input->getArgument('rootFolder'), 'path' => $path, '--associated' => null); $inputCommand = new ArrayInput($arguments); $returnCode = $command->run($inputCommand, $output); } //twigs if ($withViewElementTwig || $withAll) { $output->writeln(sprintf('Generate view element for <info>%s</info>', $entity)); $command = $this->getApplication()->find('prototype:generate:twig:element:view'); $arguments = array('configBundle' => $input->getArgument('configBundle'), 'entity' => $entity, 'rootFolder' => $input->getArgument('rootFolder'), '--withAssociated' => null); $inputCommand = new ArrayInput($arguments); $returnCode = $command->run($inputCommand, $output); } if ($withReadElementTwig || $withAll) { $output->writeln(sprintf('Generate read element for <info>%s</info>', $entity)); $command = $this->getApplication()->find('prototype:generate:twig:element:read'); $arguments = array('configBundle' => $input->getArgument('configBundle'), 'entity' => $entity, 'rootFolder' => $input->getArgument('rootFolder'), '--withAssociated' => null); $inputCommand = new ArrayInput($arguments); $returnCode = $command->run($inputCommand, $output); } if ($withUpdateElementTwig || $withAll) { $output->writeln(sprintf('Generate update element for <info>%s</info>', $entity)); $command = $this->getApplication()->find('prototype:generate:twig:element:update'); $arguments = array('configBundle' => $input->getArgument('configBundle'), 'entity' => $entity, 'rootFolder' => $input->getArgument('rootFolder'), '--withAssociated' => null); $inputCommand = new ArrayInput($arguments); $returnCode = $command->run($inputCommand, $output); } if ($withCreateElementTwig || $withAll) { $output->writeln(sprintf('Generate create element for <info>%s</info>', $entity)); $command = $this->getApplication()->find('prototype:generate:twig:element:create'); $arguments = array('configBundle' => $input->getArgument('configBundle'), 'entity' => $entity, 'rootFolder' => $input->getArgument('rootFolder'), '--withAssociated' => null); $inputCommand = new ArrayInput($arguments); $returnCode = $command->run($inputCommand, $output); } if ($withListElementTwig || $withAll) { $output->writeln(sprintf('Generate list element for <info>%s</info>', $entity)); $command = $this->getApplication()->find('prototype:generate:twig:element:list'); $arguments = array('configBundle' => $input->getArgument('configBundle'), 'entity' => $entity, 'rootFolder' => $input->getArgument('rootFolder'), '--withAssociated' => null); $inputCommand = new ArrayInput($arguments); $returnCode = $command->run($inputCommand, $output); } if ($withReadContainerTwig || $withAll) { $output->writeln(sprintf('Generate read container for <info>%s</info>', $entity)); $command = $this->getApplication()->find('prototype:generate:twig:container:read'); $arguments = array('configBundle' => $input->getArgument('configBundle'), 'entity' => $entity, 'rootFolder' => $input->getArgument('rootFolder')); $inputCommand = new ArrayInput($arguments); $returnCode = $command->run($inputCommand, $output); } if ($withCreateContainerTwig || $withAll) { $output->writeln(sprintf('Generate create container for <info>%s</info>', $entity)); $command = $this->getApplication()->find('prototype:generate:twig:container:create'); $arguments = array('configBundle' => $input->getArgument('configBundle'), 'entity' => $entity, 'rootFolder' => $input->getArgument('rootFolder')); $inputCommand = new ArrayInput($arguments); $returnCode = $command->run($inputCommand, $output); } if ($withUpdateContainerTwig || $withAll) { $output->writeln(sprintf('Generate update container for <info>%s</info>', $entity)); $command = $this->getApplication()->find('prototype:generate:twig:container:update'); $arguments = array('configBundle' => $input->getArgument('configBundle'), 'entity' => $entity, 'rootFolder' => $input->getArgument('rootFolder')); $inputCommand = new ArrayInput($arguments); $returnCode = $command->run($inputCommand, $output); } if ($withViewContainerTwig || $withAll) { $output->writeln(sprintf('Generate view container for <info>%s</info>', $entity)); $command = $this->getApplication()->find('prototype:generate:twig:container:view'); $arguments = array('configBundle' => $input->getArgument('configBundle'), 'entity' => $entity, 'rootFolder' => $input->getArgument('rootFolder')); $inputCommand = new ArrayInput($arguments); $returnCode = $command->run($inputCommand, $output); } if ($withGridContainerTwig || $withAll) { $output->writeln(sprintf('Generate grid container for <info>%s</info>', $entity)); $command = $this->getApplication()->find('prototype:generate:twig:container:grid'); $arguments = array('configBundle' => $input->getArgument('configBundle'), 'entity' => $entity, 'rootFolder' => $input->getArgument('rootFolder')); $inputCommand = new ArrayInput($arguments); $returnCode = $command->run($inputCommand, $output); } if ($withListContainerTwig || $withAll) { $output->writeln(sprintf('Generate list container for <info>%s</info>', $entity)); $command = $this->getApplication()->find('prototype:generate:twig:container:list'); $arguments = array('configBundle' => $input->getArgument('configBundle'), 'entity' => $entity, 'rootFolder' => $input->getArgument('rootFolder')); $inputCommand = new ArrayInput($arguments); $returnCode = $command->run($inputCommand, $output); } //translation for bundle + if ($withTranslation || $withAll) { $output->writeln(sprintf('Generate translation file for <info>%s</info>', $entity)); $command = $this->getApplication()->find('prototype:generate:translation'); //for polish $arguments = array('configBundle' => $input->getArgument('configBundle'), 'entityOrBundle' => $entity, 'shortLanguage' => 'pl'); $inputCommand = new ArrayInput($arguments); $returnCode = $command->run($inputCommand, $output); //for english $arguments = array('configBundle' => $input->getArgument('configBundle'), 'entityOrBundle' => $entity, 'shortLanguage' => 'en'); $inputCommand = new ArrayInput($arguments); $returnCode = $command->run($inputCommand, $output); } } }
/** * {@inheritdoc} */ public function getExportData($webspaceKey, $locale, $output = null, $format = '1.2.xliff', $uuid = null, $nodes = null, $ignoredNodes = null) { /** @var PageDocument[] $documents */ $documents = $this->getDocuments($webspaceKey, $locale, $uuid, $nodes, $ignoredNodes); /** @var PageDocument[] $loadedDocuments */ $documentData = []; if (null === $output) { $output = new NullOutput(); } $output->writeln('<info>Loading Data…</info>'); $progress = new ProgressBar($output, count($documents)); $progress->start(); foreach ($documents as $key => $document) { $contentData = $this->getContentData($document, $locale, $format); $extensionData = $this->getExtensionData($document, $format); $settingData = $this->getSettingData($document, $format); $documentData[] = ['uuid' => $document->getUuid(), 'locale' => $document->getLocale(), 'content' => $contentData, 'settings' => $settingData, 'extensions' => $extensionData]; $progress->advance(); } $progress->finish(); $output->writeln(['', '<info>Render Xliff…</info>']); return ['webspaceKey' => $webspaceKey, 'locale' => $locale, 'format' => $format, 'documents' => $documentData]; }