Cleaned a bit the TableDrop command

This commit is contained in:
Kévin Gomez 2013-11-04 21:32:14 +00:00
parent 53db41026b
commit 2b7cbeacfb
3 changed files with 56 additions and 47 deletions

View file

@ -44,6 +44,10 @@ abstract class AbstractCommand extends ContainerAwareCommand
*/
protected $input;
use FormattingHelpers;
/**
* {@inheritdoc}
*/
@ -380,36 +384,6 @@ EOT;
return $this->cacheDir;
}
/**
* Comes from the SensioGeneratorBundle.
* @see https://github.com/sensio/SensioGeneratorBundle/blob/master/Command/Helper/DialogHelper.php#L52
*
* @param OutputInterface $output The output.
* @param string $text A text message.
* @param string $style A style to apply on the section.
*/
protected function writeSection(OutputInterface $output, $text, $style = 'bg=blue;fg=white')
{
$output->writeln(array(
'',
$this->getHelperSet()->get('formatter')->formatBlock($text, $style, true),
'',
));
}
/**
* Ask confirmation from the user.
*
* @param OutputInterface $output The output.
* @param string $question A given question.
* @param string $default A default response.
*/
protected function askConfirmation(OutputInterface $output, $question, $default = null)
{
return $this->getHelperSet()->get('dialog')->askConfirmation($output, $question, $default);
}
protected function arrayToIni(array $data)
{
$lines = array();

View file

@ -0,0 +1,48 @@
<?php
/**
* This file is part of the PropelBundle package.
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @license MIT License
*/
namespace Propel\PropelBundle\Command;
use Symfony\Component\Console\Output\OutputInterface;
/**
* @author Kévin Gomez <contact@kevingomez.fr>
*/
trait FormattingHelpers
{
/**
* Comes from the SensioGeneratorBundle.
* @see https://github.com/sensio/SensioGeneratorBundle/blob/master/Command/Helper/DialogHelper.php#L52
*
* @param OutputInterface $output The output.
* @param string $text A text message.
* @param string $style A style to apply on the section.
*/
protected function writeSection(OutputInterface $output, $text, $style = 'bg=blue;fg=white')
{
$output->writeln(array(
'',
$this->getHelperSet()->get('formatter')->formatBlock($text, $style, true),
'',
));
}
/**
* Ask confirmation from the user.
*
* @param OutputInterface $output The output.
* @param string $question A given question.
* @param string $default A default response.
*/
protected function askConfirmation(OutputInterface $output, $question, $default = null)
{
return $this->getHelperSet()->get('dialog')->askConfirmation($output, $question, $default);
}
}

View file

@ -11,6 +11,7 @@
namespace Propel\PropelBundle\Command;
use Propel\Runtime\Propel;
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
@ -19,8 +20,10 @@ use Symfony\Component\Console\Output\OutputInterface;
/**
* @author Kévin Gomez <contact@kevingomez.fr>
*/
class TableDropCommand extends AbstractCommand
class TableDropCommand extends ContainerAwareCommand
{
use FormattingHelpers;
/**
* {@inheritdoc}
*/
@ -110,20 +113,4 @@ class TableDropCommand extends AbstractCommand
), 'fg=white;bg=red');
}
}
/**
* {@inheritdoc}
*/
protected function createSubCommandInstance()
{
// useless for this command
}
/**
* {@inheritdoc}
*/
protected function getSubCommandArguments(InputInterface $input)
{
// useless for this command
}
}