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


PHP OutputInterface::writeln方法代码示例

本文整理汇总了PHP中Symfony\Components\Console\Output\OutputInterface::writeln方法的典型用法代码示例。如果您正苦于以下问题:PHP OutputInterface::writeln方法的具体用法?PHP OutputInterface::writeln怎么用?PHP OutputInterface::writeln使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Symfony\Components\Console\Output\OutputInterface的用法示例。


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

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

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

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

示例4: execute

 /**
  * @see Command
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     if (null === $this->command) {
         $this->command = $this->application->getCommand($input->getArgument('command_name'));
     }
     if ($input->getOption('xml')) {
         $output->writeln($this->command->asXml(), Output::OUTPUT_RAW);
     } else {
         $output->writeln($this->command->asText());
     }
 }
开发者ID:poulikov,项目名称:readlater,代码行数:14,代码来源:HelpCommand.php

示例5: dropDatabaseForConnection

 protected function dropDatabaseForConnection(Connection $connection, OutputInterface $output)
 {
     $params = $connection->getParams();
     $name = isset($params['path']) ? $params['path'] : $params['dbname'];
     try {
         $connection->getSchemaManager()->dropDatabase($name);
         $output->writeln(sprintf('<info>Dropped database for connection named <comment>%s</comment></info>', $name));
     } catch (\Exception $e) {
         $output->writeln(sprintf('<error>Could not drop database for connection named <comment>%s</comment></error>', $name));
         $output->writeln(sprintf('<error>%s</error>', $e->getMessage()));
     }
 }
开发者ID:pgodel,项目名称:PageRoller,代码行数:12,代码来源:DropDatabaseDoctrineCommand.php

示例6: createDatabaseForConnection

 protected function createDatabaseForConnection(Connection $connection, OutputInterface $output)
 {
     $params = $connection->getParams();
     $name = isset($params['path']) ? $params['path'] : $params['dbname'];
     unset($params['dbname']);
     $tmpConnection = \Doctrine\DBAL\DriverManager::getConnection($params);
     try {
         $tmpConnection->getSchemaManager()->createDatabase($name);
         $output->writeln(sprintf('<info>Created database for connection named <comment>%s</comment></info>', $name));
     } catch (\Exception $e) {
         $output->writeln(sprintf('<error>Could not create database for connection named <comment>%s</comment></error>', $name));
         $output->writeln(sprintf('<error>%s</error>', $e->getMessage()));
     }
     $tmpConnection->close();
 }
开发者ID:robo47,项目名称:symfony,代码行数:15,代码来源:CreateDatabaseDoctrineCommand.php

示例7: execute

 protected function execute(Console\Input\InputInterface $input, Console\Output\OutputInterface $output)
 {
     $em = $this->getHelper('em')->getEntityManager();
     // Delete first
     $query = $em->createQuery('delete from BBM\\Play');
     $query->execute();
     $query = $em->createQuery('delete from BBM\\Game');
     $query->execute();
     $count = 0;
     $gameFactory = new GameFactory($em);
     $currec = array();
     if (($handle = fopen(DATADIR . "/game_events/2008ATL.EVN", "r")) !== FALSE) {
         while (($data = fgetcsv($handle)) !== FALSE) {
             if ($data[0] === 'id' && sizeof($currec) !== 0) {
                 $game = $gameFactory->createGameFromRetrosheetRecords($currec);
                 $em->persist($game);
                 if ($count % 10 == 0) {
                     $em->flush();
                     $em->clear();
                 }
                 $output->writeln($game);
                 unset($currec);
                 $count++;
             }
             $currec[] = $data;
         }
     }
     fclose($handle);
     $em->flush();
 }
开发者ID:jsuggs,项目名称:BBM_old,代码行数:30,代码来源:LoadGames.php

示例8: _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

示例9: execute

  protected function execute(InputInterface $input, OutputInterface $output)
  {
    $this->input = $input;
    $this->output = $output;

    $output->writeln('called');
  }
开发者ID:nicolasmartin,项目名称:symfony,代码行数:7,代码来源:FooCommand.php

示例10: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $bundleClass = null;
     $bundleDirs = $this->container->getKernelService()->getBundleDirs();
     foreach ($this->container->getKernelService()->getBundles() as $bundle) {
         if (strpos(get_class($bundle), $input->getArgument('bundle')) !== false) {
             $tmp = dirname(str_replace('\\', '/', get_class($bundle)));
             $namespace = str_replace('/', '\\', dirname($tmp));
             $class = basename($tmp);
             if (isset($bundleDirs[$namespace])) {
                 $destPath = realpath($bundleDirs[$namespace]) . '/' . $class;
                 $bundleClass = $class;
                 break;
             }
         }
     }
     $type = $input->getArgument('mapping-type') ? $input->getArgument('mapping-type') : 'xml';
     if ($type === 'annotation') {
         $destPath .= '/Entities';
     } else {
         $destPath .= '/Resources/config/doctrine/metadata';
     }
     $cme = new ClassMetadataExporter();
     $exporter = $cme->getExporter($type);
     if ($type === 'annotation') {
         $entityGenerator = $this->getEntityGenerator();
         $exporter->setEntityGenerator($entityGenerator);
     }
     $emName = $input->getOption('em') ? $input->getOption('em') : 'default';
     $emServiceName = sprintf('doctrine.orm.%s_entity_manager', $emName);
     $em = $this->container->getService($emServiceName);
     $databaseDriver = new DatabaseDriver($em->getConnection()->getSchemaManager());
     $em->getConfiguration()->setMetadataDriverImpl($databaseDriver);
     $cmf = new DisconnectedClassMetadataFactory($em);
     $metadata = $cmf->getAllMetadata();
     if ($metadata) {
         $output->writeln(sprintf('Importing mapping information from "<info>%s</info>" entity manager', $emName));
         $filesystem = new Filesystem();
         foreach ($metadata as $class) {
             $className = $class->name;
             $class->name = $namespace . '\\' . $bundleClass . '\\Entities\\' . $className;
             if ($type === 'annotation') {
                 $path = $destPath . '/' . $className . '.php';
             } else {
                 $path = $destPath . '/' . str_replace('\\', '.', $class->name) . '.dcm.xml';
             }
             $output->writeln(sprintf('  > writing <comment>%s</comment>', $path));
             $code = $exporter->exportClassMetadata($class);
             if (!is_dir($dir = dirname($path))) {
                 $filesystem->mkdirs($dir);
             }
             file_put_contents($path, $code);
         }
     } else {
         $output->writeln('Database does not have any mapping information.' . PHP_EOL, 'ERROR');
     }
 }
开发者ID:jarosz,项目名称:symfony,代码行数:57,代码来源:ImportMappingDoctrineCommand.php

示例11: execute

 /**
  * @see Command
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $bundleClass = null;
     $bundleDirs = $this->container->getKernelService()->getBundleDirs();
     foreach ($this->container->getKernelService()->getBundles() as $bundle) {
         if (strpos(get_class($bundle), $input->getArgument('bundle')) !== false) {
             $tmp = dirname(str_replace('\\', '/', get_class($bundle)));
             $namespace = str_replace('/', '\\', dirname($tmp));
             $class = basename($tmp);
             if (isset($bundleDirs[$namespace])) {
                 $destPath = realpath($bundleDirs[$namespace]) . '/' . $class;
                 $bundleClass = $class;
                 break;
             }
         }
     }
     $type = $input->getArgument('mapping-type') ? $input->getArgument('mapping-type') : 'xml';
     if ($type === 'annotation') {
         $destPath .= '/Entities';
     } else {
         $destPath .= '/Resources/config/doctrine/metadata';
     }
     // adjust so file naming works
     if ($type === 'yaml') {
         $type = 'yml';
     }
     $cme = new ClassMetadataExporter();
     $exporter = $cme->getExporter($type);
     if ($type === 'annotation') {
         $entityGenerator = $this->getEntityGenerator();
         $exporter->setEntityGenerator($entityGenerator);
     }
     $converter = new ConvertDoctrine1Schema($input->getArgument('d1-schema'));
     $metadata = $converter->getMetadata();
     if ($metadata) {
         $output->writeln(sprintf('Converting Doctrine 1 schema "<info>%s</info>"', $input->getArgument('d1-schema')));
         foreach ($metadata as $class) {
             $className = $class->name;
             $class->name = $namespace . '\\' . $bundleClass . '\\Entities\\' . $className;
             if ($type === 'annotation') {
                 $path = $destPath . '/' . $className . '.php';
             } else {
                 $path = $destPath . '/' . str_replace('\\', '.', $class->name) . '.dcm.' . $type;
             }
             $output->writeln(sprintf('  > writing <comment>%s</comment>', $path));
             $code = $exporter->exportClassMetadata($class);
             if (!is_dir($dir = dirname($path))) {
                 mkdir($dir, 0777, true);
             }
             file_put_contents($path, $code);
         }
     } else {
         $output->writeln('Database does not have any mapping information.' . PHP_EOL, 'ERROR');
     }
 }
开发者ID:khalid05,项目名称:symfony,代码行数:58,代码来源:ConvertDoctrine1SchemaDoctrineCommand.php

示例12: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $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 (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) {
                     $output->writeln(sprintf('  > generating <comment>%s</comment>', $metadata->name));
                     $entityGenerator->generate(array($metadata), $destination);
                 }
             }
         }
     }
 }
开发者ID:jacques-sounvi,项目名称:addressbook,代码行数:20,代码来源:GenerateEntitiesDoctrineCommand.php

示例13: execute

 /**
  * @see Command
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $name = $input->getArgument('name');
     $container = $this->application->getController()->getContainer($name);
     if (!$container) {
         $output->writeln("<error>Container {$name} does not exists</error>");
     } else {
         $editor = $this->application->getController()->getExecutable('editor');
         \ContainerKit\Console\Launcher::launch("{$editor} {$container->getConfigPath()}");
     }
 }
开发者ID:KernelMadness,项目名称:ContainerKit,代码行数:14,代码来源:EditCommand.php

示例14: execute

 protected function execute(Console\Input\InputInterface $input, Console\Output\OutputInterface $output)
 {
     $em = $this->getHelper('em')->getEntityManager();
     $playerRepository = new PlayerRepository($em);
     $pitchers = $playerRepository->getAllPitchers();
     $count = 0;
     $stats = array();
     foreach ($pitchers as $pitcher) {
         $output->writeln($pitcher);
         $matchups = $pitcher->getPitchingMatchupsAsPitcher();
         $runsAllowed = 0;
         $totalMatchups = 0;
         foreach ($matchups as $matchup) {
             $runsAllowed += $matchup->getRunsScored();
             //$output->writeln($matchup);
             $totalMatchups++;
         }
         $output->writeln('Total Matchups: ' . $totalMatchups);
         $output->writeln('Runs allowed: ' . $runsAllowed);
     }
 }
开发者ID:jsuggs,项目名称:BBM_old,代码行数:21,代码来源:ComputePitchingStats.php

示例15: _getMigrationConfiguration

 /**
  * @param InputInterface $input
  * @param OutputInterface $output
  * @return Configuration
  */
 protected function _getMigrationConfiguration(InputInterface $input, OutputInterface $output)
 {
     if (!$this->_configuration) {
         $outputWriter = new OutputWriter(function ($message) use($output) {
             return $output->writeln($message);
         });
         if ($this->application->getHelperSet()->has('db')) {
             $conn = $this->getHelper('db')->getConnection();
         } else {
             if ($input->getOption('db-configuration')) {
                 if (!file_exists($input->getOption('db-configuration'))) {
                     throw new \InvalidArgumentException("The specified connection file is a valid file.");
                 }
                 $params = (include $input->getOption('db-configuration'));
                 if (!is_array($params)) {
                     throw new \InvalidArgumentException('The connection file has to return an array with database configuration parameters.');
                 }
                 $conn = \Doctrine\DBAL\DriverManager::getConnection($params);
             } else {
                 if (file_exists('migrations-db.php')) {
                     $params = (include "migrations-db.php");
                     if (!is_array($params)) {
                         throw new \InvalidArgumentException('The connection file has to return an array with database configuration parameters.');
                     }
                     $conn = \Doctrine\DBAL\DriverManager::getConnection($params);
                 } else {
                     throw new \InvalidArgumentException('You have to specify a --db-configuration file or pass a Database Connection as a dependency to the Migrations.');
                 }
             }
         }
         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($conn, $outputWriter);
             $configuration->load($input->getOption('configuration'));
         } else {
             if (file_exists('migrations.xml')) {
                 $configuration = new XmlConfiguration($conn, $outputWriter);
                 $configuration->load('migrations.xml');
             } else {
                 if (file_exists('migrations.yml')) {
                     $configuration = new YamlConfiguration($conn, $outputWriter);
                     $configuration->load('migrations.yml');
                 } else {
                     $configuration = new Configuration($conn, $outputWriter);
                 }
             }
         }
         $this->_configuration = $configuration;
     }
     return $this->_configuration;
 }
开发者ID:klaasn,项目名称:symfony-sandbox,代码行数:57,代码来源:AbstractCommand.php


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