Skip to content

Commit 913d2e0

Browse files
Merge pull request #9 from webfactory/feature/dispatch_sub_requests
Allow to dispatch the legacy app in sub-requests
2 parents e3bbfa4 + 9d5a48a commit 913d2e0

File tree

10 files changed

+31
-195
lines changed

10 files changed

+31
-195
lines changed

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# IDE
2+
/.idea/
3+
4+
# Composer
5+
/vendor/
6+
/composer.lock

.idea/codeStyleSettings.xml

Lines changed: 0 additions & 160 deletions
This file was deleted.

.idea/encodings.xml

Lines changed: 0 additions & 5 deletions
This file was deleted.

.idea/misc.xml

Lines changed: 0 additions & 5 deletions
This file was deleted.

.idea/modules.xml

Lines changed: 0 additions & 10 deletions
This file was deleted.

.idea/vcs.xml

Lines changed: 0 additions & 7 deletions
This file was deleted.

CHANGELOG.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,17 @@
11
Changelog
22
=========
33

4-
Version 1.1
4+
Version 1.3
5+
-----------
6+
7+
* Symfony sub-requests can be dispatched to the legacy app (but the legacy app is still called at most once per web request)
8+
9+
Version 1.2
10+
-----------
11+
12+
* Legacy front controllers don't have to return the HTTP status code anymore
13+
14+
Version 1.1
515
-----------
616

717
* Added a way to embed Symfony 2 output into the legacy response (#5)

EventListener/LegacyApplicationDispatchingEventListener.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ class LegacyApplicationDispatchingEventListener
2121
protected $container;
2222
protected $reader;
2323
protected $stopwatch;
24+
25+
/**
26+
* @var Filter[]
27+
*/
2428
protected $filters = array();
2529

2630
public function __construct(ContainerInterface $container, Reader $reader)
@@ -36,10 +40,6 @@ public function addFilter(Filter $filter)
3640

3741
public function onKernelController(FilterControllerEvent $event)
3842
{
39-
if ($event->getRequestType() != HttpKernelInterface::MASTER_REQUEST) {
40-
return;
41-
}
42-
4343
if (!is_array($controller = $event->getController())) {
4444
return;
4545
}
@@ -68,6 +68,9 @@ public function onKernelController(FilterControllerEvent $event)
6868
}
6969
}
7070

71+
/**
72+
* @return HttpKernelInterface
73+
*/
7174
protected function getLegacyApplication()
7275
{
7376
return $this->container->get('webfactory_legacy_integration.legacy_application');

Integration/LegacyApplication.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,11 @@ public function setLegacyKernel(HttpKernelInterface $kernel)
2828

2929
public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = true)
3030
{
31-
return $this->response = $this->legacyKernel->handle($request, $type, $catch);
31+
if ($this->response === null) {
32+
// Dispatch legacy application only once.
33+
$this->response = $this->legacyKernel->handle($request, $type, $catch);
34+
}
35+
return $this->response;
3236
}
3337

3438
public function isDispatched()

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Later, after the Symfony2 Controller has been executed and a Twig template is be
1212
rendered, fragments of the "legacy response" can be retrieved and be used as part
1313
of the output.
1414

15-
That way, you can start with your legacy applcation and Symfony2 in coexistence
15+
That way, you can start with your legacy application and Symfony2 in coexistence
1616
next to each other. You can then incrementally start to shift functionality over
1717
to the Symfony2 stack while maintaining a coherent user experience.
1818

@@ -48,7 +48,7 @@ The legacy "bootstrap" file
4848
---
4949

5050
You must provide a single file that can be `include()`ed in order to run your
51-
legacy applcation. Typically you will already have this - it should be your
51+
legacy application. Typically you will already have this - it should be your
5252
legacy application's front controller.
5353

5454
If you are running PHP < 5.4, this file should _return_ the HTTP status code

0 commit comments

Comments
 (0)