本文整理汇总了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);
}
}
}
}
}
示例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')));
}
}
示例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>');
}
}
示例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());
}
}
示例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()));
}
}
示例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();
}
示例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();
}
示例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;
}
示例9: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
$this->input = $input;
$this->output = $output;
$output->writeln('called');
}
示例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');
}
}
示例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');
}
}
示例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);
}
}
}
}
}
示例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()}");
}
}
示例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);
}
}
示例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;
}