当前位置: 首页>>代码示例>>PHP>>正文


PHP Input\InputInterface类代码示例

本文整理汇总了PHP中Symfony\Component\Console\Input\InputInterface的典型用法代码示例。如果您正苦于以下问题:PHP InputInterface类的具体用法?PHP InputInterface怎么用?PHP InputInterface使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了InputInterface类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: execute

 /**
  * @param InputInterface  $input
  * @param OutputInterface $output
  *
  * @throws InvalidArgumentException
  * @return int|void
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->detectMagento($output, true);
     if (!$this->initMagento()) {
         return;
     }
     $type = $input->getArgument('type');
     $areas = array('global', 'adminhtml', 'frontend', 'crontab');
     if ($type === null) {
         $type = $this->askForArrayEntry($areas, $output, 'Please select an area:');
     }
     if (!in_array($type, $areas)) {
         throw new InvalidArgumentException('Invalid type! Use one of: ' . implode(', ', $areas));
     }
     if ($input->getOption('format') === null) {
         $this->writeSection($output, 'Observers: ' . $type);
     }
     $frontendEvents = \Mage::getConfig()->getNode($type . '/events')->asArray();
     if (true === $input->getOption('sort')) {
         // sorting for Observers is a bad idea because the order in which observers will be called is important.
         ksort($frontendEvents);
     }
     $table = array();
     foreach ($frontendEvents as $eventName => $eventData) {
         $observerList = array();
         foreach ($eventData['observers'] as $observer) {
             $observerList[] = $this->getObserver($observer, $type);
         }
         $table[] = array($eventName, implode("\n", $observerList));
     }
     $this->getHelper('table')->setHeaders(array('Event', 'Observers'))->setRows($table)->renderByFormat($output, $table, $input->getOption('format'));
 }
开发者ID:antistatique,项目名称:n98-magerun,代码行数:39,代码来源:ListCommand.php

示例2: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $url = $input->getOption('url');
     $email = $input->getOption('email');
     $disable = $input->getOption('disable');
     $events = $input->getOption('event');
     if (!$url && !$email) {
         $output->writeln('<error>Must specify either a url or an email address</error>');
         return;
     }
     if ($url && $email) {
         $output->writeln('<error>Must specify only a url or an email address</error>');
         return;
     }
     if (!($resource = $this->getResource('webhook', $output))) {
         return;
     }
     if ($url) {
         $resource->setUrl($url);
     } else {
         $resource->setEmail($email);
     }
     $resource->setEventTypes($events ? $events : Webhook::$events);
     $this->getApi()->create($resource);
     $resource = $this->getApi()->getLastResponse();
     $resource = $resource['body']['data'];
     $table = $this->getHelperSet()->get('table');
     $this->formatTableRow($resource, $table, false);
     $output->writeln('<info>Webhook created</info>');
     $table->render($output);
 }
开发者ID:memeoirs,项目名称:paymill-bundle,代码行数:31,代码来源:WebhookCreateCommand.php

示例3: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $path = $input->getArgument('path');
     if (!file_exists($path)) {
         $output->writeln("{$path} is not a file or a path");
     }
     $filePaths = [];
     if (is_file($path)) {
         $filePaths = [realpath($path)];
     } elseif (is_dir($path)) {
         $filePaths = array_diff(scandir($path), array('..', '.'));
     } else {
         $output->writeln("{$path} is not known.");
     }
     $generator = new StopwordGenerator($filePaths);
     if ($input->getArgument('type') === 'json') {
         echo json_encode($this->toArray($generator->getStopwords()), JSON_NUMERIC_CHECK | JSON_UNESCAPED_UNICODE);
         echo json_last_error_msg();
         die;
         $output->write(json_encode($this->toArray($generator->getStopwords())));
     } else {
         $stopwords = $generator->getStopwords();
         $stdout = fopen('php://stdout', 'w');
         echo 'token,freq' . PHP_EOL;
         foreach ($stopwords as $token => $freq) {
             fputcsv($stdout, [utf8_encode($token), $freq]) . PHP_EOL;
         }
         fclose($stdout);
     }
 }
开发者ID:yooper,项目名称:php-text-analysis,代码行数:30,代码来源:StopWordsCommand.php

示例4: execute

    /**
     * {@inheritdoc}
     */
    protected function execute(InputInterface $input, OutputInterface $output)
    {
        $class_name = ltrim($input->getArgument('class_name'), '\\');
        $namespace_root = $input->getArgument('namespace_root_path');
        $match = [];
        preg_match('/([a-zA-Z0-9_]+\\\\[a-zA-Z0-9_]+)\\\\(.+)/', $class_name, $match);
        if ($match) {
            $root_namespace = $match[1];
            $rest_fqcn = $match[2];
            $proxy_filename = $namespace_root . '/ProxyClass/' . str_replace('\\', '/', $rest_fqcn) . '.php';
            $proxy_class_name = $root_namespace . '\\ProxyClass\\' . $rest_fqcn;
            $proxy_class_string = $this->proxyBuilder->build($class_name);
            $file_string = <<<EOF
<?php
// @codingStandardsIgnoreFile

/**
 * This file was generated via php core/scripts/generate-proxy-class.php '{$class_name}' "{$namespace_root}".
 */
{{ proxy_class_string }}
EOF;
            $file_string = str_replace(['{{ proxy_class_name }}', '{{ proxy_class_string }}'], [$proxy_class_name, $proxy_class_string], $file_string);
            mkdir(dirname($proxy_filename), 0775, TRUE);
            file_put_contents($proxy_filename, $file_string);
            $output->writeln(sprintf('Proxy of class %s written to %s', $class_name, $proxy_filename));
        }
    }
开发者ID:318io,项目名称:318-io,代码行数:30,代码来源:GenerateProxyClassCommand.php

示例5: execute

 public function execute(InputInterface $input, OutputInterface $output)
 {
     $username = $input->getArgument('userId');
     $password = $input->getArgument('password');
     $workspaceName = $input->getArgument('workspaceName');
     $this->get('phpcr.session_manager')->relogin($username, $password, $workspaceName);
 }
开发者ID:phpcr,项目名称:phpcr-shell,代码行数:7,代码来源:SessionLoginCommand.php

示例6: listItems

 /**
  * {@inheritdoc}
  */
 protected function listItems(InputInterface $input, \Reflector $reflector = null, $target = null)
 {
     // only list constants when no Reflector is present.
     //
     // TODO: make a NamespaceReflector and pass that in for commands like:
     //
     //     ls --constants Foo
     //
     // ... for listing constants in the Foo namespace
     if ($reflector !== null || $target !== null) {
         return;
     }
     // only list constants if we are specifically asked
     if (!$input->getOption('constants')) {
         return;
     }
     $category = $input->getOption('user') ? 'user' : $input->getOption('category');
     $label = $category ? ucfirst($category) . ' Constants' : 'Constants';
     $constants = $this->prepareConstants($this->getConstants($category));
     if (empty($constants)) {
         return;
     }
     $ret = array();
     $ret[$label] = $constants;
     return $ret;
 }
开发者ID:JesseDarellMoore,项目名称:CS499,代码行数:29,代码来源:ConstantEnumerator.php

示例7: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     // Replace this with dependency injection once available
     /** @var DiagnosticService $diagnosticService */
     $diagnosticService = StaticContainer::get('Piwik\\Plugins\\Diagnostics\\DiagnosticService');
     $showAll = $input->getOption('all');
     $report = $diagnosticService->runDiagnostics();
     foreach ($report->getAllResults() as $result) {
         $items = $result->getItems();
         if (!$showAll && $result->getStatus() === DiagnosticResult::STATUS_OK) {
             continue;
         }
         if (count($items) === 1) {
             $output->writeln($result->getLabel() . ': ' . $this->formatItem($items[0]), OutputInterface::OUTPUT_PLAIN);
             continue;
         }
         $output->writeln($result->getLabel() . ':');
         foreach ($items as $item) {
             $output->writeln("\t- " . $this->formatItem($item), OutputInterface::OUTPUT_PLAIN);
         }
     }
     if ($report->hasWarnings()) {
         $output->writeln(sprintf('<comment>%d warnings detected</comment>', $report->getWarningCount()));
     }
     if ($report->hasErrors()) {
         $output->writeln(sprintf('<error>%d errors detected</error>', $report->getErrorCount()));
         return 1;
     }
     return 0;
 }
开发者ID:FluentDevelopment,项目名称:piwik,代码行数:30,代码来源:Run.php

示例8: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->output = $output;
     $this->client = $client = SnsClient::factory(array('key' => $this->getContainer()->getParameter('amazon_s3.key'), 'secret' => $this->getContainer()->getParameter('amazon_s3.secret'), 'region' => $this->getContainer()->getParameter('amazon_s3.region')));
     if ($input->getOption('list-android')) {
         $this->showEndpoints($this->getContainer()->getParameter('amazon_sns.android_arn'), 'List of GCM endpoints:');
     }
     if ($input->getOption('list-ios')) {
         $this->showEndpoints($this->getContainer()->getParameter('amazon_sns.ios_arn'), 'List of APNS endpoints:');
     }
     $endpoint = $input->getArgument('endpoint');
     if ($endpoint) {
         if ($input->getOption('delete')) {
             $output->writeln('<comment>Delete endpoint</comment>');
             $client->deleteEndpoint(array('EndpointArn' => $endpoint));
         } else {
             $testMessage = 'Test notification';
             try {
                 $client->publish(array('TargetArn' => $endpoint, 'MessageStructure' => 'json', 'Message' => json_encode(array('APNS' => json_encode(array('aps' => array('alert' => $testMessage))), 'GCM' => json_encode(array('data' => array('message' => $testMessage)))))));
             } catch (\Aws\Sns\Exception\SnsException $e) {
                 $output->writeln("<error>{$e->getMessage()}</error>");
             }
         }
     }
 }
开发者ID:shakaran,项目名称:powerline-server,代码行数:25,代码来源:SnsCommand.php

示例9: execute

 /**
  * @param InputInterface  $input
  * @param OutputInterface $output
  *
  * @return void
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $outputFile = $input->getArgument('output');
     $outputHandle = fopen($outputFile, 'w');
     $client = new Client([]);
     $headers = ['Accept' => 'application/json', 'Accept-Encoding' => 'gzip,deflate', 'User-Agent' => 'crossref-dois/0.1 (+https://github.com/hubgit/crossref-dois/)'];
     // https://api.crossref.org/works?filter=type:journal-article&cursor=*
     $filters = ['type' => 'journal-article'];
     $filter = implode(',', array_map(function ($key) use($filters) {
         return $key . ':' . $filters[$key];
     }, array_keys($filters)));
     $params = ['filter' => $filter, 'cursor' => '*', 'rows' => 1000];
     $progress = new ProgressBar($output);
     $progressStarted = false;
     do {
         $response = $client->get('https://api.crossref.org/works', ['connect_timeout' => 10, 'timeout' => 120, 'query' => $params, 'headers' => $headers]);
         $data = json_decode($response->getBody(), true);
         if (!$progressStarted) {
             $progress->start($data['message']['total-results']);
             $progressStarted = true;
         }
         $items = $this->parseResponse($data);
         foreach ($items as $item) {
             fwrite($outputHandle, json_encode($item) . "\n");
         }
         $params['cursor'] = $data['message']['next-cursor'];
         $progress->advance(count($items));
     } while ($params['cursor']);
     $progress->finish();
 }
开发者ID:hubgit,项目名称:crossref-dois,代码行数:36,代码来源:FetchCommand.php

示例10: formatErroneousPlugin

 private function formatErroneousPlugin(InputInterface $input, Plugin $plugin)
 {
     if ($input->getOption('json')) {
         return ['name' => $plugin->getName(), 'error' => true, 'description' => 'Error : ' . $plugin->getError()->getMessage(), 'version' => null];
     }
     return ['<error>' . $plugin->getName() . '</error>', '<error>Error : ' . $plugin->getError()->getMessage() . '</error>', ''];
 }
开发者ID:nlegoff,项目名称:Phraseanet,代码行数:7,代码来源:ListPlugin.php

示例11: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $emName = $input->getOption('em');
     $emName = $emName ? $emName : 'default';
     $emServiceName = sprintf('doctrine.orm.%s_entity_manager', $emName);
     $em = $this->container->get($emServiceName);
     $dirOrFile = $input->getOption('fixtures');
     if ($dirOrFile) {
         $paths = is_array($dirOrFile) ? $dirOrFile : array($dirOrFile);
     } else {
         $paths = array();
         foreach ($this->application->getKernel()->getBundles() as $bundle) {
             $paths[] = $bundle->getPath() . '/DataFixtures/ORM';
         }
     }
     $loader = new DataFixturesLoader($this->container);
     foreach ($paths as $path) {
         if (is_dir($path)) {
             $loader->loadFromDirectory($path);
         }
     }
     $fixtures = $loader->getFixtures();
     $purger = new ORMPurger($em);
     $executor = new ORMExecutor($em, $purger);
     $executor->setLogger(function ($message) use($output) {
         $output->writeln(sprintf('  <comment>></comment> <info>%s</info>', $message));
     });
     $executor->execute($fixtures, $input->getOption('append'));
 }
开发者ID:rooster,项目名称:symfony,代码行数:29,代码来源:LoadDataFixturesDoctrineCommand.php

示例12: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     if ($input->getOption("maintenance-mode")) {
         // set the timeout between each iteration to 0 if maintenance mode is on, because
         // we don't have to care about the load on the server
         Warming::setTimoutBetweenIteration(0);
     }
     try {
         $types = $this->getArrayOption('types', 'validTypes', 'type', true);
         $documentTypes = $this->getArrayOption('documentTypes', 'validDocumentTypes', 'document type');
         $assetTypes = $this->getArrayOption('assetTypes', 'validAssetTypes', 'asset type');
         $objectTypes = $this->getArrayOption('objectTypes', 'validObjectTypes', 'object type');
     } catch (\InvalidArgumentException $e) {
         $this->writeError($e->getMessage());
         return 1;
     }
     if (in_array('document', $types)) {
         $this->writeWarmingMessage('document', $documentTypes);
         Warming::documents($documentTypes);
     }
     if (in_array('asset', $types)) {
         $this->writeWarmingMessage('asset', $assetTypes);
         Warming::assets($assetTypes);
     }
     if (in_array('object', $types)) {
         $this->writeWarmingMessage('object', $objectTypes);
         Warming::assets($assetTypes);
     }
     $this->disableMaintenanceMode();
 }
开发者ID:siite,项目名称:choose-sa-cloud,代码行数:30,代码来源:CacheWarmingCommand.php

示例13: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $subUrls = $input->getArgument('url');
     $outputFile = $input->getArgument('output-file');
     // Daten laden
     $kosS = new KingOfSatScrapper();
     $output->writeln('Start Pulling Data');
     if (count($subUrls) > 0) {
         $firstRun = true;
         foreach ($subUrls as $url) {
             $data = $kosS->getTransponderData($url);
             $output->writeln(count($data) . ' Transponders found in ' . $url);
             if (true === $firstRun && count($data) > 0) {
                 $this->setupExcel(array_keys($data[0]));
                 $firstRun = false;
             }
             $this->addRowsToExcel($data);
         }
         // Daten ausgeben
         $output->writeln('Generate Excelfile: ' . $outputFile);
         $this->saveExcel($outputFile);
     } else {
         $output->writeln('<error>Missing pages to Scrap. See help.</error>');
     }
     $output->writeln('<info>(c) Steven Buehner <buehner@me.com></info>');
 }
开发者ID:stevenbuehner,项目名称:kingofsat-commandline-scrapper,代码行数:26,代码来源:KingofsatCommand.php

示例14: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new DrupalStyle($input, $output);
     $state = $this->getState();
     $mode = $input->getArgument('mode');
     $stateName = 'system.maintenance_mode';
     $modeMessage = null;
     $cacheRebuild = true;
     if ('ON' === strtoupper($mode)) {
         $state->set($stateName, true);
         $modeMessage = 'commands.site.maintenance.messages.maintenance-on';
     }
     if ('OFF' === strtoupper($mode)) {
         $state->set($stateName, false);
         $modeMessage = 'commands.site.maintenance.messages.maintenance-off';
     }
     if ($modeMessage === null) {
         $modeMessage = 'commands.site.maintenance.errors.invalid-mode';
         $cacheRebuild = false;
     }
     $io->info($this->trans($modeMessage));
     if ($cacheRebuild) {
         $this->getChain()->addCommand('cache:rebuild', ['cache' => 'all']);
     }
 }
开发者ID:blasoliva,项目名称:DrupalConsole,代码行数:25,代码来源:MaintenanceCommand.php

示例15: interact

 /**
  * @see Command
  */
 protected function interact(InputInterface $input, OutputInterface $output)
 {
     $helper = $this->getHelper('question');
     $doctrine = $this->getContainer()->get('doctrine');
     $pool = $this->getContainer()->get('sulu_admin.admin_pool');
     $contexts = $pool->getSecurityContexts();
     $systems = array_keys($contexts);
     if (!$input->getArgument('name')) {
         $question = new Question('Please choose a rolename: ');
         $question->setValidator(function ($name) use($doctrine) {
             if (empty($name)) {
                 throw new \InvalidArgumentException('Rolename cannot be empty');
             }
             $roles = $this->getContainer()->get('sulu.repository.role')->findBy(['name' => $name]);
             if (count($roles) > 0) {
                 throw new \InvalidArgumentException(sprintf('Rolename "%s" is not unique', $name));
             }
             return $name;
         });
         $name = $helper->ask($input, $output, $question);
         $input->setArgument('name', $name);
     }
     if (!$input->getArgument('system')) {
         $question = new ChoiceQuestion('Please choose a system: ', $systems, 0);
         $system = $helper->ask($input, $output, $question);
         $input->setArgument('system', $system);
     }
 }
开发者ID:Silwereth,项目名称:sulu,代码行数:31,代码来源:CreateRoleCommand.php


注:本文中的Symfony\Component\Console\Input\InputInterface类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。