Skip to content

Commit b6435a2

Browse files
committed
Merge branch '2.6' into 2.7
* 2.6: (36 commits) [Debug] fix error message on double exception [Validator] make DateTime objects represented as strings in the violation message. [RFC] [DebugBundle] [HttpKernel] Avoid using container as dependency for DumpListener Upgrade information for the Translation component regarding the new LoggingTranslator class. [WebProfilerBundle] Remove usage of app.request in search bar template Fix initialized() with aliased services fix data type in docblock Rename Symfony2 to Symfony bumped Symfony version to 2.6.0 updated VERSION for 2.6.0-BETA2 updated CHANGELOG for 2.6.0-BETA2 [Debug] fix ENT_SUBSTITUTE usage compare version using PHP_VERSION_ID backport #12489 remove an unneeded check Remove block submit_widget reformat code as suggested by @fabpot Fix typo Make `\Request::get` more performant. properly set request attributes in controller test ...
2 parents 87e9a9e + 38364b7 commit b6435a2

File tree

3 files changed

+32
-54
lines changed

3 files changed

+32
-54
lines changed

EventListener/DumpListener.php

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,10 @@
1111

1212
namespace Symfony\Component\HttpKernel\EventListener;
1313

14-
use Symfony\Component\DependencyInjection\ContainerInterface;
1514
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
1615
use Symfony\Component\HttpKernel\KernelEvents;
16+
use Symfony\Component\VarDumper\Cloner\ClonerInterface;
17+
use Symfony\Component\VarDumper\Dumper\DataDumperInterface;
1718
use Symfony\Component\VarDumper\VarDumper;
1819

1920
/**
@@ -27,30 +28,23 @@ class DumpListener implements EventSubscriberInterface
2728
private $dumper;
2829

2930
/**
30-
* @param ContainerInterface $container Service container, for lazy loading.
31-
* @param string $dumper var_dumper dumper service to use.
31+
* @param ClonerInterface $cloner Cloner service.
32+
* @param DataDumperInterface $dumper Dumper service.
3233
*/
33-
public function __construct(ContainerInterface $container, $dumper)
34+
public function __construct(ClonerInterface $cloner, DataDumperInterface $dumper)
3435
{
35-
$this->container = $container;
36+
$this->cloner = $cloner;
3637
$this->dumper = $dumper;
3738
}
3839

3940
public function configure()
4041
{
41-
if ($this->container) {
42-
$container = $this->container;
43-
$dumper = $this->dumper;
44-
$this->container = null;
45-
46-
VarDumper::setHandler(function ($var) use ($container, $dumper) {
47-
$dumper = $container->get($dumper);
48-
$cloner = $container->get('var_dumper.cloner');
49-
$handler = function ($var) use ($dumper, $cloner) {$dumper->dump($cloner->cloneVar($var));};
50-
VarDumper::setHandler($handler);
51-
$handler($var);
52-
});
53-
}
42+
$cloner = $this->cloner;
43+
$dumper = $this->dumper;
44+
45+
VarDumper::setHandler(function ($var) use ($cloner, $dumper) {
46+
$dumper->dump($cloner->cloneVar($var));
47+
});
5448
}
5549

5650
public static function getSubscribedEvents()

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ HttpKernel Component
44
HttpKernel provides the building blocks to create flexible and fast HTTP-based
55
frameworks.
66

7-
``HttpKernelInterface`` is the core interface of the Symfony2 full-stack
7+
``HttpKernelInterface`` is the core interface of the Symfony full-stack
88
framework:
99

1010
```php
@@ -23,11 +23,11 @@ interface HttpKernelInterface
2323

2424
It takes a ``Request`` as an input and should return a ``Response`` as an
2525
output. Using this interface makes your code compatible with all frameworks
26-
using the Symfony2 components. And this will give you many cool features for
26+
using the Symfony components. And this will give you many cool features for
2727
free.
2828

29-
Creating a framework based on the Symfony2 components is really easy. Here is
30-
a very simple, but fully-featured framework based on the Symfony2 components:
29+
Creating a framework based on the Symfony components is really easy. Here is
30+
a very simple, but fully-featured framework based on the Symfony components:
3131

3232
```php
3333
$routes = new RouteCollection();
@@ -54,7 +54,7 @@ $kernel = new HttpKernel($dispatcher, $resolver);
5454
$kernel->handle($request)->send();
5555
```
5656

57-
This is all you need to create a flexible framework with the Symfony2
57+
This is all you need to create a flexible framework with the Symfony
5858
components.
5959

6060
Want to add an HTTP reverse proxy and benefit from HTTP caching and Edge Side

Tests/EventListener/DumpListenerTest.php

Lines changed: 15 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,11 @@
1111

1212
namespace Symfony\Component\HttpKernel\Tests\EventListener;
1313

14-
use Symfony\Component\DependencyInjection\ContainerBuilder;
15-
use Symfony\Component\DependencyInjection\Definition;
1614
use Symfony\Component\HttpKernel\EventListener\DumpListener;
1715
use Symfony\Component\HttpKernel\KernelEvents;
16+
use Symfony\Component\VarDumper\Cloner\ClonerInterface;
17+
use Symfony\Component\VarDumper\Cloner\Data;
18+
use Symfony\Component\VarDumper\Dumper\DataDumperInterface;
1819
use Symfony\Component\VarDumper\VarDumper;
1920

2021
/**
@@ -34,34 +35,23 @@ public function testSubscribedEvents()
3435

3536
public function testConfigure()
3637
{
37-
$prevDumper = $this->getDumpHandler();
38+
$prevDumper = VarDumper::setHandler('var_dump');
39+
VarDumper::setHandler($prevDumper);
3840

39-
$container = new ContainerBuilder();
40-
$container->setDefinition('var_dumper.cloner', new Definition('Symfony\Component\HttpKernel\Tests\EventListener\MockCloner'));
41-
$container->setDefinition('mock_dumper', new Definition('Symfony\Component\HttpKernel\Tests\EventListener\MockDumper'));
41+
$cloner = new MockCloner();
42+
$dumper = new MockDumper();
4243

4344
ob_start();
4445
$exception = null;
45-
$listener = new DumpListener($container, 'mock_dumper');
46+
$listener = new DumpListener($cloner, $dumper);
4647

4748
try {
4849
$listener->configure();
4950

50-
$lazyDumper = $this->getDumpHandler();
5151
VarDumper::dump('foo');
52-
53-
$loadedDumper = $this->getDumpHandler();
5452
VarDumper::dump('bar');
5553

5654
$this->assertSame('+foo-+bar-', ob_get_clean());
57-
58-
$listenerReflector = new \ReflectionClass($listener);
59-
$lazyReflector = new \ReflectionFunction($lazyDumper);
60-
$loadedReflector = new \ReflectionFunction($loadedDumper);
61-
62-
$this->assertSame($listenerReflector->getFilename(), $lazyReflector->getFilename());
63-
$this->assertSame($listenerReflector->getFilename(), $loadedReflector->getFilename());
64-
$this->assertGreaterThan($lazyReflector->getStartLine(), $loadedReflector->getStartLine());
6555
} catch (\Exception $exception) {
6656
}
6757

@@ -71,28 +61,22 @@ public function testConfigure()
7161
throw $exception;
7262
}
7363
}
74-
75-
private function getDumpHandler()
76-
{
77-
$prevDumper = VarDumper::setHandler('var_dump');
78-
VarDumper::setHandler($prevDumper );
79-
80-
return $prevDumper;
81-
}
8264
}
8365

84-
class MockCloner
66+
class MockCloner implements ClonerInterface
8567
{
8668
public function cloneVar($var)
8769
{
88-
return $var.'-';
70+
return new Data(array($var.'-'));
8971
}
9072
}
9173

92-
class MockDumper
74+
class MockDumper implements DataDumperInterface
9375
{
94-
public function dump($var)
76+
public function dump(Data $data)
9577
{
96-
echo '+'.$var;
78+
$rawData = $data->getRawData();
79+
80+
echo '+'.$rawData[0];
9781
}
9882
}

0 commit comments

Comments
 (0)