本文整理匯總了PHP中Symfony\Component\Console\Output\ConsoleOutput::writeln方法的典型用法代碼示例。如果您正苦於以下問題:PHP ConsoleOutput::writeln方法的具體用法?PHP ConsoleOutput::writeln怎麽用?PHP ConsoleOutput::writeln使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Symfony\Component\Console\Output\ConsoleOutput
的用法示例。
在下文中一共展示了ConsoleOutput::writeln方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: execute
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;
}
示例2: overview
public static function overview()
{
$printer = new ConsoleOutput();
$printer->writeln('');
$printer->writeln('Testing Environment');
$printer->writeln('===================');
$printer->writeln('Machine : ' . gethostname());
$printer->writeln('Database : ' . Config::get('database.default'));
}
示例3: destroyTestUser
/**
* 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;
}
示例4: execute
/**
* 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>');
}
示例5: execute_commands
/**
* @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("");
}
}
示例6: processFiles
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('');
}
示例7: terminate
/**
* @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('');
// }
}
示例8: dump
/**
* @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('');
}
}
}
示例9: doDownLoad
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('');
}
示例10: loadExternalConfig
/**
* Load the external config files specified by the command line option.
*/
protected function loadExternalConfig()
{
$config = new Repository(static::getDefaultConfig());
$filesystem = new Filesystem();
foreach ($this->getConfigFiles($filesystem) as $filename) {
$this->output->writeln("<info>Reading config from <path>{$filename}</path></info>");
if ($filesystem->extension($filename) == 'php') {
$configValues = $filesystem->getRequire($filename);
} else {
$configValues = Yaml::parse($filesystem->get($filename));
}
$config->set(array_dot($configValues));
}
$this->container->instance('config', $config);
}
示例11: printDebug
/**
* Print a message out - useful for debugging
*
* @param $string
*/
protected function printDebug($string)
{
if ($this->output === null) {
$this->output = new ConsoleOutput();
}
$this->output->writeln($string);
}
示例12: execute_commands
/**
* @param $commands
* @param \Symfony\Component\Console\Output\ConsoleOutput $output
*
* @return boolean
*/
function execute_commands($commands, $output)
{
foreach ($commands as $command) {
$output->writeln(sprintf('<info>Executing : </info> %s', $command));
$p = new \Symfony\Component\Process\Process($command);
$p->setTimeout(null);
$p->run(function ($type, $data) use($output) {
$output->write($data);
});
if (!$p->isSuccessful()) {
return false;
}
$output->writeln("");
}
return true;
}
示例13: runDatabaseMigrations
/**
* @before
*/
public function runDatabaseMigrations()
{
if ($GLOBALS['run_database_migrations']) {
return;
}
$GLOBALS['run_database_migrations'] = true;
$output = new ConsoleOutput();
if (getenv('SCHEMA_DUMP') == 1) {
$output->writeln("Cleaning Database with artisan's <bg=green;options=bold>db:fix && db:schema:dump</>...");
$this->artisan('db:fix');
$this->artisan('db:schema:dump', ['--output-file' => 'tests/_data/dump.sql', '--binary' => 'true']);
} else {
$output->writeln("Restoring Database with artisan's <bg=green;options=bold>db:schema:restore</>...");
$this->artisan('db:schema:restore', ['--schema-file' => 'tests/_data/dump.sql']);
}
}
示例14: listNodes
protected function listNodes(array $nodes, $sortBy = self::SORT_BY_NAME)
{
switch ($sortBy) {
case self::SORT_BY_NAME:
usort($nodes, function ($a, $b) {
return strcasecmp($a['name'], $b['name']);
});
break;
case self::SORT_BY_TIME:
usort($nodes, function ($a, $b) {
return strtotime($a['modifiedDate']) < strtotime($b['modifiedDate']);
});
break;
}
foreach ($nodes as $node) {
if ($node->inTrash() && !$this->config['display.trash']) {
continue;
}
$modified = new \DateTime($node['modifiedDate']);
if ($modified->format('Y') === date('Y')) {
$date = $modified->format('M d H:m');
} else {
$date = $modified->format('M d Y');
}
$name = $node['kind'] === 'FOLDER' ? "<blue>{$node['name']}</blue>" : $node['name'];
$this->output->writeln(sprintf("%s %s %s %s %s %s", $node['id'], $date, str_pad($node['status'], 10), str_pad($node['kind'], 7), str_pad($this->convertFilesize($node['contentProperties']['size'], 0), 6), $name));
}
}
示例15: __construct
/**
* @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);
}