write() public method

public write ( $messages, $newline = true )
示例#1
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $timezone = $input->getOption('timezone');
     $drafts = $input->getOption('drafts');
     $safe = $input->getOption('safe');
     $env = $input->getOption('env');
     $io = new ConsoleIO($input, $output, $this->getHelperSet());
     $app = new SpressCLI($io);
     $config = $app['spress.config'];
     $envDefault = $config->getEnvironmentName();
     $io->write('<comment>Starting...</comment>');
     $io->write(sprintf('<comment>Environment: %s.</comment>', $env ? $env : $envDefault));
     if ($drafts) {
         $io->write('<comment>Posts drafts activated.</comment>');
     }
     if ($safe) {
         $io->write('<comment>Plugins disabled.</comment>');
     }
     $resultData = $app->parse($input->getOption('source'), $env, $timezone, $drafts, $safe);
     $io->write(sprintf('Total posts: %d', $resultData['total_post']));
     $io->write(sprintf('Processed posts: %d', $resultData['processed_post']));
     $io->write(sprintf('Drafts post: %d', $resultData['drafts_post']));
     $io->write(sprintf('Total pages: %d', $resultData['total_pages']));
     $io->write(sprintf('Processed pages: %d', $resultData['processed_pages']));
     $io->write(sprintf('Other resources: %d', $resultData['other_resources']));
 }
示例#2
0
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new ConsoleIO($input, $output, $this->getHelperSet());
     $io->write(['', $this->getSpressAsciiArt(), '', 'Hola user and welcome!', '', 'More information at <comment>http://spress.yosymfony.com</comment> or <comment>@spress_cms</comment> on Twitter', '']);
     if ($this->isUnstableVersion()) {
         $io->write(['', '<error>Warning: this is a unstable version.</error>', ``]);
     }
     $command = $this->getApplication()->find('list');
     $arguments = new ArrayInput(['command' => 'list']);
     $command->run($arguments, $output);
 }
示例#3
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $path = $input->getArgument('path');
     $template = $input->getArgument('template');
     $force = $input->getOption('force');
     $completeScaffold = $input->getOption('all');
     $io = new ConsoleIO($input, $output, $this->getHelperSet());
     $app = new SpressCLI($io);
     $operation = new NewSite($app['spress.paths']['templates']);
     $operation->newSite($path, $template, $force, $completeScaffold);
     $io->write(sprintf('<comment>New site created at %s.</comment>', $path));
     if ('./' == $path) {
         $io->write('<comment>Edit composer.json file to add your theme data and plugins required.</comment>');
     } else {
         $io->write(sprintf('<comment>Go to %s folder and edit composer.json file to add your theme data and plugins required.</comment>', $path));
     }
 }
示例#4
0
 public function testWrite()
 {
     $inputMock = $this->getMockBuilder('Symfony\\Component\\Console\\Input\\InputInterface')->getMock();
     $outputMock = $this->getMockBuilder('Symfony\\Component\\Console\\Output\\OutputInterface')->getMock();
     $outputMock->expects($this->once())->method('write')->with($this->equalTo('Hi IO API'));
     $helperMock = $this->getMockBuilder('Symfony\\Component\\Console\\Helper\\HelperSet')->getMock();
     $consoleIO = new ConsoleIO($inputMock, $outputMock, $helperMock);
     $consoleIO->write('Hi IO API', false);
 }
示例#5
0
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new ConsoleIO($input, $output);
     if ($this->isInstalledAsPhar() === false) {
         $io->error('Self-update is available only for PHAR version');
         return 1;
     }
     $manifest = $this->getManifestFile();
     $remoteVersion = $manifest['version'];
     $localVersion = $this->getApplication()->getVersion();
     if ($localVersion === $remoteVersion) {
         $io->success('Spress is already up to date');
         return;
     }
     $remoteFilename = $manifest['url'];
     $localFilename = $_SERVER['argv'][0];
     $tempFilename = basename($localFilename, '.phar') . '-tmp.phar';
     $io->newLine();
     $io->write('Downloading Spress...');
     $io->newLine();
     $this->downloadRemoteFilename($remoteFilename);
     try {
         copy($remoteFilename, $tempFilename);
         chmod($tempFilename, 0777 & ~umask());
         $phar = new \Phar($tempFilename);
         unset($phar);
         if (@rename($tempFilename, $localFilename) !== true) {
             $io->error(sprintf('Cannot rename "%s" to "%s" probably because permission denied.', $tempFilename, $localFilename));
             return 1;
         }
         $io->success(sprintf('Spress updated from %s to %s.', $localVersion, $remoteVersion));
         if (isset($manifest['changelog_url']) === true) {
             $io->write(sprintf('<comment>Go to <info>%s</info> for more details.</comment>', $manifest['changelog_url']));
         }
     } catch (\Exception $e) {
         if ($e instanceof \UnexpectedValueException === false && $e instanceof \PharException === false) {
             throw $e;
         }
         unlink($tempFilename);
         $io->error([sprintf('The download is corrupt (%s).', $e->getMessage()), 'Please re-run the self-update command to try again.']);
         return 1;
     }
 }
示例#6
0
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new ConsoleIO($input, $output, $this->getHelperSet());
     if ($this->isInstalledAsPhar() === false) {
         $io->write('<error>Self-update is available only for PHAR version.</error>');
         return 1;
     }
     $manifest = $this->getManifestFile();
     $remoteVersion = $manifest['version'];
     $localVersion = $this->getApplication()->getVersion();
     if ($localVersion === $remoteVersion) {
         $io->write('<info>Spress is already up to date.</info>');
         return;
     }
     $remoteFilename = $manifest['url'];
     $localFilename = $_SERVER['argv'][0];
     $tempFilename = basename($localFilename, '.phar') . '-tmp.phar';
     $this->downloadRemoteFilename($remoteFilename);
     try {
         copy($remoteFilename, $tempFilename);
         chmod($tempFilename, 0777 & ~umask());
         $phar = new \Phar($tempFilename);
         unset($phar);
         rename($tempFilename, $localFilename);
         $io->write(sprintf('<success>Spress updated from %s to %s.</success>', $localVersion, $remoteVersion));
         if (isset($manifest['changelog_url']) === true) {
             $io->write(sprintf('<info>Go to %s for more details.</info>', $manifest['changelog_url']));
         }
     } catch (\Exception $e) {
         if ($e instanceof \UnexpectedValueException === false && $e instanceof \PharException === false) {
             throw $e;
         }
         unlink($tempFilename);
         $io->write(sprintf('<error>The download is corrupt (%s).</error>', $e->getMessage()));
         $io->write('<error>Please re-run the self-update command to try again.</error>');
         return 1;
     }
 }
示例#7
0
 /**
  * Writes the result of a parsing a site.
  *
  * @param \Yosymfony\Spress\IO\ConsoleIO                    $io
  * @param \Yosymfony\Spress\Core\DataSource\ItemInterface[] $items
  */
 protected function resultMessage(ConsoleIO $io, array $items)
 {
     $io->write(sprintf('<info>Total items: %d.</info>', count($items)));
 }
示例#8
0
 /**
  * Write the result of rebuilding a site.
  *
  * @param Yosymfony\Spress\IO\ConsoleIO $io
  * @param array                         $newResources
  * @param array                         $updatedResources
  * @param array                         $deletedResources
  */
 protected function rebuildingSiteMessage(ConsoleIO $io, array $newResources, array $updatedResources, array $deletedResources)
 {
     $io->write(sprintf('<comment>Rebuilding site... (%s new, %s updated and %s deleted resources)</comment>', count($newResources), count($updatedResources), count($deletedResources)));
     $io->newLine();
 }
示例#9
0
 public function testWrite()
 {
     $this->command->setCode(function (InputInterface $input, OutputInterface $output) use(&$isDecorated) {
         $io = new ConsoleIO($input, $output);
         $io->write('Hi IO API');
     });
     $this->tester->execute([], ['interactive' => false, 'decorated' => false]);
     $this->assertEquals("Hi IO API\n", $this->tester->getDisplay(true));
 }