本文整理汇总了PHP中Symfony\Component\Console\Input\InputInterface::hasParameterOption方法的典型用法代码示例。如果您正苦于以下问题:PHP InputInterface::hasParameterOption方法的具体用法?PHP InputInterface::hasParameterOption怎么用?PHP InputInterface::hasParameterOption使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\Console\Input\InputInterface
的用法示例。
在下文中一共展示了InputInterface::hasParameterOption方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
/**
* {@inheritDoc}
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$session = $this->getPhpcrSession();
$dumperHelper = $this->getPhpcrConsoleDumperHelper();
// node to dump
$identifier = $input->getArgument('identifier');
// whether to dump node uuid
$options = array();
$options['dump_uuids'] = $input->hasParameterOption('--identifiers');
$options['ref_format'] = $input->getOption('ref-format');
$options['show_props'] = $input->hasParameterOption('--props');
$options['show_sys_nodes'] = $input->hasParameterOption('--sys-nodes');
$options['max_line_length'] = $input->getOption('max_line_length');
if (null !== $options['ref_format'] && !in_array($options['ref_format'], array('uuid', 'path'))) {
throw new \Exception('The ref-format option must be set to either "path" or "uuid"');
}
$walker = $dumperHelper->getTreeWalker($output, $options);
try {
if (UUIDHelper::isUUID($identifier)) {
$node = $session->getNodeByIdentifier($identifier);
} else {
$node = $session->getNode($identifier);
}
$walker->traverse($node, $input->getOption('depth'));
} catch (RepositoryException $e) {
if ($e instanceof PathNotFoundException || $e instanceof ItemNotFoundException) {
$output->writeln("<error>Path '{$identifier}' does not exist</error>");
} else {
throw $e;
}
return 1;
}
return 0;
}
示例2: execute
/**
* Executes the current command.
*
* @param InputInterface $input An InputInterface instance
* @param OutputInterface $output An OutputInterface instance
* @return null|int null or 0 if everything went fine, or an error code
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$configNames = $input->getArgument('name');
$configName = array_shift($configNames);
$defaultValue = $input->getOption('default-value');
if (!in_array($configName, $this->systemConfig->getKeys()) && !$input->hasParameterOption('--default-value')) {
return 1;
}
if (!in_array($configName, $this->systemConfig->getKeys())) {
$configValue = $defaultValue;
} else {
$configValue = $this->systemConfig->getValue($configName);
if (!empty($configNames)) {
foreach ($configNames as $configName) {
if (isset($configValue[$configName])) {
$configValue = $configValue[$configName];
} else {
if (!$input->hasParameterOption('--default-value')) {
return 1;
} else {
$configValue = $defaultValue;
break;
}
}
}
}
}
$this->writeMixedInOutputFormat($input, $output, $configValue);
return 0;
}
示例3: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
self::$label = $input->getOption('label');
// tricky test, as hasOption( 'env' ) always returns true
if ($input->hasParameterOption('--env') || $input->hasParameterOption('-e')) {
self::$forcedEnv = $input->getOption('env');
}
$driverName = $input->getOption('driver');
$debug = $input->getOption('debug');
$timeout = $input->getOption('timeout');
$this->driver = $this->getContainer()->get('kaliop_queueing.drivermanager')->getDriver($driverName);
if ($debug !== null) {
$this->driver->setDebug($debug);
}
// reimplementation of parent::execute($input, $output); to add timeout, let consumers handle signals better
// this is now handled by the driver
//if (defined('AMQP_DEBUG') === false) {
// define('AMQP_DEBUG', (bool) $input->getOption('debug'));
//}
$this->amount = $input->getOption('messages');
if (0 > $this->amount) {
throw new \InvalidArgumentException("The -m option should be null or greater than 0");
}
$this->initConsumer($input);
try {
$this->consumer->consume($this->amount, $timeout);
} catch (ForcedStopException $e) {
// exit gracefully with a message
$output->writeln("Stopped because: " . $e->getMessage());
}
// end reimplementation
// reset label after execution is done, in case of weird usage patterns
self::$label = null;
}
示例4: execute
/**
* @param InputInterface $input
* @param OutputInterface $output
*
* @throws \InvalidArgumentException
* @return int|null|void
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$this->helper = $this->getHelper('resource');
$mapmode = strtolower($input->getOption('mapmode'));
if (!in_array($mapmode, array('world', 'server'))) {
throw new \InvalidArgumentException("--mapmode must be 'world' or 'server'");
}
$mapname = $input->getOption('mapname');
$this->mapdir = $input->getOption('mapdir');
$lang = $input->getOption('lang');
if ($this->mapdir[0] != '/') {
$this->mapdir = $this->helper->get('app.path') . '/' . $this->mapdir;
}
$withMap = $input->hasParameterOption('--with-map');
$withCity = $input->hasParameterOption('--with-city');
$withRegionColor = $input->hasParameterOption('--with-region-color');
$output->writeln("=======================");
$output->writeln("mode = <info>{$mapmode}</info>");
$output->writeln("mapdir = <info>{$this->mapdir}</info>");
if (!$withMap && !$withCity && empty($lang)) {
throw new \InvalidArgumentException("Use --with-map, --with-city, --lang options\n");
}
$config = $this->helper->get('map-config');
$this->proj = new MapProjection();
$this->proj->setServerZones($this->helper->get('server.json.array'));
$maps = $config['maps'];
if ($mapmode == 'world') {
$this->proj->setWorldZones($this->helper->get('world.json.array'));
} else {
// include individual zone map
$maps = array_merge($maps, $config['zones']);
unset($maps['world']);
$this->proj->setWorldZones(array('grid' => array(array(0, 47520), array(108000, 0))));
}
$this->mapmode = $mapmode;
$this->mapname = $mapname;
$this->tileStorage = $this->helper->get('tilestorage');
// map tiles
$minMapZoom = 1;
$maxMapZoom = 11;
// city map on world image
$minCityZoom = 10;
$maxCityZoom = 11;
// text tiles
$minTextZoom = 5;
$maxTextZoom = 12;
// generate tiles for world map zone placement
if ($withMap) {
$this->doMaps($maps, $minMapZoom, $maxMapZoom, $output);
}
if ($withCity) {
$this->doMaps($config['cities'], $minCityZoom, $maxCityZoom, $output);
}
if (!empty($lang)) {
$languages = explode(',', $lang);
foreach ($languages as $l) {
$this->doTextTiles($l, $minTextZoom, $maxTextZoom, $output);
}
}
}
示例5: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
$configNames = $input->getArgument('name');
$configName = $configNames[0];
if (sizeof($configNames) > 1) {
if ($input->hasParameterOption('--error-if-not-exists') && !in_array($configName, $this->systemConfig->getKeys())) {
$output->writeln('<error>System config ' . implode(' => ', $configNames) . ' could not be deleted because it did not exist</error>');
return 1;
}
$value = $this->systemConfig->getValue($configName);
try {
$value = $this->removeSubValue(array_slice($configNames, 1), $value, $input->hasParameterOption('--error-if-not-exists'));
} catch (\UnexpectedValueException $e) {
$output->writeln('<error>System config ' . implode(' => ', $configNames) . ' could not be deleted because it did not exist</error>');
return 1;
}
$this->systemConfig->setValue($configName, $value);
$output->writeln('<info>System config value ' . implode(' => ', $configNames) . ' deleted</info>');
return 0;
} else {
if ($input->hasParameterOption('--error-if-not-exists') && !in_array($configName, $this->systemConfig->getKeys())) {
$output->writeln('<error>System config ' . $configName . ' could not be deleted because it did not exist</error>');
return 1;
}
$this->systemConfig->deleteValue($configName);
$output->writeln('<info>System config value ' . $configName . ' deleted</info>');
return 0;
}
}
示例6: initialize
/**
* @see Console\Command\Command
*/
protected function initialize(InputInterface $input, OutputInterface $output)
{
$project = $this->getApplication()->getProject();
if (true === $input->hasParameterOption(array('--path', '-p'))) {
#switch path to the argument
$project->getPath()->parse((string) $input->getOption('path'));
# change the extension directories
$project['loader']->setExtensionNamespace('Faker\\Extension', $project->getPath()->get());
}
#try and detect if path exits
$path = $project->getPath()->get();
if ($path === false) {
throw new \RuntimeException('Project Folder does not exist');
}
# path exists does it have a project
if (Project::detect((string) $path) === false && $this->getName() !== 'faker:init') {
throw new \RuntimeException('Project Folder does not contain the correct folder heirarchy');
}
# load the extension bootstrap the path has been verifed to contain an extension folder
if ($this->getName() !== 'faker:init') {
$project->getPath()->loadExtensionBootstrap();
}
if (true === $input->hasParameterOption(array('--schema'))) {
#switch path to the argument
$project['schema_name'] = $input->getOption('schema');
}
# Test for DSN
if (true === $input->hasParameterOption(array('--dsn'))) {
$project['dsn_command'] = $input->getOption('dsn');
}
parent::initialize($input, $output);
}
示例7: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
$this->setOutput($output);
$this->writeln("Watchdog started at " . $this->formatDate(), OutputInterface::VERBOSITY_VERY_VERBOSE);
$command = $input->getArgument('action');
if (!in_array($command, array('start', 'stop', 'check'))) {
throw new \InvalidArgumentException("Action '{$command}' is not valid");
}
// by default we do not force an environment on the commands we ant to execute.
// We do if we have been invoked with one - which is checked using the tricky test below here
$env = null;
if ($input->hasParameterOption('--env') || $input->hasParameterOption('-e')) {
$env = $input->getOption('env');
}
$manager = $this->getContainer()->get('kaliop_queueing.worker_manager');
$commandList = $manager->getWorkersCommands($env);
$this->writeln("Checking " . count($commandList) . " worker processes", OutputInterface::VERBOSITY_VERBOSE);
$watchdog = $this->getContainer()->get('kaliop_queueing.watchdog');
foreach ($commandList as $workerName => $cmd) {
// To see if the command is executing, we need to retrieve a version of it which was not escaped for the shell
// NB: this is most likely NOT failproof!
$workerCommand = $manager->getWorkerCommand($workerName, $env, true);
$this->writeln("Looking for process with command line: {$workerCommand}", OutputInterface::VERBOSITY_VERBOSE);
$pids = $watchdog->getProcessPidByCommand($workerCommand);
if (count($pids)) {
$pids = array_keys($pids);
switch ($command) {
case 'start':
$this->writeln("Worker: {$workerName}, found pid: " . implode(',', $pids), OutputInterface::VERBOSITY_VERBOSE);
break;
case 'stop':
$this->writeln("Stopping process: " . implode(',', $pids));
$watchdog->stopProcesses($pids);
break;
case 'check':
$this->writeln("Worker: {$workerName}, found pid: " . implode(',', $pids), OutputInterface::VERBOSITY_NORMAL);
}
} else {
switch ($command) {
case 'start':
$this->writeln("Starting worker: {$workerName}", OutputInterface::VERBOSITY_VERBOSE);
try {
$this->writeln("Command: {$cmd}");
$watchdog->startProcess($cmd);
} catch (RuntimeException $e) {
$output->writeln("Process can not be started! Reason: " . $e->getMessage());
}
break;
case 'check':
$this->writeln("Worker: {$workerName}: not started");
break;
}
}
}
$this->writeln("Watchdog ended at " . $this->formatDate(), OutputInterface::VERBOSITY_VERY_VERBOSE);
}
示例8: doRun
public function doRun(InputInterface $input, OutputInterface $output)
{
if (!$input->hasParameterOption('--quiet')) {
$output->write(sprintf("phpqa %s by Rodrigo Moyle.\n\n", $this->getVersion()));
}
if ($input->hasParameterOption('--version') || $input->hasParameterOption('-V')) {
exit;
}
return parent::doRun($input, $output);
}
示例9: doRun
/**
* Runs the current application.
*
* @param InputInterface $input An Input instance
* @param OutputInterface $output An Output instance
*
* @return int 0 if everything went fine, or an error code
*/
public function doRun(InputInterface $input, OutputInterface $output)
{
if (!$input->hasParameterOption('--quiet')) {
$output->write(sprintf("phpcov-runner %s by Levi Govaerts.\n\n", $this->getVersion()));
}
if ($input->hasParameterOption('--version') || $input->hasParameterOption('-V')) {
exit;
}
parent::doRun($input, $output);
}
示例10: doRun
/**
* Runs the current application.
*
* @param InputInterface $input An Input instance
* @param OutputInterface $output An Output instance
*
* @return integer 0 if everything went fine, or an error code
*/
public function doRun(InputInterface $input, OutputInterface $output)
{
if (!$input->hasParameterOption('--quiet')) {
$output->write(sprintf("phpunit-skelgen %s by Sebastian Bergmann.\n\n", $this->getVersion()));
}
if ($input->hasParameterOption('--version') || $input->hasParameterOption('-V')) {
exit;
}
parent::doRun($input, $output);
}
示例11: doRun
public function doRun(InputInterface $input, OutputInterface $output)
{
if (!$input->hasParameterOption('--quiet')) {
$output->write(sprintf("<info>%s</info> <comment>v%s</comment> by <comment>%s</comment> <%s>\n\n", self::APP_NAME, $this->getVersion(), self::AUTHOR_NAME, self::AUTHOR_EMAIL));
}
if ($input->hasParameterOption('--version') || $input->hasParameterOption('-V')) {
return 0;
}
return parent::doRun($input, $output);
}
示例12: doRun
public function doRun(InputInterface $input, OutputInterface $output)
{
if (true === $input->hasParameterOption(array('--shell', '-s'))) {
$shell = new Shell($this);
$shell->setProcessIsolation($input->hasParameterOption(array('--process-isolation')));
$shell->run();
return 0;
}
return parent::doRun($input, $output);
}
示例13: doRun
/**
* Runs the current application.
*
* @param InputInterface $input An Input instance
* @param OutputInterface $output An Output instance
*
* @return integer 0 if everything went fine, or an error code
*/
public function doRun(InputInterface $input, OutputInterface $output)
{
$this->registerCommands();
$this->setDispatcher($this->kernel->getContainer()->get('event_dispatcher'));
if (true === $input->hasParameterOption(array('--shell', '-s'))) {
$shell = new Shell($this);
$shell->setProcessIsolation($input->hasParameterOption(array('--process-isolation')));
$shell->run();
return 0;
}
return parent::doRun($input, $output);
}
示例14: findFiles
/**
* @param InputInterface $input
*
* @return array
* @throws \Exception
*/
public static function findFiles(InputInterface $input)
{
if ($input->hasParameterOption('--config-file')) {
$file = $input->getParameterOption('--config-file');
if (file_exists($file)) {
return [$file];
}
throw new ConfigurationFileNotFoundException(sprintf("Couldn't find the configuration file: %s", $file));
}
$format = $input->hasParameterOption('--config-format') ? $input->getParameterOption('--config-format') : static::$DEFAULT_TYPE;
return [sprintf("%s.%s", static::$NAME, $format), sprintf("%s.%s.dist", static::$NAME, $format)];
}
示例15: doRun
public function doRun(InputInterface $input, OutputInterface $output)
{
if (!$input->hasParameterOption('--quiet')) {
$output->write(sprintf("<info>%s</info> by <comment>%s</comment> <%s>\n\n", self::APP_NAME, self::AUTHOR_NAME, self::AUTHOR_EMAIL));
}
if ($input->hasParameterOption('--version') || $input->hasParameterOption('-V')) {
return 0;
}
if (!$input->getFirstArgument()) {
$input = new ArrayInput(['list']);
}
return parent::doRun($input, $output);
}