protected function execute(InputInterface $input, OutputInterface $output) { $rc = 0; try { if (!$input->getOption('force')) { if (!$input->isInteractive()) { throw new Exception("You have to specify the --force option in order to run this command"); } $confirmQuestion = new ConfirmationQuestion('Are you sure you want to update this concrete5 installation?'); if (!$this->getHelper('question')->ask($input, $output, $confirmQuestion)) { throw new Exception("Operation aborted."); } } $configuration = new \Concrete\Core\Updater\Migrations\Configuration(); $output = new ConsoleOutput(); $configuration->setOutputWriter(new OutputWriter(function ($message) use($output) { $output->writeln($message); })); Update::updateToCurrentVersion($configuration); } catch (Exception $x) { $output->writeln('<error>' . $x->getMessage() . '</error>'); $rc = 1; } return $rc; }
/** * @return OutputWriter */ public static function createConsoleOutput() { $output = new ConsoleOutput(); return new OutputWriter(function ($message) use($output) { $output->write($message, TRUE); }); }
/** * @param string $name application name * @param string $version application version * @SuppressWarnings(PHPMD.ExitExpression) */ public function __construct($name = 'UNKNOWN', $version = 'UNKNOWN') { $this->serviceManager = \Zend\Mvc\Application::init(require BP . '/setup/config/application.config.php')->getServiceManager(); $generationDirectoryAccess = new GenerationDirectoryAccess($this->serviceManager); if (!$generationDirectoryAccess->check()) { $output = new ConsoleOutput(); $output->writeln('<error>Command line user does not have read and write permissions on var/generation directory. Please' . ' address this issue before using Magento command line.</error>'); exit(0); } /** * Temporary workaround until the compiler is able to clear the generation directory * @todo remove after MAGETWO-44493 resolved */ if (class_exists(CompilerPreparation::class)) { $compilerPreparation = new CompilerPreparation($this->serviceManager, new ArgvInput(), new File()); $compilerPreparation->handleCompilerEnvironment(); } if ($version == 'UNKNOWN') { $directoryList = new DirectoryList(BP); $composerJsonFinder = new ComposerJsonFinder($directoryList); $productMetadata = new ProductMetadata($composerJsonFinder); $version = $productMetadata->getVersion(); } parent::__construct($name, $version); }
/** * Outputs specified text to the console window * You can specify arguments that will be passed to the text via sprintf * @see http://www.php.net/sprintf * * @param string $text Text to output * @param array $arguments Optional arguments to use for sprintf * @return void */ public function output($text, array $arguments = array()) { if ($arguments !== array()) { $text = vsprintf($text, $arguments); } $this->output->write($text); }
public function writeln($sprintf) { $arguments = func_get_args(); $arguments[0] .= PHP_EOL; $message = call_user_func_array("sprintf", $arguments); $this->laravelConsoleOutput->write($message); }
/** * @param $commands * @param \Symfony\Component\Console\Output\ConsoleOutput $output * * @return boolean */ function execute_commands($commands, $output) { foreach ($commands as $command) { list($command, $message, $allowFailure) = $command; $output->write(sprintf(' - %\'.-70s', $message)); $return = array(); if (is_callable($command)) { $success = $command($output); } else { $p = new \Symfony\Component\Process\Process($command); $p->setTimeout(null); $p->run(function ($type, $data) use(&$return) { $return[] = $data; }); $success = $p->isSuccessful(); } if (!$success && !$allowFailure) { $output->writeln('<error>KO</error>'); $output->writeln(sprintf('<error>Fail to run: %s</error>', is_callable($command) ? '[closure]' : $command)); foreach ($return as $data) { $output->write($data, false, OutputInterface::OUTPUT_RAW); } $output->writeln("If the error is coming from the sandbox,"); $output->writeln("please report the issue to https://github.com/sonata-project/sandbox/issues"); return false; } else { if (!$success) { $output->writeln("<info>!!</info>"); } else { $output->writeln("<info>OK</info>"); } } } return true; }
/** * Method overridden to add output customizations and use the output object * for application logging. */ public function run(InputInterface $input = null, OutputInterface $output = null) { if (null === $output) { $output = new ConsoleOutput(); $output->setFormatter(new OutputFormatter($output->isDecorated())); } return parent::run($input, $output); }
public function checkDependencies() { $output = new ConsoleOutput(); if (!extension_loaded('mbstring')) { $output->writeln("\n<error>Missing Dependency: Please install the Multibyte String Functions.</error>\n" . "More help: http://www.php.net/manual/en/mbstring.installation.php\n", $this->outputFormat); exit(1); } }
public function run(InputInterface $input = null, OutputInterface $output = null) { if (null === $output) { $output = new ConsoleOutput(); } $output->getFormatter()->getStyle('info')->setForeground('magenta'); $output->getFormatter()->getStyle('comment')->setForeground('cyan'); return parent::run($input, $output); }
private static function printMessage($s, $tag) { if (PHP_SAPI === 'cli') { $output = new ConsoleOutput(); $output->writeln('<' . $tag . '>' . $s . '</' . $tag . '>'); } else { error_log(strtoupper($tag) . ': ' . $s); } }
/** * Destroy a user that matches a test user name. * * @param $role * @return $this */ public function destroyTestUser($role) { $this->output->writeln("deleting test{$role}User..."); $users = \Drupal::entityQuery('user')->condition("name", "test{$role}User")->execute(); $users = User::loadMultiple($users); foreach ($users as $user) { $user->delete(); } return $this; }
/** * Execute the product template migration */ public function execute() { $productTemplates = $this->getProductTemplates(); if (empty($productTemplates)) { $this->output->writeln('<info>There is no product template to update<info>'); return; } $this->convert($productTemplates); $this->output->writeln('<info>Done !</info>'); }
/** * Prints a message to console * * @param $message * @param int $tabs * @param int $newLine */ public function output($message, $tabs = 1, $newLine = 1) { //Auto logs to File $this->log(strip_tags($message)); $this->consoleOutput->write(str_repeat("\t", $tabs)); $this->consoleOutput->write($message); // Writes Message to console $this->consoleOutput->write(str_repeat(PHP_EOL, $newLine)); // New Lines }
public static function postInstall(Event $event) { $vendor_dir = $event->getComposer()->getConfig()->get('vendor-dir'); //tinymce taalbestanden in lib dir plaatsen if (!file_exists($vendor_dir . "/tinymce/tinymce/jscripts/tiny_mce/langs/nl.js")) { $output = new output(); $output->writeln('<info>copying tinyMCE language files into ' . $vendor_dir . '/tinymce/tinymce/jscripts/tiny_mce</info>'); passthru("cp -af " . $vendor_dir . "/bugbyte/composereventhandler/lib/tinymce_lang_pack/* " . $vendor_dir . "/tinymce/tinymce/jscripts/tiny_mce"); } }
/** * @param $commands * @param \Symfony\Component\Console\Output\ConsoleOutput $output * @return void */ function execute_commands($commands, $output) { foreach ($commands as $command) { $output->writeln(sprintf('<info>Executing : </info> %s', $command)); $p = new \Symfony\Component\Process\Process($command); $exit = $p->run(function ($type, $data) use($output) { $output->write($data); }); $output->writeln(""); } }
protected function setUp() { $this->oldApplicationContext = ApplicationContext::getInstance(); $this->applicationContext = $this->createApplicationContext(); $this->applicationContext->setPlugin($this->getPlugin()); $this->applicationContext->setComponent('input', new ArgvInput()); $output = new ConsoleOutput(); $output->setDecorated(false); $this->applicationContext->setComponent('output', $output); ApplicationContext::setInstance($this->applicationContext); }
/** * Registers services on the given app. * * This method should only be used to configure services and parameters. * It should not get services. * * @param Application $app An Application instance */ public function register(Application $app) { $app['migrations.output_writer'] = new OutputWriter(function ($message) { $output = new ConsoleOutput(); $output->writeln($message); }); $app['migrations.directory'] = null; $app['migrations.name'] = 'Migrations'; $app['migrations.namespace'] = null; $app['migrations.table_name'] = 'migration_versions'; }
/** * install * * @return void */ public static function install() { $output = new ConsoleOutput(); $style = new OutputFormatterStyle('green'); $output->getFormatter()->setStyle('green', $style); $assets = array('resources/cache', 'resources/log', 'web/assets'); foreach ($assets as $asset) { self::createAndChmod($asset, 0777); $output->writeln(sprintf('<green>Generating "%s" asset dir</green>', $asset)); } exec('php console assetic:dump'); }
public function testShutdownToConsoleOutput() { ob_start(); $out = new ConsoleOutput(); $err = new StreamOutput(fopen('php://memory', 'w', false)); $out->setErrorOutput($err); $app = new Application('test', 'beta'); $app->configure(null, $out); Application::shutdownFunction($app); rewind($err->getStream()); $this->assertContains('exit()', stream_get_contents($err->getStream())); }
/** * {@inheritDoc} */ public function load(ObjectManager $manager) { /** @var KernelInterface $kernel */ $kernel = $this->container->get('kernel'); if (in_array($kernel->getEnvironment(), $this->getEnvironments())) { $this->doLoad($manager); } else { $ouput = new ConsoleOutput(); $msg = '...Not for ' . $kernel->getEnvironment() . ' environment'; $ouput->writeln(' <comment>></comment> <comment>' . $msg . '</comment>'); } }
/** * Runs the current application. * * @param InputInterface $input An InputInterface instance * @param OutputInterface $output An OutputInterface instance * * @return integer 0 if everything went fine, or an error code * * @throws \Exception on problems */ public function run(InputInterface $input = null, OutputInterface $output = null) { try { parent::run($input, $output); } catch (\Exception $e) { if (null === $output) { $output = new ConsoleOutput(); } $message = array($this->getLongVersion(), '', $e->getMessage(), ''); $output->writeln($message); } }
public function processFiles($title, array $files, $process) { $o = new ConsoleOutput(); $o->writeln('<info>' . $title . '</info>'); $p = new ProgressBar($o, count($files)); $p->start(); foreach ($files as $path) { $process($path); $p->advance(); } $p->finish(); $o->writeln(''); }
/** * Send an E-mail signup confirmation * @param mixin $user */ public function sendConfirmEmail($user) { Mail::send('emails.confirmation', ['user' => $user, 'confirmationLink' => url('/ulibier/activated?token=' . base64_encode(serialize($user)))], function ($m) use($user) { $m->from('*****@*****.**', 'Ulibi'); $m->to($user['email'], $user['firstname'] . ' ' . $user['lastname'])->subject('Ulibi sign-up confirmation'); }); $email = $user['email']; $output = new ConsoleOutput(); $output->writeln(<<<ENDDOC <info>Message sent to {$email} :)</info> ENDDOC ); }
/** * Outputs a string to the cli. If you send an array it will implode them * with a line break. * * @param string|array $text the text to output, or array of lines * @param bool $newline */ public static function write($text = '', $newline = false) { if (is_array($text)) { foreach ($text as $line) { CLI::write($line); } } else { if (PHP_SAPI == 'cli') { static::$output->write($text, $newline); } else { echo "<h4>{$text}</h4>"; } } }
/** * {@inheritdoc} */ public function index() { $style = new OutputFormatterStyle('red', 'yellow', array('bold', 'blink')); $output = new ConsoleOutput(); $output->getFormatter()->setStyle('fire', $style); $fileContents = $this->searchService->getFileContents(); foreach ($fileContents as $content) { $output->writeln('<info>Indexing File & Contents: </info><comment>' . $content['path'] . '</comment>'); /** * @var \Symfony\Component\Finder\SplFileInfo $file */ $this->createIndex($content['title'], $content['file_contents'], $content['path']); } }
/** * @inheritdoc */ public function terminate(ResultCollection $collection, ResultCollection $groupedResults) { $output = new ConsoleOutput(OutputInterface::VERBOSITY_NORMAL, true); $output->write(str_pad("\r", 80, " ")); $output->writeln(''); // score $score = $collection->getScore(); // if($score) { foreach ($score->all() as $name => $value) { $output->writeln(sprintf('%s %s', str_pad($name, 35, '.'), str_pad($value, 5, ' ', STR_PAD_LEFT) . ' / ' . Scoring::MAX)); } $output->writeln(''); // } }
/** * @param $data * @param null|int $flags */ public function dump($data, $flags = null) { if ($flags !== null) { if ($flags & self::NEWLINE_BEFORE) { $this->output->writeln(''); } } $this->cliDumper->dump($this->varCloner->cloneVar($data)); if ($flags !== null) { if ($flags & self::NEWLINE_AFTER) { $this->output->writeln(''); } } }
/** * Run the dotenv diff */ public static function run() { $output = new ConsoleOutput(); $formatter = new FormatterHelper(); $env = self::readFile('.env'); $envExample = self::readFile('.env.example'); // Check which variables are missing and which ones are extra $envKeys = array_keys($env); $envExampleKeys = array_keys($envExample); $missing = array_diff($envExampleKeys, $envKeys); $extra = array_diff($envKeys, $envExampleKeys); if (count($missing) > 0 || count($extra) > 0) { $output->writeln(''); $warning = $formatter->formatBlock('Warning: Your .env and .env.example files are not in sync.', 'bg=blue;fg=white', true); $output->writeln($warning); } if (count($missing) > 0) { $output->writeln("\n<comment>The following variables are missing from your .env file:<comment>"); foreach ($missing as $variable) { $output->writeln(sprintf('<info>%s=%s<info>', $variable, $envExample[$variable])); } } if (count($extra) > 0) { $output->writeln("\n<comment>The following variables are in your .env file but not in .env.example:<comment>"); foreach ($extra as $variable) { $output->writeln(sprintf('<info>%s=%s<info>', $variable, $env[$variable])); } } $output->writeln(''); }
/** * Load data fixtures with the passed EntityManager * * @param ObjectManager $manager */ public function load(ObjectManager $manager) { $tokenGenerator = $this->container->get('fos_user.util.token_generator'); $password = substr($tokenGenerator->generateToken(), 0, 8); $user1 = $this->createUser($manager, 'admin', $password, '*****@*****.**', $this->container->getParameter('kunstmaan_admin.default_admin_locale'), array('ROLE_SUPER_ADMIN'), array($manager->merge($this->getReference('superadmins-group'))), true, false); $manager->flush(); $output = new ConsoleOutput(); $output->writeln(array("<comment> > User 'admin' created with password '{$password}'</comment>")); $file = $this->container->get('kernel')->getRootDir() . '/config/config.yml'; $contents = file_get_contents($file); $contents = str_replace('-adminpwd-', $password, $contents); file_put_contents($file, $contents); $this->setReference('adminuser', $user1); }
public function doDownLoad($limit_array) { $output = new ConsoleOutput(); // $bar = new ProgressBar($output,count($limit_array)); // $bar->start(); // $bar->setBarWidth(100); $i = 0; $count = count($limit_array); // $bar->setFormat('debug'); foreach ($limit_array as $file => $data) { // $package = $this->repository_path."/packages/".$file.".json"; $versions = $this->repository_path . "/download/" . $file . ".json"; // $package = json_decode(file_get_contents($package),true); $download = json_decode(file_get_contents($download), true); if (!$download) { $i++; $output->writeln($i . '/' . $count . ' skip'); continue; // $bar->advance(); } $i++; $versions = array_values($download['package']['versions']); if (!isset($versions[0]['require'])) { $output->writeln($i . '/' . $count . ' skip'); continue; } $output->writeln($i . '/' . $count); $package_name = strtolower($download['package']['name']); $project_name = substr($package_name, 0, strpos($package_name, '/')); // echo strpos($package_name,'/').' '.$package_name."\r\n";exit; if (isset($versions[0]['require'])) { foreach ($versions[0]['require'] as $k => $v) { R::findOrCreate("CpmRequire", array("package" => $package_name, "project" => $project_name, "require" => strtolower($k), "version" => strtolower($v))); } } if (isset($versions[0]['require-dev'])) { foreach ($versions[0]['require-dev'] as $k => $v) { R::findOrCreate("CpmRequireDev", array("package" => $package_name, "project" => $project_name, "require" => strtolower($k), "version" => strtolower($v))); } } if (isset($versions[0]['keywords'])) { foreach ($versions[0]['keywords'] as $v) { R::findOrCreate("CpmKeyword", array("package" => $package_name, "project" => $project_name, "keyword" => strtolower($v))); } } } // $bar->finish(); $output->writeln(''); }