Make PropelBundle available for Symfony 3.X
- Updated composer.json dependency - Replaced deprecated dialog helper with question helper - propel.html.twig - Use render function not render tag - Replaced ContainerAware with ContainerAwareTrait
This commit is contained in:
parent
fab7981630
commit
ca13ff5195
|
@ -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;
|
||||
|
|
|
@ -62,7 +62,7 @@ EOT
|
|||
|
||||
if (!file_exists($path)) {
|
||||
$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->mkdir($path);
|
||||
$this->writeNewDirectory($output, $path);
|
||||
|
|
|
@ -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 <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.
|
||||
* @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
|
||||
|
|
|
@ -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('<info>Aborted, nice decision !</info>');
|
||||
|
||||
return -2;
|
||||
|
|
|
@ -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 <william.durand1@gmail.com>
|
||||
*/
|
||||
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)
|
||||
{
|
||||
|
|
|
@ -115,12 +115,12 @@
|
|||
<code>{{ query.sql|format_sql|raw }}</code>
|
||||
{% if app.request.query.has('query') and app.request.query.get('query') == i %}
|
||||
<div class="SQLExplain">
|
||||
{% 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')
|
||||
}) %}
|
||||
})) }}
|
||||
</div>
|
||||
{% endif %}
|
||||
<div class="SQLInfo">
|
||||
|
@ -149,5 +149,5 @@
|
|||
</tbody>
|
||||
</table>
|
||||
|
||||
{% render controller('PropelBundle:Panel:configuration') %}
|
||||
{{ render(controller('PropelBundle:Panel:configuration')) }}
|
||||
{% endblock %}
|
||||
|
|
|
@ -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\\": "" }
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue