From 0af16762932e96500e2e8a143c058dcbfaac8bb9 Mon Sep 17 00:00:00 2001 From: WouterJ Date: Sun, 27 Sep 2015 13:24:29 +0200 Subject: [PATCH 1/4] Bind input before executing the COMMAND event --- src/Symfony/Component/Console/Application.php | 9 +++ .../Component/Console/Command/Command.php | 3 +- .../Console/Tests/ApplicationTest.php | 57 +++++++++++++++++++ 3 files changed, 68 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/Console/Application.php b/src/Symfony/Component/Console/Application.php index df999d2435..5b4ec43904 100644 --- a/src/Symfony/Component/Console/Application.php +++ b/src/Symfony/Component/Console/Application.php @@ -13,6 +13,7 @@ namespace Symfony\Component\Console; use Symfony\Component\Console\Descriptor\TextDescriptor; use Symfony\Component\Console\Descriptor\XmlDescriptor; +use Symfony\Component\Console\Exception\ExceptionInterface; use Symfony\Component\Console\Helper\DebugFormatterHelper; use Symfony\Component\Console\Helper\ProcessHelper; use Symfony\Component\Console\Helper\QuestionHelper; @@ -880,6 +881,14 @@ class Application return $command->run($input, $output); } + // bind before the console.command event, so the listeners have access to input options/arguments + try { + $command->mergeApplicationDefinition(); + $input->bind($command->getDefinition()); + } catch (ExceptionInterface $e) { + // ignore invalid options/arguments for now, to allow the event listeners to customize the InputDefinition + } + $event = new ConsoleCommandEvent($command, $input, $output); $this->dispatcher->dispatch(ConsoleEvents::COMMAND, $event); diff --git a/src/Symfony/Component/Console/Command/Command.php b/src/Symfony/Component/Console/Command/Command.php index 5ff7ab9b97..21b069268d 100644 --- a/src/Symfony/Component/Console/Command/Command.php +++ b/src/Symfony/Component/Console/Command/Command.php @@ -13,6 +13,7 @@ namespace Symfony\Component\Console\Command; use Symfony\Component\Console\Descriptor\TextDescriptor; use Symfony\Component\Console\Descriptor\XmlDescriptor; +use Symfony\Component\Console\Exception\ExceptionInterface; use Symfony\Component\Console\Input\InputDefinition; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Input\InputArgument; @@ -231,7 +232,7 @@ class Command // bind the input against the command specific arguments/options try { $input->bind($this->definition); - } catch (\Exception $e) { + } catch (ExceptionInterface $e) { if (!$this->ignoreValidationErrors) { throw $e; } diff --git a/src/Symfony/Component/Console/Tests/ApplicationTest.php b/src/Symfony/Component/Console/Tests/ApplicationTest.php index dc2651537a..4f6e000f8e 100644 --- a/src/Symfony/Component/Console/Tests/ApplicationTest.php +++ b/src/Symfony/Component/Console/Tests/ApplicationTest.php @@ -943,6 +943,63 @@ class ApplicationTest extends \PHPUnit_Framework_TestCase $this->assertEquals(ConsoleCommandEvent::RETURN_CODE_DISABLED, $exitCode); } + public function testRunWithDispatcherAccessingInputOptions() + { + $noInteractionValue = null; + $quietValue = null; + + $dispatcher = $this->getDispatcher(); + $dispatcher->addListener('console.command', function (ConsoleCommandEvent $event) use (&$noInteractionValue, &$quietValue) { + $input = $event->getInput(); + + $noInteractionValue = $input->getOption('no-interaction'); + $quietValue = $input->getOption('quiet'); + }); + + $application = new Application(); + $application->setDispatcher($dispatcher); + $application->setAutoExit(false); + + $application->register('foo')->setCode(function (InputInterface $input, OutputInterface $output) { + $output->write('foo.'); + }); + + $tester = new ApplicationTester($application); + $tester->run(array('command' => 'foo', '--no-interaction' => true)); + + $this->assertTrue($noInteractionValue); + $this->assertFalse($quietValue); + } + + public function testRunWithDispatcherAddingInputOptions() + { + $extraValue = null; + + $dispatcher = $this->getDispatcher(); + $dispatcher->addListener('console.command', function (ConsoleCommandEvent $event) use (&$extraValue) { + $definition = $event->getCommand()->getDefinition(); + $input = $event->getInput(); + + $definition->addOption(new InputOption('extra', null, InputOption::VALUE_REQUIRED)); + $input->bind($definition); + + $extraValue = $input->getOption('extra'); + }); + + $application = new Application(); + $application->setDispatcher($dispatcher); + $application->setAutoExit(false); + + $application->register('foo')->setCode(function (InputInterface $input, OutputInterface $output) { + $output->write('foo.'); + }); + + $tester = new ApplicationTester($application); + $tester->run(array('command' => 'foo', '--extra' => 'some test value')); + + $this->assertEquals('some test value', $extraValue); + } + public function testTerminalDimensions() { $application = new Application(); From 23b8a562463e91412089b67e401b142932b7d3da Mon Sep 17 00:00:00 2001 From: WouterJ Date: Mon, 10 Aug 2015 08:36:12 +0200 Subject: [PATCH 2/4] Added general sf-toolbar-block-right class --- .../Resources/views/Collector/config.html.twig | 2 +- .../WebProfilerBundle/Resources/views/Profiler/toolbar.css.twig | 2 +- .../Resources/views/Profiler/toolbar_item.html.twig | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/config.html.twig b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/config.html.twig index 669f654b72..deab6989e4 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/config.html.twig +++ b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/config.html.twig @@ -108,7 +108,7 @@ {% endif %} {% endset %} - {{ include('@WebProfiler/Profiler/toolbar_item.html.twig', { link: true, name: 'config', status: block_status }) }} + {{ include('@WebProfiler/Profiler/toolbar_item.html.twig', { link: true, name: 'config', status: block_status, additional_classes: 'sf-toolbar-block-right' }) }} {% endblock %} {% block menu %} diff --git a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/toolbar.css.twig b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/toolbar.css.twig index 6d07bc4e0b..6b15a33bb8 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/toolbar.css.twig +++ b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/toolbar.css.twig @@ -436,7 +436,7 @@ font-size: 13px; } - .sf-toolbar-block-config { + .sf-toolbar-block-right { float: right; margin-left: 0; margin-right: 0; diff --git a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/toolbar_item.html.twig b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/toolbar_item.html.twig index 2f30e05c9a..7424f1fcef 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/toolbar_item.html.twig +++ b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/toolbar_item.html.twig @@ -1,4 +1,4 @@ -
+
{% if link %}{% endif %}
{{ icon|default('') }}
{% if link %}
{% endif %} From 049fdfed84caf6af6b1469f1b0c2a88004b15c0e Mon Sep 17 00:00:00 2001 From: WouterJ Date: Wed, 30 Sep 2015 15:05:28 +0200 Subject: [PATCH 3/4] Add a way to group toolbar info pieces --- .../views/Collector/config.html.twig | 143 +++++++++--------- .../Resources/views/Profiler/toolbar.css.twig | 10 ++ 2 files changed, 84 insertions(+), 69 deletions(-) diff --git a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/config.html.twig b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/config.html.twig index deab6989e4..a2a7dff8b4 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/config.html.twig +++ b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/config.html.twig @@ -31,81 +31,86 @@ {% endset %} {% set text %} - {% if collector.applicationname %} +
+ {% if collector.applicationname %} +
+ {{ collector.applicationname }} + {{ collector.applicationversion }} +
+ {% endif %} +
- {{ collector.applicationname }} - {{ collector.applicationversion }} -
- {% endif %} - -
- Profiler token - - {% if profiler_url %} - {{ collector.token }} - {% else %} - {{ collector.token }} - {% endif %} - -
- - {% if 'n/a' != collector.appname %} -
- Kernel name - {{ collector.appname }} -
- {% endif %} - - {% if 'n/a' != collector.env %} -
- Environment - {{ collector.env }} -
- {% endif %} - - {% if 'n/a' != collector.debug %} -
- Debug - {{ collector.debug ? 'enabled' : 'disabled' }} -
- {% endif %} - -
- PHP version - - {{ collector.phpversion }} -   View phpinfo() - -
- -
- PHP Extensions - xdebug - accel -
- -
- PHP SAPI - {{ collector.sapiName }} -
- - - {% if collector.symfonyversion is defined %} -
- Resources + Profiler token - {% if 'Silex' == collector.applicationname %} - - Read Silex Docs - + {% if profiler_url %} + {{ collector.token }} {% else %} - - Read Symfony {{ collector.symfonyversion }} Docs - + {{ collector.token }} {% endif %}
- {% endif %} + + {% if 'n/a' != collector.appname %} +
+ Kernel name + {{ collector.appname }} +
+ {% endif %} + + {% if 'n/a' != collector.env %} +
+ Environment + {{ collector.env }} +
+ {% endif %} + + {% if 'n/a' != collector.debug %} +
+ Debug + {{ collector.debug ? 'enabled' : 'disabled' }} +
+ {% endif %} +
+ +
+
+ PHP version + + {{ collector.phpversion }} +   View phpinfo() + +
+ +
+ PHP Extensions + xdebug + accel +
+ +
+ PHP SAPI + {{ collector.sapiName }} +
+
+ +
+ {% if collector.symfonyversion is defined %} +
+ Resources + + {% if 'Silex' == collector.applicationname %} + + Read Silex Docs + + {% else %} + + Read Symfony {{ collector.symfonyversion }} Docs + + {% endif %} + +
+ {% endif %} +
{% endset %} {{ include('@WebProfiler/Profiler/toolbar_item.html.twig', { link: true, name: 'config', status: block_status, additional_classes: 'sf-toolbar-block-right' }) }} diff --git a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/toolbar.css.twig b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/toolbar.css.twig index 6b15a33bb8..1b61835d10 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/toolbar.css.twig +++ b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/toolbar.css.twig @@ -104,6 +104,16 @@ .sf-toolbar-block .sf-toolbar-info-piece-additional-detail { display: none; } +.sf-toolbar-block .sf-toolbar-info-group { + margin-bottom: 4px; + padding-bottom: 2px; + border-bottom: 1px solid #333333; +} +.sf-toolbar-block .sf-toolbar-info-group:last-child { + margin-bottom: 0; + padding-bottom: 0; + border-bottom: none; +} .sf-toolbar-block .sf-toolbar-info-piece .sf-toolbar-status { padding: 2px 5px; From d7034db6bdfecd500b5019e4d96ce652be4c457c Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Wed, 30 Sep 2015 18:53:57 +0200 Subject: [PATCH 4/4] add dependency required by a replaced package Since #16007, the Security HTTP component requires the PropertyAccess component to access nested parameter bag values. Since the Security component replaces the Security HTTP component, all dependencies of the replaced packages must be mirrored here. --- src/Symfony/Component/Security/composer.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/Security/composer.json b/src/Symfony/Component/Security/composer.json index 87a47a53ad..ad0ea41586 100644 --- a/src/Symfony/Component/Security/composer.json +++ b/src/Symfony/Component/Security/composer.json @@ -20,7 +20,8 @@ "symfony/security-acl": "~2.7", "symfony/event-dispatcher": "~2.2|~3.0.0", "symfony/http-foundation": "~2.1|~3.0.0", - "symfony/http-kernel": "~2.4|~3.0.0" + "symfony/http-kernel": "~2.4|~3.0.0", + "symfony/property-access": "~2.3|~3.0.0" }, "replace": { "symfony/security-core": "self.version",