本文整理汇总了PHP中Symfony\Component\Console\Input\InputInterface::hasOption方法的典型用法代码示例。如果您正苦于以下问题:PHP InputInterface::hasOption方法的具体用法?PHP InputInterface::hasOption怎么用?PHP InputInterface::hasOption使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\Console\Input\InputInterface
的用法示例。
在下文中一共展示了InputInterface::hasOption方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
try {
$settings = new PhpParallelLint\Settings();
//$output->writeln("Hola");
if ($input->hasArgument("directory")) {
$settings->paths = $input->getArgument("directory");
}
if ($input->hasOption("exclude")) {
$settings->excluded = $input->getOption("exclude");
}
if ($input->hasOption("extension")) {
$settings->extensions = $input->getOption("extension");
}
if ($input->hasOption("number-jobs")) {
$settings->parallelJobs = $input->getOption("number-jobs");
}
if ($input->hasOption("no-colors")) {
$settings->colors = false;
}
$manager = new PhpParallelLint\Manager();
$result = $manager->run($settings);
} catch (Exception $e) {
}
}
示例2: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
$application = $this->getApplication();
$config = $application->getConfig();
$global = false;
if ($input->hasOption('global')) {
$global = $input->getOption('global');
}
$project = $input->getOption('project');
if ($global && $project) {
throw new \Exception('Options `project` and `global` can not used in combination.');
}
if (!$global && (!$project || !in_array($project, $this->projects))) {
throw new \Exception(sprintf('You must provide a valid project value (%s)', implode(',', $this->projects)));
}
$override = false;
if ($input->hasOption('override')) {
$override = $input->getOption('override');
}
if ($global) {
$this->copyHomeDirectory($output, $config, $override);
}
if (!$global) {
$this->copyCurrentDirectory($output, $config, $override, $project);
}
}
示例3: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
if (!is_dir($path = realpath($input->getArgument(self::ARGUMENT_PATH)))) {
throw new \OutOfBoundsException("Could not find " . $input->getArgument(self::ARGUMENT_PATH));
}
$output->writeln("Analyze source code in {$path}");
$project = new Project();
$project->dataDir = $this->targetDir;
$project->baseDir = $path;
if ($input->hasOption(self::OPTION_EXCLUDE)) {
$project->excludes = array_filter(array_map('trim', explode(',', $input->getOption(self::OPTION_EXCLUDE))));
}
if ($input->hasOption(self::OPTION_COVERAGE)) {
$project->coverage = $input->getOption(self::OPTION_COVERAGE);
}
$this->filterHandlers($input);
foreach ($this->handlers as $name => $handler) {
$output->writeln(" * Running {$name}");
try {
$existingResult = $input->hasOption($name) ? $input->getOption($name) : null;
if ($result = $handler->handle($project, $existingResult)) {
$project->analyzers[$name] = $this->copyResultFile($name, $result);
}
} catch (\Exception $exception) {
$output->writeln('<error>' . $exception . '</error>');
$result = null;
}
}
file_put_contents($this->targetDir . '/project.json', json_encode($project));
$output->writeln("Done");
}
示例4: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
global $prefs, $url_scheme, $url_host, $tikiroot, $url_port;
$days = intval($input->getArgument('days')) ?: 7;
if ($input->getOption('ssl')) {
$url_scheme = 'https';
}
if ($input->hasOption('port')) {
$url_port = (int) $input->getOption('port');
}
if ($input->hasOption('path')) {
$tikiroot = $input->getOption('path');
// Make sure slash before and after
$tikiroot = rtrim($tikiroot, '/') . '/';
$tikiroot = '/' . ltrim($tikiroot, '/');
}
$url_host = $input->getArgument('domain');
$list = \TikiDb::get()->fetchAll("\n\t\t\tSELECT userId, login, email, IFNULL(p.value, ?) language\n\t\t\tFROM users_users u\n\t\t\t\tLEFT JOIN tiki_user_preferences p ON u.login = p.user AND p.prefName = 'language'", [$prefs['site_language']]);
$monitormail = \TikiLib::lib('monitormail');
$from = date('Y-m-d H:i:s', time() - $days * 24 * 3600);
$to = date('Y-m-d H:i:s');
foreach ($list as $info) {
$success = $monitormail->sendDigest($info, $from, $to);
if ($success) {
$output->writeln("Digest sent to {$info['email']}");
} else {
$output->writeln("No data for {$info['email']}");
}
}
}
示例5: execute
/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$command = $this->getApplication()->find('chain');
$arguments = ['command' => 'chain', '--file' => $this->file, '--placeholder' => $input->getOption('placeholder'), '--generate-inline' => $input->hasOption('generate-inline'), '--no-interaction' => $input->hasOption('no-interaction')];
$commandInput = new ArrayInput($arguments);
return $command->run($commandInput, $output);
}
示例6: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
$pageIdentifiers = array();
if ($input->hasOption('pageid')) {
foreach ($input->getOption('pageid') as $pageId) {
$pageIdentifiers[] = new PageIdentifier(null, (int) $pageId);
}
} elseif ($input->hasOption('title')) {
foreach ($input->getOption('title') as $title) {
$pageIdentifiers[] = new PageIdentifier(new Title($title));
}
} else {
throw new \RuntimeException('No titles or pageids were set!');
}
$wiki = $input->getOption('wiki');
$wikiDetails = $this->appConfig->offsetGet('wikis.' . $wiki);
$api = new MediawikiApi($wikiDetails['url']);
$mwFactory = new MediawikiFactory($api);
$purger = $mwFactory->newPagePurger();
/** @var PageIdentifier $identifier */
foreach ($pageIdentifiers as $identifier) {
if ($identifier->getId() != null) {
$output->writeln('Purging page with id ' . $identifier->getId());
} elseif ($identifier->getTitle() != null) {
$output->writeln('Purging page with title ' . $identifier->getTitle()->getText());
}
$purger->purge(new Page($identifier));
}
$output->writeln('Done');
}
示例7: execute
/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$io = new DrupalStyle($input, $output);
$yes = $input->hasOption('yes') ? $input->getOption('yes') : false;
// @see use Drupal\Console\Command\ConfirmationTrait::confirmGeneration
if (!$this->confirmGeneration($io, $yes)) {
return;
}
$learning = $input->hasOption('learning') ? $input->getOption('learning') : false;
$module = $input->getOption('module');
$class = $input->getOption('class');
$routes = $input->getOption('routes');
$test = $input->getOption('test');
$services = $input->getOption('services');
$routes = $this->inlineValueAsArray($routes);
$input->setOption('routes', $routes);
// @see use Drupal\Console\Command\ServicesTrait::buildServices
$build_services = $this->buildServices($services);
// Controller machine name
$classMachineName = $this->getStringHelper()->camelCaseToMachineName($class);
$generator = $this->getGenerator();
$generator->setLearning($learning);
$generator->generate($module, $class, $routes, $test, $build_services, $classMachineName);
$this->getChain()->addCommand('router:rebuild');
}
示例8: execute
/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$environment = $input->getOption('env');
try {
$schema = $input->hasOption('schema') ? $input->getOption('schema') : UniqueIdGenerator::SCHEMA_UUID;
$qty = $input->hasOption('quantity') ? $input->getOption('quantity') : 1;
$ver = 5;
//$input->hasOption('version') ? $input->getOption('version') : 5;
$generator = UniqueIdGenerator::instance();
for ($i = 0; $i < $qty; $i++) {
$id = $generator->generate($schema, $ver);
$output->writeln($id);
}
} catch (\Exception $ex) {
$exception = new OutputFormatterStyle('red');
$output->getFormatter()->setStyle('exception', $exception);
$output->writeln("\n\n");
$output->writeln('<exception>[Exception in: ' . get_class($this) . ']</exception>');
$output->writeln('<exception>Exception: ' . get_class($ex) . ' with message: ' . $ex->getMessage() . '</exception>');
$output->writeln('<exception>Stack Trace:</exception>');
$output->writeln('<exception>' . $ex->getTraceAsString() . '</exception>');
exit(1);
}
exit(0);
}
示例9: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
$doctrine = $this->getContainer()->get('doctrine');
$username = $input->getArgument('username');
$password = $input->getArgument('password');
$user = new User($username, $password);
$roles = ['ROLE_USER', 'ROLE_API'];
if ($input->hasOption('roles')) {
$roles = array_merge($roles, $input->getOption('roles'));
}
$user->setRoles($roles);
if ($input->hasOption('firstName')) {
$user->setFirstName($input->getOption('firstName'));
}
if ($input->hasOption('lastName')) {
$user->setLastName($input->getOption('lastName'));
}
if ($input->hasOption('email')) {
$user->setEmail($input->getOption('email'));
}
$manager = $doctrine->getManager();
$manager->persist($user);
$manager->flush($user);
$output->writeln(sprintf('New user: <info>%s</info>, with password: <info>%s</info> created', $username, $password));
}
示例10: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
/**
* set context inside container
*/
$this->container->register(new LoggerProvider($output));
try {
/** @var LoggerInterface $logger */
$logger = $this->container['logger'];
$connection = ['host' => $input->getArgument('host'), 'port' => $input->getArgument('port'), 'user' => $input->getArgument('username'), 'password' => $input->getArgument('password')];
$client = $this->container['curl_client_factory']->createClient($connection);
$queueManager = $this->container['manager_rabbitmq_queue'];
$exchangeManager = $this->container['manager_rabbitmq_exchange'];
$policygeManager = $this->container['manager_rabbitmq_policy'];
$manager = new DeleteManager($exchangeManager, $queueManager, $policygeManager, $logger);
if ($input->hasOption('queues') && null !== $input->getOption('queues')) {
$queueManager->setClient($client);
$manager->deleteQueues($input->getOption('vhost'), $input->getOption('queues'));
}
if ($input->hasOption('exchanges') && null !== $input->getOption('exchanges')) {
$exchangeManager->setClient($client);
$manager->deleteExchanges($input->getOption('vhost'), $input->getOption('exchanges'));
}
if ($input->hasOption('policies') && null !== $input->getOption('policies')) {
$policygeManager->setClient($client);
$manager->deletePolicies($input->getOption('vhost'), $input->getOption('policies'));
}
} catch (\Exception $e) {
$logger->critical($e->getMessage());
return 1;
}
return 0;
}
示例11: execute
/**
* @param InputInterface $input
* @param OutputInterface $output
* @return int|null
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
if ($input->hasOption('key')) {
$key = $input->getOption('key');
} else {
$key = null;
}
if ($input->hasOption('secret')) {
$secret = $input->getOption('secret');
} else {
$secret = null;
}
try {
/**
* @var $authenticator \WeavingTheWeb\Bundle\TwitterBundle\Security\ApplicationAuthenticator
*/
$authenticator = $this->getContainer()->get('weaving_the_web_twitter.application_authenticator');
$authenticationResult = $authenticator->authenticate($key, $secret);
$key = $authenticationResult['consumer_key'];
/**
* @var \Symfony\Component\Translation\Translator $translator
*/
$translator = $this->getContainer()->get('translator');
$output->writeln($translator->trans('twitter.success.authentication', ['{{ consumer_key }}' => $key]));
} catch (\Exception $exception) {
$this->getContainer()->get('logger')->error($exception->getMessage());
return 1;
}
return 0;
}
示例12: setupQueue
private function setupQueue(InputInterface $input)
{
$container = $this->getContainer();
if ($input->hasOption('host') && ($host = $input->getOption('host'))) {
$container[BeanstalkKeys::HOST] = $host;
}
if ($input->hasOption('port') && ($port = $input->getOption('port'))) {
$container[BeanstalkKeys::PORT] = $port;
}
$logger = $this->logger;
if ($container instanceof \Pimple) {
$container[BeanstalkKeys::QUEUE] = $container->share($container->extend(BeanstalkKeys::QUEUE, function (QueueInterface $queue) use($logger) {
$queue->setLogger($logger);
return $queue;
}));
} elseif ($container instanceof \Pimple\Container) {
$container->extend(BeanstalkKeys::QUEUE, function (QueueInterface $queue) use($logger) {
$queue->setLogger($logger);
return $queue;
});
} else {
$queue = $container[BeanstalkKeys::QUEUE];
$queue->setLogger($logger);
$container[BeanstalkKeys::QUEUE] = $queue;
}
}
示例13: afterExample
/**
* @param ExampleEvent $event
*
* @throws \PhpSpec\Exception\Example\StopOnFailureException
*/
public function afterExample(ExampleEvent $event)
{
if (!$this->input->hasOption('stop-on-failure') || !$this->input->getOption('stop-on-failure')) {
return;
}
if ($event->getResult() === ExampleEvent::FAILED || $event->getResult() === ExampleEvent::BROKEN) {
throw new StopOnFailureException('Example failed');
}
}
示例14: getDefaultParams
/**
* Get default parameters
*
* @return array
*/
protected function getDefaultParams()
{
$defaultParams = ['--no-debug' => true];
if ($this->input->hasOption('env')) {
$defaultParams['--env'] = $this->input->getOption('env');
}
if ($this->input->hasOption('verbose') && $this->input->getOption('verbose') === true) {
$defaultParams['--verbose'] = true;
}
return $defaultParams;
}
示例15: parseCommandLine
/**
* @param InputInterface $input
* @param bool $alsoDisable
* @param bool $includeRemote
* @param string|null $factory
* @param int|null $signal
*
* @throws Exception\InvalidArgumentException
*/
private function parseCommandLine(InputInterface $input, &$alsoDisable, &$includeRemote, &$factory, &$signal)
{
$alsoDisable = $input->getOption('also-disable');
$includeRemote = $input->getOption('include-remote');
$factory = $input->hasOption('factory') ? $input->getOption('factory') : null;
$signal = $input->hasOption('signal') ? $input->getOption('signal') : null;
if ($signal !== null) {
$includeRemote = false;
$signal = self::parseSignal($signal);
}
}