diff --git a/Command/DatabaseDropCommand.php b/Command/DatabaseDropCommand.php index 2c645b2..80fa856 100644 --- a/Command/DatabaseDropCommand.php +++ b/Command/DatabaseDropCommand.php @@ -61,7 +61,7 @@ EOT if ('prod' === $this->getApplication()->getKernel()->getEnvironment()) { $this->writeSection($output, 'WARNING: you are about to drop a database in production !', 'bg=red;fg=white'); - if (false === $this->askConfirmation($output, 'Are you sure ? (y/n) ', false)) { + if (false === $this->askConfirmation($input, $output, 'Are you sure ? (y/n) ', false)) { $output->writeln('Aborted, nice decision !'); return -2; diff --git a/Command/FixturesDumpCommand.php b/Command/FixturesDumpCommand.php index ab855dc..36af2ef 100644 --- a/Command/FixturesDumpCommand.php +++ b/Command/FixturesDumpCommand.php @@ -62,7 +62,7 @@ EOT if (!file_exists($path)) { $output->writeln("The $path folder does not exists."); - if ($this->askConfirmation($output, "Do you want me to create it for you ? [Yes]")) { + if ($this->askConfirmation($input, $output, "Do you want me to create it for you ? [Yes]")) { $fs = new Filesystem(); $fs->mkdir($path); $this->writeNewDirectory($output, $path); diff --git a/Command/FormattingHelpers.php b/Command/FormattingHelpers.php index 9dfdb2e..fc4bea0 100644 --- a/Command/FormattingHelpers.php +++ b/Command/FormattingHelpers.php @@ -10,7 +10,9 @@ namespace Propel\Bundle\PropelBundle\Command; +use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; +use Symfony\Component\Console\Question\Question; /** * @author Kévin Gomez @@ -35,15 +37,29 @@ trait FormattingHelpers } /** - * Ask confirmation from the user. + * Asks a confirmation to the user. * - * @param OutputInterface $output The output. - * @param string $question A given question. - * @param string $default A default response. + * The question will be asked until the user answers by nothing, yes, or no. + * + * @param InputInterface $input An Input instance + * @param OutputInterface $output An Output instance + * @param string|array $question The question to ask + * @param bool $default The default answer if the user enters nothing + * + * @return bool true if the user has confirmed, false otherwise */ - protected function askConfirmation(OutputInterface $output, $question, $default = null) + protected function askConfirmation(InputInterface $input, OutputInterface $output, $question, $default = true) { - return $this->getHelperSet()->get('dialog')->askConfirmation($output, $question, $default); + $question = new Question($question); + do { + $answer = $this->getHelperSet()->get('question')->ask($input, $output, $question); + } while ($answer && !in_array(strtolower($answer[0]), array('y', 'n'))); + + if (false === $default) { + return $answer && 'y' == strtolower($answer[0]); + } + + return !$answer || 'y' == strtolower($answer[0]); } /** @@ -75,7 +91,7 @@ trait FormattingHelpers { $moreText = $more ? ' To get more details, run the command with the "--verbose" option.' : ''; - return $this->writeSection($output, array( + $this->writeSection($output, array( '[Propel] Error', '', 'An error has occured during the "' . $taskName . '" task process.' . $moreText diff --git a/Command/TableDropCommand.php b/Command/TableDropCommand.php index dab8d4c..e6e48a4 100644 --- a/Command/TableDropCommand.php +++ b/Command/TableDropCommand.php @@ -69,7 +69,7 @@ class TableDropCommand extends ContainerAwareCommand 'bg=red;fg=white' ); - if (false === $this->askConfirmation($output, 'Are you sure ? (y/n) ', false)) { + if (false === $this->askConfirmation($input, $output, 'Are you sure ? (y/n) ', false)) { $output->writeln('Aborted, nice decision !'); return -2; diff --git a/Controller/PanelController.php b/Controller/PanelController.php index a03fd4a..08b6b07 100644 --- a/Controller/PanelController.php +++ b/Controller/PanelController.php @@ -11,7 +11,8 @@ namespace Propel\Bundle\PropelBundle\Controller; use Propel\Runtime\Propel; -use Symfony\Component\DependencyInjection\ContainerAware; +use Symfony\Component\DependencyInjection\ContainerAwareInterface; +use Symfony\Component\DependencyInjection\ContainerAwareTrait; use Symfony\Component\HttpFoundation\Response; /** @@ -19,8 +20,10 @@ use Symfony\Component\HttpFoundation\Response; * * @author William DURAND */ -class PanelController extends ContainerAware +class PanelController implements ContainerAwareInterface { + use ContainerAwareTrait; + /** * This method renders the global Propel configuration. */ @@ -45,7 +48,7 @@ class PanelController extends ContainerAware * @param string $connection The connection name * @param integer $query * - * @return Symfony\Component\HttpFoundation\Response A Response instance + * @return Response A Response instance */ public function explainAction($token, $connection, $query) { diff --git a/Resources/views/Collector/propel.html.twig b/Resources/views/Collector/propel.html.twig index d261e14..d824f42 100644 --- a/Resources/views/Collector/propel.html.twig +++ b/Resources/views/Collector/propel.html.twig @@ -115,12 +115,12 @@ {{ query.sql|format_sql|raw }} {% if app.request.query.has('query') and app.request.query.get('query') == i %}
- {% render controller('PropelBundle:Panel:explain', { + {{ render(controller('PropelBundle:Panel:explain', { 'token': token, 'panel': 'propel', 'query': app.request.query.get('query'), 'connection': app.request.query.get('connection') - }) %} + })) }}
{% endif %}
@@ -149,5 +149,5 @@ - {% render controller('PropelBundle:Panel:configuration') %} + {{ render(controller('PropelBundle:Panel:configuration')) }} {% endblock %} diff --git a/composer.json b/composer.json index e7553a3..66416d3 100644 --- a/composer.json +++ b/composer.json @@ -8,19 +8,16 @@ "name": "William Durand", "email": "william.durand1@gmail.com" }], - - "autoload": { - "psr-4": { "Propel\\Bundle\\PropelBundle\\": "" }, - "exclude-from-classmap": [ "Tests/" ] - }, - "require": { - "propel/propel": "dev-master", - "symfony/symfony": "^2.8|^3.0" + "symfony/symfony": ">=2.5", + "propel/propel": "2.*@dev" }, "require-dev": { - "phpunit/phpunit": "^4.8.21|^5.0.10", - "sensio/framework-extra-bundle": "^3.0.2", - "fzaninotto/faker": "^1.5" + "sensio/framework-extra-bundle": "~3.0", + "phpunit/phpunit": "~4.0", + "fzaninotto/faker": "~1.1" + }, + "autoload": { + "psr-4": { "Propel\\PropelBundle\\": "" } } }