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


PHP Input\InputInterface类代码示例

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


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

示例1: _getMigrationConfiguration

 protected function _getMigrationConfiguration(InputInterface $input, OutputInterface $output)
 {
     if (!$this->_configuration) {
         $outputWriter = new OutputWriter(function ($message) use($output) {
             return $output->writeln($message);
         });
         $em = $this->getHelper('em')->getEntityManager();
         if ($input->getOption('configuration')) {
             $info = pathinfo($input->getOption('configuration'));
             $class = $info['extension'] === 'xml' ? 'Doctrine\\DBAL\\Migrations\\Configuration\\XmlConfiguration' : 'Doctrine\\DBAL\\Migrations\\Configuration\\YamlConfiguration';
             $configuration = new $class($em->getConnection(), $outputWriter);
             $configuration->load($input->getOption('configuration'));
         } else {
             if (file_exists('migrations.xml')) {
                 $configuration = new XmlConfiguration($em->getConnection(), $outputWriter);
                 $configuration->load('migrations.xml');
             } else {
                 if (file_exists('migrations.yml')) {
                     $configuration = new YamlConfiguration($em->getConnection(), $outputWriter);
                     $configuration->load('migrations.yml');
                 } else {
                     $configuration = new Configuration($em->getConnection(), $outputWriter);
                 }
             }
         }
         $this->_configuration = $configuration;
     }
     return $this->_configuration;
 }
开发者ID:poulikov,项目名称:readlater,代码行数:29,代码来源:AbstractCommand.php

示例2: execute

 /**
  * @see Command
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $selector = $input->getArgument('selector');
     if (!$selector) {
         $containers = $this->application->getController()->getContainers();
     } else {
         $containers = $this->application->getController()->selectContainers($selector);
     }
     $l = Formatter::calculateNamelength($containers) + 1;
     $FORMAT = "%{$l}s %s\n";
     printf($FORMAT, 'Name', 'Tags');
     array_walk($containers, function (&$container, $key) use($FORMAT) {
         $tags = $container->getTags();
         if (empty($tags)) {
             vprintf($FORMAT, array($container->getName(), '<none>'));
         }
         foreach ($tags as $key => $tag) {
             if ($key === 0) {
                 vprintf($FORMAT, array($container->getName(), $tag));
             } else {
                 vprintf($FORMAT, array('', $tag));
             }
         }
     });
 }
开发者ID:KernelMadness,项目名称:ContainerKit,代码行数:28,代码来源:TagListCommand.php

示例3: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $filterBundle = $input->getOption('bundle') ? str_replace('/', '\\', $input->getOption('bundle')) : false;
     $filterEntity = $filterBundle ? $filterBundle . '\\Entities\\' . str_replace('/', '\\', $input->getOption('entity')) : false;
     if (!isset($filterBundle) && isset($filterEntity)) {
         throw new \InvalidArgumentException(sprintf('Unable to specify an entity without also specifying a bundle.'));
     }
     $entityGenerator = $this->getEntityGenerator();
     $bundleDirs = $this->container->getKernelService()->getBundleDirs();
     foreach ($this->container->getKernelService()->getBundles() as $bundle) {
         $tmp = dirname(str_replace('\\', '/', get_class($bundle)));
         $namespace = str_replace('/', '\\', dirname($tmp));
         $class = basename($tmp);
         if ($filterBundle && $filterBundle != $namespace . '\\' . $class) {
             continue;
         }
         if (isset($bundleDirs[$namespace])) {
             $destination = realpath($bundleDirs[$namespace] . '/..');
             if ($metadatas = $this->getBundleMetadatas($bundle)) {
                 $output->writeln(sprintf('Generating entities for "<info>%s</info>"', $class));
                 foreach ($metadatas as $metadata) {
                     if ($filterEntity && strpos($metadata->name, $filterEntity) !== 0) {
                         continue;
                     }
                     $output->writeln(sprintf('  > generating <comment>%s</comment>', $metadata->name));
                     $entityGenerator->generate(array($metadata), $destination);
                 }
             }
         }
     }
 }
开发者ID:khalid05,项目名称:symfony,代码行数:31,代码来源:GenerateEntitiesDoctrineCommand.php

示例4: execute

 /**
  * @see Console\Command\Command
  */
 protected function execute(Console\Input\InputInterface $input, Console\Output\OutputInterface $output)
 {
     $em = $this->getHelper('em')->getEntityManager();
     $metadatas = $em->getMetadataFactory()->getAllMetadata();
     $metadatas = MetadataFilter::filter($metadatas, $input->getOption('filter'));
     // Process destination directory
     if (($destPath = $input->getArgument('dest-path')) === null) {
         $destPath = $em->getConfiguration()->getProxyDir();
     }
     if (!is_dir($destPath)) {
         mkdir($destPath, 0777, true);
     }
     $destPath = realpath($destPath);
     if (!file_exists($destPath)) {
         throw new \InvalidArgumentException(sprintf("Proxies destination directory '<info>%s</info>' does not exist.", $destPath));
     } else {
         if (!is_writable($destPath)) {
             throw new \InvalidArgumentException(sprintf("Proxies destination directory '<info>%s</info>' does not have write permissions.", $destPath));
         }
     }
     if (count($metadatas)) {
         foreach ($metadatas as $metadata) {
             $output->write(sprintf('Processing entity "<info>%s</info>"', $metadata->name) . PHP_EOL);
         }
         // Generating Proxies
         $em->getProxyFactory()->generateProxyClasses($metadatas, $destPath);
         // Outputting information message
         $output->write(PHP_EOL . sprintf('Proxy classes generated to "<info>%s</INFO>"', $destPath) . PHP_EOL);
     } else {
         $output->write('No Metadata Classes to process.' . PHP_EOL);
     }
 }
开发者ID:jacques-sounvi,项目名称:addressbook,代码行数:35,代码来源:GenerateProxiesCommand.php

示例5: execute

 /**
  * @see Console\Command\Command
  */
 protected function execute(Console\Input\InputInterface $input, Console\Output\OutputInterface $output)
 {
     $em = $this->getHelper('em')->getEntityManager();
     $metadatas = $em->getMetadataFactory()->getAllMetadata();
     $metadatas = MetadataFilter::filter($metadatas, $input->getOption('filter'));
     // 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.", $destPath));
     } else {
         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();
         foreach ($metadatas as $metadata) {
             if ($metadata->customRepositoryClassName) {
                 $output->write(sprintf('Processing repository "<info>%s</info>"', $metadata->customRepositoryClassName) . PHP_EOL);
                 $generator->writeEntityRepositoryClass($metadata->customRepositoryClassName, $destPath);
                 $numRepositories++;
             }
         }
         if ($numRepositories) {
             // Outputting information message
             $output->write(PHP_EOL . sprintf('Repository classes generated to "<info>%s</INFO>"', $destPath) . PHP_EOL);
         } else {
             $output->write('No Repository classes were found to be processed.' . PHP_EOL);
         }
     } else {
         $output->write('No Metadata Classes to process.' . PHP_EOL);
     }
 }
开发者ID:jacques-sounvi,项目名称:addressbook,代码行数:37,代码来源:GenerateRepositoriesCommand.php

示例6: execute

 /**
  * @see Command
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $selector = $input->getArgument('selector');
     $this->application->getController()->restart($selector, function ($message) {
         echo \Console_Color::convert(" %g>>%n ") . $message . "\n";
     });
 }
开发者ID:KernelMadness,项目名称:ContainerKit,代码行数:10,代码来源:RestartCommand.php

示例7: execute

 public function execute(InputInterface $input, OutputInterface $output)
 {
     DoctrineCommand::setApplicationEntityManager($this->application, $input->getOption('em'));
     $configuration = $this->_getMigrationConfiguration($input, $output);
     DoctrineCommand::configureMigrationsForBundle($this->application, $input->getOption('bundle'), $configuration);
     parent::execute($input, $output);
 }
开发者ID:jacques-sounvi,项目名称:addressbook,代码行数:7,代码来源:MigrationsMigrateDoctrineCommand.php

示例8: execute

 /**
  * @see Console\Command\Command
  */
 protected function execute(Console\Input\InputInterface $input, Console\Output\OutputInterface $output)
 {
     $em = $this->getHelper('em')->getEntityManager();
     $cacheDriver = $em->getConfiguration()->getResultCacheImpl();
     if (!$cacheDriver) {
         throw new \InvalidArgumentException('No Result cache driver is configured on given EntityManager.');
     }
     $outputed = false;
     // Removing based on --id
     if (($ids = $input->getOption('id')) !== null && $ids) {
         foreach ($ids as $id) {
             $output->write($outputed ? PHP_EOL : '');
             $output->write(sprintf('Clearing Result cache entries that match the id "<info>%s</info>"', $id) . PHP_EOL);
             $deleted = $cacheDriver->delete($id);
             if (is_array($deleted)) {
                 $this->_printDeleted($output, $deleted);
             } else {
                 if (is_bool($deleted) && $deleted) {
                     $this->_printDeleted($output, array($id));
                 }
             }
             $outputed = true;
         }
     }
     // Removing based on --regex
     if (($regexps = $input->getOption('regex')) !== null && $regexps) {
         foreach ($regexps as $regex) {
             $output->write($outputed ? PHP_EOL : '');
             $output->write(sprintf('Clearing Result cache entries that match the regular expression "<info>%s</info>"', $regex) . PHP_EOL);
             $this->_printDeleted($output, $cacheDriver->deleteByRegex('/' . $regex . '/'));
             $outputed = true;
         }
     }
     // Removing based on --prefix
     if (($prefixes = $input->getOption('prefix')) !== null & $prefixes) {
         foreach ($prefixes as $prefix) {
             $output->write($outputed ? PHP_EOL : '');
             $output->write(sprintf('Clearing Result cache entries that have the prefix "<info>%s</info>"', $prefix) . PHP_EOL);
             $this->_printDeleted($output, $cacheDriver->deleteByPrefix($prefix));
             $outputed = true;
         }
     }
     // Removing based on --suffix
     if (($suffixes = $input->getOption('suffix')) !== null && $suffixes) {
         foreach ($suffixes as $suffix) {
             $output->write($outputed ? PHP_EOL : '');
             $output->write(sprintf('Clearing Result cache entries that have the suffix "<info>%s</info>"', $suffix) . PHP_EOL);
             $this->_printDeleted($output, $cacheDriver->deleteBySuffix($suffix));
             $outputed = true;
         }
     }
     // Removing ALL entries
     if (!$ids && !$regexps && !$prefixes && !$suffixes) {
         $output->write($outputed ? PHP_EOL : '');
         $output->write('Clearing ALL Result cache entries' . PHP_EOL);
         $this->_printDeleted($output, $cacheDriver->deleteAll());
         $outputed = true;
     }
 }
开发者ID:jacques-sounvi,项目名称:addressbook,代码行数:62,代码来源:ResultCommand.php

示例9: initialize

 /**
  * @see Command
  */
 protected function initialize(InputInterface $input, OutputInterface $output)
 {
     $this->container = $this->application->getKernel()->getContainer();
     $this->server = $this->container->getServerService();
     if (!$input->getOption('verbose')) {
         $this->server->setConsole(new Console($output));
     }
 }
开发者ID:avalanche123,项目名称:ServerBundle,代码行数:11,代码来源:Command.php

示例10: execute

 protected function execute(Input\InputInterface $input, Output\OutputInterface $output)
 {
     try {
         $output->writeln('<info>' . $this->runIndexUpdates($input->getOption('mode'), $input->getOption('class')) . '</info>');
     } catch (\Exception $e) {
         $output->writeln('<error>' . $e->getMessage() . '</error>');
     }
 }
开发者ID:skoop,项目名称:symfony-sandbox,代码行数:8,代码来源:IndexesCommand.php

示例11: execute

 /**
  * @see Command
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     if ($input->getOption('xml')) {
         $output->writeln($this->application->asXml($input->getArgument('namespace')), Output::OUTPUT_RAW);
     } else {
         $output->writeln($this->application->asText($input->getArgument('namespace')));
     }
 }
开发者ID:skoop,项目名称:symfony-sandbox,代码行数:11,代码来源:ListCommand.php

示例12: 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 (true === $input->hasParameterOption(array('--shell', '-s'))) {
         $shell = new Shell($this);
         $shell->run();
         return 0;
     }
     return parent::doRun($input, $output);
 }
开发者ID:pgodel,项目名称:PageRoller,代码行数:17,代码来源:Application.php

示例13: execute

 /**
  * @see Command
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $selector = $input->getArgument('selector');
     $tag = $input->getArgument('tag');
     $containers = $this->application->getController()->selectContainers($selector);
     array_walk($containers, function (&$container, $key, $tag) {
         $container->addTag($tag);
     }, $tag);
 }
开发者ID:KernelMadness,项目名称:ContainerKit,代码行数:12,代码来源:TagAddCommand.php

示例14: execute

 /**
  * @see Command
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $name = $input->getArgument('name');
     $ip = $input->getArgument('ip');
     $container = $this->application->getController()->getContainer($name);
     if (!$container) {
         throw new \Exception('Container does not exists!');
     }
     $container->addAllowedIp($ip);
 }
开发者ID:KernelMadness,项目名称:ContainerKit,代码行数:13,代码来源:IpAddCommand.php

示例15: execute

 /**
  * @throws \InvalidArgumentException When the bundle doesn't end with Bundle (Example: "Bundle\MySampleBundle")
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     if (!preg_match('/Bundle$/', $bundle = $input->getArgument('bundle'))) {
         throw new \InvalidArgumentException('The bundle name must end with Bundle. Example: "Bundle\\MySampleBundle".');
     }
     $dirs = $this->container->getKernelService()->getBundleDirs();
     $tmp = str_replace('\\', '/', $bundle);
     $namespace = str_replace('/', '\\', dirname($tmp));
     $bundle = basename($tmp);
     if (!isset($dirs[$namespace])) {
         throw new \InvalidArgumentException(sprintf('Unable to initialize the bundle entity (%s not defined).', $namespace));
     }
     $entity = $input->getArgument('entity');
     $entityNamespace = $namespace . '\\' . $bundle . '\\Entities';
     $fullEntityClassName = $entityNamespace . '\\' . $entity;
     $tmp = str_replace('\\', '/', $fullEntityClassName);
     $tmp = str_replace('/', '\\', dirname($tmp));
     $className = basename($tmp);
     $mappingType = $input->getOption('mapping-type');
     $mappingType = $mappingType ? $mappingType : 'xml';
     $class = new ClassMetadataInfo($fullEntityClassName);
     $class->mapField(array('fieldName' => 'id', 'type' => 'integer', 'id' => true));
     $class->setIdGeneratorType(ClassMetadataInfo::GENERATOR_TYPE_AUTO);
     // Map the specified fields
     $fields = $input->getOption('fields');
     if ($fields) {
         $e = explode(' ', $fields);
         foreach ($e as $value) {
             $e = explode(':', $value);
             $name = $e[0];
             $type = isset($e[1]) ? $e[1] : 'string';
             preg_match_all('/(.*)\\((.*)\\)/', $type, $matches);
             $type = isset($matches[1][0]) ? $matches[1][0] : 'string';
             $length = isset($matches[2][0]) ? $matches[2][0] : null;
             $class->mapField(array('fieldName' => $name, 'type' => $type, 'length' => $length));
         }
     }
     // Setup a new exporter for the mapping type specified
     $cme = new ClassMetadataExporter();
     $exporter = $cme->getExporter($mappingType);
     if ($mappingType === 'annotation') {
         $path = $dirs[$namespace] . '/' . $bundle . '/Entities/' . str_replace($entityNamespace . '\\', null, $fullEntityClassName) . '.php';
         $exporter->setEntityGenerator($this->getEntityGenerator());
     } else {
         $mappingType = $mappingType == 'yaml' ? 'yml' : $mappingType;
         $path = $dirs[$namespace] . '/' . $bundle . '/Resources/config/doctrine/metadata/' . str_replace('\\', '.', $fullEntityClassName) . '.dcm.' . $mappingType;
     }
     $code = $exporter->exportClassMetadata($class);
     if (!is_dir($dir = dirname($path))) {
         mkdir($dir, 0777, true);
     }
     $output->writeln(sprintf('Generating entity for "<info>%s</info>"', $bundle));
     $output->writeln(sprintf('  > generating <comment>%s</comment>', $fullEntityClassName));
     file_put_contents($path, $code);
 }
开发者ID:khalid05,项目名称:symfony,代码行数:58,代码来源:GenerateEntityDoctrineCommand.php


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