當前位置: 首頁>>代碼示例>>PHP>>正文


PHP InputInterface::getArgument方法代碼示例

本文整理匯總了PHP中Symfony\Component\Console\Input\InputInterface::getArgument方法的典型用法代碼示例。如果您正苦於以下問題:PHP InputInterface::getArgument方法的具體用法?PHP InputInterface::getArgument怎麽用?PHP InputInterface::getArgument使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Symfony\Component\Console\Input\InputInterface的用法示例。


在下文中一共展示了InputInterface::getArgument方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: 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

示例2: 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

示例3: 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

示例4: execute

 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $em = $this->getHelper('em')->getEntityManager();
     $entityClass = $input->getArgument('entity-class');
     $entityId = $input->getArgument('entity-id');
     $cache = $em->getCache();
     if (!$cache instanceof Cache) {
         throw new \InvalidArgumentException('No second-level cache is configured on the given EntityManager.');
     }
     if (!$entityClass && !$input->getOption('all')) {
         throw new \InvalidArgumentException('Invalid argument "--entity-class"');
     }
     if ($input->getOption('flush')) {
         $entityRegion = $cache->getEntityCacheRegion($entityClass);
         if (!$entityRegion instanceof DefaultRegion) {
             throw new \InvalidArgumentException(sprintf('The option "--flush" expects a "Doctrine\\ORM\\Cache\\Region\\DefaultRegion", but got "%s".', is_object($entityRegion) ? get_class($entityRegion) : gettype($entityRegion)));
         }
         $entityRegion->getCache()->flushAll();
         $output->writeln(sprintf('Flushing cache provider configured for entity named <info>"%s"</info>', $entityClass));
         return;
     }
     if ($input->getOption('all')) {
         $output->writeln('Clearing <info>all</info> second-level cache entity regions');
         $cache->evictEntityRegions();
         return;
     }
     if ($entityId) {
         $output->writeln(sprintf('Clearing second-level cache entry for entity <info>"%s"</info> identified by <info>"%s"</info>', $entityClass, $entityId));
         $cache->evictEntity($entityClass, $entityId);
         return;
     }
     $output->writeln(sprintf('Clearing second-level cache for entity <info>"%s"</info>', $entityClass));
     $cache->evictEntityRegion($entityClass);
 }
開發者ID:Dren-x,項目名稱:mobitnew,代碼行數:37,代碼來源:EntityRegionCommand.php

示例5: execute

 /**
  * @see Command
  * @see SecurityChecker
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     if ($endPoint = $input->getOption('end-point')) {
         $this->checker->getCrawler()->setEndPoint($endPoint);
     }
     if ($timeout = $input->getOption('timeout')) {
         $this->checker->getCrawler()->setTimeout($timeout);
     }
     try {
         $vulnerabilities = $this->checker->check($input->getArgument('lockfile'));
     } catch (ExceptionInterface $e) {
         $output->writeln($this->getHelperSet()->get('formatter')->formatBlock($e->getMessage(), 'error', true));
         return 1;
     }
     switch ($input->getOption('format')) {
         case 'json':
             $formatter = new JsonFormatter();
             break;
         case 'simple':
             $formatter = new SimpleFormatter($this->getHelperSet()->get('formatter'));
             break;
         case 'text':
         default:
             $formatter = new TextFormatter($this->getHelperSet()->get('formatter'));
     }
     $formatter->displayResults($output, $input->getArgument('lockfile'), $vulnerabilities);
     if ($this->checker->getLastVulnerabilityCount() > 0) {
         return 1;
     }
 }
開發者ID:BusinessCookies,項目名稱:CoffeeMachineProject,代碼行數:34,代碼來源:SecurityCheckerCommand.php

示例6: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $masterLanguage = $input->getArgument('master');
     $slaveLanguage = $input->getArgument('slave');
     $masterLanguageFile = $this->path . 'messages.' . $masterLanguage . '.yml';
     $slaveLanguageFile = $this->path . 'messages.' . $slaveLanguage . '.yml';
     $catMasterFile = $this->loader->load($masterLanguageFile, $masterLanguage);
     $catSlaveFile = $this->loader->load($slaveLanguageFile, $slaveLanguage);
     foreach ($catMasterFile->all('messages') as $key => $value) {
         if (!$catSlaveFile->has($key)) {
             $catSlaveFile->set($key, "TODO: {$value}");
         }
     }
     $messages = $catMasterFile->all('messages');
     ksort($messages);
     $catSlaveFile->replace($messages);
     foreach ($messages as $key => $value) {
         $catSlaveFile->set($key, $value);
     }
     $output->writeln('Slave file can modify');
     $dumper = new YamlFileDumper();
     $dumper->dump($catSlaveFile, array('path' => $this->path));
     /*unlink created trash file*/
     if (file_exists($slaveLanguageFile . '~')) {
         unlink($slaveLanguageFile . '~');
     }
     $output->writeln($slaveLanguageFile . ' --> <info>Slave file updated</info>');
 }
開發者ID:necatikartal,項目名稱:ojs,代碼行數:28,代碼來源:TranslateSynchronizeCommand.php

示例7: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     # MVC object
     $mvc = MVCStore::retrieve('mvc');
     if ($input->getArgument('folder') == 'web') {
         $input->setArgument('folder', dirname($mvc->getAppDir()) . '/web');
     }
     $folderArg = rtrim($input->getArgument('folder'), '/');
     if (!is_dir($folderArg)) {
         throw new \InvalidArgumentException(sprintf('The target directory "%s" does not exist.', $input->getArgument('folder')));
     }
     $modulesPath = $folderArg . '/modules/';
     @mkdir($modulesPath);
     if ($input->getOption('symlinks')) {
         $output->writeln('Trying to install assets as <comment>symbolic links</comment>.');
     } else {
         $output->writeln('Installing assets as <comment>hard copies</comment>.');
     }
     foreach ($mvc->getModules() as $module) {
         if (is_dir($originDir = $module->getPath() . '/Resources/public')) {
             $targetDir = $modulesPath . preg_replace('/module$/', '', strtolower($module->getName()));
             $output->writeln(sprintf('Installing assets for <comment>%s</comment> into <comment>%s</comment>', $module->getNamespace(), $targetDir));
             if (!$this->recursiveRemoveDir($targetDir)) {
                 $output->writeln(sprintf('Could\'t been removed the dir "%s".', $targetDir));
             }
             if ($input->getOption('symlinks')) {
                 #link($originDir, $targetDir);
                 @symlink($originDir, $targetDir);
             } else {
                 $this->resourceCopy($originDir, $targetDir);
             }
         }
     }
 }
開發者ID:simple-php-mvc,項目名稱:installer-module,代碼行數:34,代碼來源:AssetsInstallCommand.php

示例8: execute

 /**
  * Execute the command.
  *
  * @param  \Symfony\Component\Console\Input\InputInterface  $input
  * @param  \Symfony\Component\Console\Output\OutputInterface  $output
  * @return void
  */
 public function execute(InputInterface $input, OutputInterface $output)
 {
     $client = new Client();
     $modname = $input->getArgument('modname');
     $modversion = $input->getArgument('modversion');
     $config = solder_config();
     $response = $client->get($config->api);
     $server = $response->json();
     $response = $client->get($config->api . '/mod/' . $modname . '/' . $modversion);
     $json = $response->json();
     if (isset($json['error'])) {
         throw new \Exception($json['error']);
     }
     $rows = array();
     foreach ($json as $key => $value) {
         if ($key == 'versions') {
             $rows[] = array("<info>{$key}</info>", implode($value, "\n"));
         } else {
             $rows[] = array("<info>{$key}</info>", mb_strimwidth($value, 0, 80, "..."));
         }
     }
     $output->writeln('<comment>Server:</comment>');
     $output->writeln(" <info>{$server['api']}</info> version {$server['version']}");
     $output->writeln(" {$api}");
     $output->writeln('');
     $output->writeln("<comment>Mod:</comment>");
     $table = new Table($output);
     $table->setRows($rows)->setStyle('compact')->render();
 }
開發者ID:indemnity83,項目名稱:mcmod,代碼行數:36,代碼來源:ModCommand.php

示例9: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $dateTime = new \DateTime($input->getArgument('date'));
     $event = new TicketEvent($input->getArgument('from'), $input->getArgument('to'), $dateTime);
     $salePerson = $this->getContainer()->get('sale');
     $salePerson->checkAvailableTicket($event);
 }
開發者ID:eugenegp,項目名稱:uzticketstat,代碼行數:7,代碼來源:BookindLoadCommand.php

示例10: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $login = $input->getArgument("login");
     $helper = $this->getHelper('question');
     $question = new Question("Unix password for « {$login} » : ");
     $question->setHidden(true);
     $question->setHiddenFallback(false);
     $password = $input->getArgument("password") ? $input->getArgument("password") : $helper->ask($input, $output, $question);
     $blih = new Blih($login, $password);
     $blihRepositoriesResponse = $blih->repository()->all();
     if ($blihRepositoriesResponse->code == 200) {
         $user = $this->getUserOrCreateIt($login);
         $repositoryNames = array_keys(get_object_vars($blihRepositoriesResponse->body->repositories));
         foreach ($repositoryNames as $repositoryName) {
             $output->writeln("> Repository « {$login}/{$repositoryName} »");
             $repository = $this->getRepoOrCreateIt($user, $repositoryName);
             $aclResponse = $blih->repository($repositoryName)->acl()->get();
             if ($aclResponse->code == 200) {
                 $acls = get_object_vars($aclResponse->body);
                 foreach ($acls as $aclLogin => $acl) {
                     $output->writeln("  ACL for « {$aclLogin} »: {$acl}");
                     $aclUser = $this->getUserOrCreateIt($aclLogin);
                     $repositoryACL = $this->getACLOrCreateIt($aclUser, $repository);
                     $repositoryACL->setR(strpos($acl, "r") !== false);
                     $repositoryACL->setW(strpos($acl, "w") !== false);
                     $repositoryACL->setA(strpos($acl, "a") !== false);
                     $this->getContainer()->get("doctrine")->getManager()->persist($repositoryACL);
                 }
             }
             $output->writeln("");
             $this->getContainer()->get("doctrine")->getManager()->persist($repository);
             $this->getContainer()->get("doctrine")->getManager()->flush();
         }
     }
 }
開發者ID:Raphy,項目名稱:BlihWI,代碼行數:35,代碼來源:BlihUpdateCommand.php

示例11: extractArguments

 /**
  * @param InputInterface $input
  * @param string         $file
  * @return int
  */
 protected function extractArguments(InputInterface $input, &$file)
 {
     $file = $input->getArgument('path');
     $count = $input->getArgument('includeFirstLine');
     $counter = null === $count ? 0 : 1;
     return $counter;
 }
開發者ID:TransformCore,項目名稱:HayPersistenceApi,代碼行數:12,代碼來源:CommandBase.php

示例12: askPassword

 protected function askPassword(InputInterface $input, OutputInterface $output, $encoder, $properties)
 {
     $encoder = $this->createEncoder($properties);
     $dialog = $this->getHelperSet()->get('dialog');
     $verified = true;
     do {
         if ($verified === false) {
             $output->writeln("<error>Passwords are not the same.</error>");
         }
         if ($input->getArgument('password')) {
             $password = $input->getArgument('password');
         } else {
             $password = $dialog->askHiddenResponse($output, "<question>Password:</question> ");
             if ($input->getOption('check-password')) {
                 $repeat = $dialog->askHiddenResponse($output, "<question>Repeat password:</question> ");
                 $verified = $repeat === $password;
             }
         }
     } while ($verified === false);
     if ($input->getOption('ask-salt')) {
         $salt = $dialog->ask($output, "<question>Salt:</question> ");
     } else {
         $salt = hash('sha256', $this->getSecureRandom()->nextBytes(32));
         $output->writeln("<info>A salt was generated for you:</info>");
         $output->writeln($salt);
     }
     $output->writeln("<info>The hashed password:</info>");
     $output->writeln($encoder->encodePassword($password, 'blurp'));
 }
開發者ID:tweedegolf,項目名稱:generatorbundle,代碼行數:29,代碼來源:HashPasswordCommand.php

示例13: execute

 /**
  * {@inheritdoc}
  *
  * @throws \InvalidArgumentException When the target directory does not exist or symlink cannot be used
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $targetArg = rtrim($input->getArgument('target'), '/');
     if (!is_dir($targetArg)) {
         throw new \InvalidArgumentException(sprintf('The target directory "%s" does not exist.', $input->getArgument('target')));
     }
     if (!function_exists('symlink') && $input->getOption('symlink')) {
         throw new \InvalidArgumentException('The symlink() function is not available on your system. You need to install the assets without the --symlink option.');
     }
     $filesystem = $this->getContainer()->get('filesystem');
     // Create the bundles directory otherwise symlink will fail.
     $bundlesDir = $targetArg . '/bundles/';
     $filesystem->mkdir($bundlesDir, 0777);
     $output->writeln(sprintf('Installing assets using the <comment>%s</comment> option', $input->getOption('symlink') ? 'symlink' : 'hard copy'));
     foreach ($this->getContainer()->get('kernel')->getBundles() as $bundle) {
         if (is_dir($originDir = $bundle->getPath() . '/Resources/public')) {
             $targetDir = $bundlesDir . preg_replace('/bundle$/', '', strtolower($bundle->getName()));
             $output->writeln(sprintf('Installing assets for <comment>%s</comment> into <comment>%s</comment>', $bundle->getNamespace(), $targetDir));
             $filesystem->remove($targetDir);
             if ($input->getOption('symlink')) {
                 if ($input->getOption('relative')) {
                     $relativeOriginDir = $filesystem->makePathRelative($originDir, realpath($bundlesDir));
                 } else {
                     $relativeOriginDir = $originDir;
                 }
                 $filesystem->symlink($relativeOriginDir, $targetDir);
             } else {
                 $filesystem->mkdir($targetDir, 0777);
                 // We use a custom iterator to ignore VCS files
                 $filesystem->mirror($originDir, $targetDir, Finder::create()->ignoreDotFiles(false)->in($originDir));
             }
         }
     }
 }
開發者ID:mkemiche,項目名稱:Annuaire,代碼行數:39,代碼來源:AssetsInstallCommand.php

示例14: execute

 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $configName = $input->getArgument('config-name');
     $editor = $input->getArgument('editor');
     $config = $this->getConfigFactory()->getEditable($configName);
     $configSystem = $this->getConfigFactory()->get('system.file');
     $temporalyDirectory = $configSystem->get('path.temporary') ?: '/tmp';
     $configFile = $temporalyDirectory . '/config-edit/' . $configName . '.yml';
     $ymlFile = new Parser();
     $fileSystem = new Filesystem();
     try {
         $fileSystem->mkdir($temporalyDirectory);
         $fileSystem->dumpFile($configFile, $this->getYamlConfig($configName));
     } catch (IOExceptionInterface $e) {
         throw new \Exception($this->trans('commands.config.edit.messages.no-directory') . ' ' . $e->getPath());
     }
     if (!$editor) {
         $editor = $this->getEditor();
     }
     $processBuilder = new ProcessBuilder(array($editor, $configFile));
     $process = $processBuilder->getProcess();
     $process->setTty('true');
     $process->run();
     if ($process->isSuccessful()) {
         $value = $ymlFile->parse(file_get_contents($configFile));
         $config->setData($value);
         $config->save();
         $fileSystem->remove($configFile);
     }
     if (!$process->isSuccessful()) {
         throw new \RuntimeException($process->getErrorOutput());
     }
 }
開發者ID:amira2r,項目名稱:DrupalConsole,代碼行數:36,代碼來源:ConfigEditCommand.php

示例15: execute

 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $em = $this->getHelper('em')->getEntityManager();
     $metadatas = $em->getMetadataFactory()->getAllMetadata();
     $metadatas = MetadataFilter::filter($metadatas, $input->getOption('filter'));
     $repositoryName = $em->getConfiguration()->getDefaultRepositoryClassName();
     // Process destination directory
     $destPath = realpath($input->getArgument('dest-path'));
     if (!file_exists($destPath)) {
         throw new \InvalidArgumentException(sprintf("Entities destination directory '<info>%s</info>' does not exist.", $input->getArgument('dest-path')));
     }
     if (!is_writable($destPath)) {
         throw new \InvalidArgumentException(sprintf("Entities destination directory '<info>%s</info>' does not have write permissions.", $destPath));
     }
     if (count($metadatas)) {
         $numRepositories = 0;
         $generator = new EntityRepositoryGenerator();
         $generator->setDefaultRepositoryName($repositoryName);
         foreach ($metadatas as $metadata) {
             if ($metadata->customRepositoryClassName) {
                 $output->writeln(sprintf('Processing repository "<info>%s</info>"', $metadata->customRepositoryClassName));
                 $generator->writeEntityRepositoryClass($metadata->customRepositoryClassName, $destPath);
                 $numRepositories++;
             }
         }
         if ($numRepositories) {
             // Outputting information message
             $output->writeln(PHP_EOL . sprintf('Repository classes generated to "<info>%s</INFO>"', $destPath));
         } else {
             $output->writeln('No Repository classes were found to be processed.');
         }
     } else {
         $output->writeln('No Metadata Classes to process.');
     }
 }
開發者ID:BusinessCookies,項目名稱:CoffeeMachineProject,代碼行數:38,代碼來源:GenerateRepositoriesCommand.php


注:本文中的Symfony\Component\Console\Input\InputInterface::getArgument方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。