Merge pull request #396 from IceShack/2.0
Make PropelBundle available for Symfony 3.X
This commit is contained in:
commit
865599263e
|
@ -61,7 +61,7 @@ EOT
|
||||||
if ('prod' === $this->getApplication()->getKernel()->getEnvironment()) {
|
if ('prod' === $this->getApplication()->getKernel()->getEnvironment()) {
|
||||||
$this->writeSection($output, 'WARNING: you are about to drop a database in production !', 'bg=red;fg=white');
|
$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 !');
|
$output->writeln('Aborted, nice decision !');
|
||||||
|
|
||||||
return -2;
|
return -2;
|
||||||
|
|
|
@ -62,7 +62,7 @@ EOT
|
||||||
|
|
||||||
if (!file_exists($path)) {
|
if (!file_exists($path)) {
|
||||||
$output->writeln("<info>The $path folder does not exists.</info>");
|
$output->writeln("<info>The $path folder does not exists.</info>");
|
||||||
if ($this->askConfirmation($output, "<question>Do you want me to create it for you ?</question> [Yes]")) {
|
if ($this->askConfirmation($input, $output, "<question>Do you want me to create it for you ?</question> [Yes]")) {
|
||||||
$fs = new Filesystem();
|
$fs = new Filesystem();
|
||||||
$fs->mkdir($path);
|
$fs->mkdir($path);
|
||||||
$this->writeNewDirectory($output, $path);
|
$this->writeNewDirectory($output, $path);
|
||||||
|
|
|
@ -10,7 +10,9 @@
|
||||||
|
|
||||||
namespace Propel\Bundle\PropelBundle\Command;
|
namespace Propel\Bundle\PropelBundle\Command;
|
||||||
|
|
||||||
|
use Symfony\Component\Console\Input\InputInterface;
|
||||||
use Symfony\Component\Console\Output\OutputInterface;
|
use Symfony\Component\Console\Output\OutputInterface;
|
||||||
|
use Symfony\Component\Console\Question\Question;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Kévin Gomez <contact@kevingomez.fr>
|
* @author Kévin Gomez <contact@kevingomez.fr>
|
||||||
|
@ -35,15 +37,29 @@ trait FormattingHelpers
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Ask confirmation from the user.
|
* Asks a confirmation to the user.
|
||||||
*
|
*
|
||||||
* @param OutputInterface $output The output.
|
* The question will be asked until the user answers by nothing, yes, or no.
|
||||||
* @param string $question A given question.
|
*
|
||||||
* @param string $default A default response.
|
* @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.' : '';
|
$moreText = $more ? ' To get more details, run the command with the "--verbose" option.' : '';
|
||||||
|
|
||||||
return $this->writeSection($output, array(
|
$this->writeSection($output, array(
|
||||||
'[Propel] Error',
|
'[Propel] Error',
|
||||||
'',
|
'',
|
||||||
'An error has occured during the "' . $taskName . '" task process.' . $moreText
|
'An error has occured during the "' . $taskName . '" task process.' . $moreText
|
||||||
|
|
|
@ -69,7 +69,7 @@ class TableDropCommand extends ContainerAwareCommand
|
||||||
'bg=red;fg=white'
|
'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('<info>Aborted, nice decision !</info>');
|
$output->writeln('<info>Aborted, nice decision !</info>');
|
||||||
|
|
||||||
return -2;
|
return -2;
|
||||||
|
|
|
@ -11,7 +11,8 @@
|
||||||
namespace Propel\Bundle\PropelBundle\Controller;
|
namespace Propel\Bundle\PropelBundle\Controller;
|
||||||
|
|
||||||
use Propel\Runtime\Propel;
|
use Propel\Runtime\Propel;
|
||||||
use Symfony\Component\DependencyInjection\ContainerAware;
|
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
|
||||||
|
use Symfony\Component\DependencyInjection\ContainerAwareTrait;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -19,8 +20,10 @@ use Symfony\Component\HttpFoundation\Response;
|
||||||
*
|
*
|
||||||
* @author William DURAND <william.durand1@gmail.com>
|
* @author William DURAND <william.durand1@gmail.com>
|
||||||
*/
|
*/
|
||||||
class PanelController extends ContainerAware
|
class PanelController implements ContainerAwareInterface
|
||||||
{
|
{
|
||||||
|
use ContainerAwareTrait;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method renders the global Propel configuration.
|
* This method renders the global Propel configuration.
|
||||||
*/
|
*/
|
||||||
|
@ -45,7 +48,7 @@ class PanelController extends ContainerAware
|
||||||
* @param string $connection The connection name
|
* @param string $connection The connection name
|
||||||
* @param integer $query
|
* @param integer $query
|
||||||
*
|
*
|
||||||
* @return Symfony\Component\HttpFoundation\Response A Response instance
|
* @return Response A Response instance
|
||||||
*/
|
*/
|
||||||
public function explainAction($token, $connection, $query)
|
public function explainAction($token, $connection, $query)
|
||||||
{
|
{
|
||||||
|
|
|
@ -115,12 +115,12 @@
|
||||||
<code>{{ query.sql|format_sql|raw }}</code>
|
<code>{{ query.sql|format_sql|raw }}</code>
|
||||||
{% if app.request.query.has('query') and app.request.query.get('query') == i %}
|
{% if app.request.query.has('query') and app.request.query.get('query') == i %}
|
||||||
<div class="SQLExplain">
|
<div class="SQLExplain">
|
||||||
{% render controller('PropelBundle:Panel:explain', {
|
{{ render(controller('PropelBundle:Panel:explain', {
|
||||||
'token': token,
|
'token': token,
|
||||||
'panel': 'propel',
|
'panel': 'propel',
|
||||||
'query': app.request.query.get('query'),
|
'query': app.request.query.get('query'),
|
||||||
'connection': app.request.query.get('connection')
|
'connection': app.request.query.get('connection')
|
||||||
}) %}
|
})) }}
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<div class="SQLInfo">
|
<div class="SQLInfo">
|
||||||
|
@ -149,5 +149,5 @@
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
{% render controller('PropelBundle:Panel:configuration') %}
|
{{ render(controller('PropelBundle:Panel:configuration')) }}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
Loading…
Reference in a new issue