diff --git a/DependencyInjection/Compiler/KernelConfigurationPass.php b/DependencyInjection/Compiler/KernelConfigurationPass.php
index fc933ba..bf1b598 100644
--- a/DependencyInjection/Compiler/KernelConfigurationPass.php
+++ b/DependencyInjection/Compiler/KernelConfigurationPass.php
@@ -26,8 +26,7 @@ class KernelConfigurationPass implements CompilerPassInterface
*/
public function process(ContainerBuilder $container)
{
-
-
+
$kernelId = $container->getParameter('legacy_bridge_bundle.legacy_kernel.id');
$kernelOptions = $container->getParameter('legacy_bridge_bundle.legacy_kernel.options');
$classLoaderId = $this->getClassLoaderId($container);
diff --git a/DependencyInjection/Compiler/ReplaceRouterPass.php b/DependencyInjection/Compiler/ReplaceRouterPass.php
index f4b809a..a121e86 100644
--- a/DependencyInjection/Compiler/ReplaceRouterPass.php
+++ b/DependencyInjection/Compiler/ReplaceRouterPass.php
@@ -30,10 +30,10 @@ public function process(ContainerBuilder $container)
if ($container->hasDefinition('legacy_bridge_bundle.router_listener') === true) {
// First get te default router_listener.
$routerListener = $container->getDefinition('router_listener');
-
+
// Then get our custom route listener and inject the default route listener.
$definition = $container->getDefinition('legacy_bridge_bundle.router_listener');
- $definition->replaceArgument(1, $routerListener);
+ $definition->replaceArgument(0, $routerListener);
// Remap the route_listener service to our custom route listener.
$container->setAlias('router_listener', 'legacy_bridge_bundle.router_listener');
diff --git a/DependencyInjection/LegacyBridgeBundleExtension.php b/DependencyInjection/LegacyBridgeBundleExtension.php
index 1f9da64..d2eaf83 100644
--- a/DependencyInjection/LegacyBridgeBundleExtension.php
+++ b/DependencyInjection/LegacyBridgeBundleExtension.php
@@ -9,6 +9,8 @@
use Symfony\Component\Config\FileLocator;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
use Symfony\Component\DependencyInjection\Loader;
+use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
+
/**
* This is the class that loads and manages your bundle configuration
@@ -30,14 +32,12 @@ class LegacyBridgeBundleExtension extends Extension
public function load(array $configs, ContainerBuilder $container)
{
- // Get the xml file loader.
- $loader = new Loader\XmlFileLoader(
+ $loader = new XmlFileLoader(
$container,
new FileLocator(__DIR__.'/../Resources/config')
);
-
- // Load the services.xml file.
$loader->load('services.xml');
+
// Register composer class loader.
$container->register('composer.loader', 'Composer\Autoload\ClassLoader');
diff --git a/Event/LegacyKernelBootEventInterface.php b/Event/LegacyKernelBootEventInterface.php
index 8fa81a5..ead952e 100644
--- a/Event/LegacyKernelBootEventInterface.php
+++ b/Event/LegacyKernelBootEventInterface.php
@@ -2,7 +2,7 @@
/**
*
*/
-namespace Tactics\LegacyBridgeBundle\Kernel;
+namespace Tactics\LegacyBridgeBundle\Event;
/**
* Interface LegacyKernelInterface
diff --git a/EventListener/LegacyBooterListener.php b/EventListener/LegacyBooterListener.php
index 5962ba2..00958a8 100644
--- a/EventListener/LegacyBooterListener.php
+++ b/EventListener/LegacyBooterListener.php
@@ -65,6 +65,8 @@ public function __construct(
*/
public function onKernelRequest(RequestEvent $event)
{
+
+
if ($this->kernel->isBooted() === false) {
$this->kernel->boot($this->container);
}
diff --git a/EventListener/RouterListener.php b/EventListener/RouterListener.php
index 3a58047..0137f28 100644
--- a/EventListener/RouterListener.php
+++ b/EventListener/RouterListener.php
@@ -37,11 +37,11 @@ class RouterListener implements EventSubscriberInterface
/**
- * @param LegacyKernelInterface $legacyKernel
* @param SymfonyRouterListener $routerListener
+ * @param LegacyKernelInterface $legacyKernel
* @param LoggerInterface $logger
*/
- public function __construct(LegacyKernelInterface $legacyKernel, SymfonyRouterListener $routerListener, LoggerInterface $logger=null)
+ public function __construct(SymfonyRouterListener $routerListener, LegacyKernelInterface $legacyKernel=null, LoggerInterface $logger=null)
{
$this->legacyKernel = $legacyKernel;
$this->routerListener = $routerListener;
@@ -68,17 +68,20 @@ public function onKernelRequest(RequestEvent $event)
$this->logger->info($message);
}
- // When the request could not be dispatched through symfony 5
- // we fallback to our legacy kernel to dispatch the request.
- $response = $this->legacyKernel->handle(
- $event->getRequest(),
- $event->getRequestType(),
- true
- );
-
- if ($response->getStatusCode() !== 404) {
- $event->setResponse($response);
- return $event;
+ if ($this->legacyKernel !== null) {
+
+ // When the request could not be dispatched through symfony 5
+ // we fallback to our legacy kernel to dispatch the request.
+ $response = $this->legacyKernel->handle(
+ $event->getRequest(),
+ $event->getRequestType(),
+ true
+ );
+
+ if ($response->getStatusCode() !== 404) {
+ $event->setResponse($response);
+ return $event;
+ }
}
}
diff --git a/LegacyBridgeBundle.php b/LegacyBridgeBundle.php
index b5d6b9e..f4e678a 100644
--- a/LegacyBridgeBundle.php
+++ b/LegacyBridgeBundle.php
@@ -7,8 +7,10 @@
use Composer\Autoload\ClassLoader;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\HttpKernel\Bundle\Bundle;
+use Tactics\LegacyBridgeBundle\DependencyInjection\Compiler\KernelConfigurationPass;
use Tactics\LegacyBridgeBundle\DependencyInjection\Compiler\LoaderInjectorPass;
use Tactics\LegacyBridgeBundle\DependencyInjection\Compiler\ReplaceRouterPass;
+use Tactics\LegacyBridgeBundle\DependencyInjection\LegacyBridgeBundleExtension;
/**
* Class LegacyBridgeBundle
@@ -41,7 +43,12 @@ public function build(ContainerBuilder $container)
$container->addCompilerPass(new LoaderInjectorPass($this->loader));
}
- //$container->addCompilerPass(new KernelConfigurationPass());
+ $container->addCompilerPass(new KernelConfigurationPass());
$container->addCompilerPass(new ReplaceRouterPass());
}
+
+ public function getContainerExtension()
+ {
+ return new LegacyBridgeBundleExtension();
+ }
}
diff --git a/Resources/config/services.xml b/Resources/config/services.xml
index bff39ed..a9e0cb8 100644
--- a/Resources/config/services.xml
+++ b/Resources/config/services.xml
@@ -6,6 +6,7 @@
Tactics\LegacyBridgeBundle\EventListener\RouterListener
+ Tactics\LegacyBridgeBundle\EventListener\LegacyBooterListener
@@ -14,14 +15,19 @@
Later on we can dive deeper into the autowire functionality.
-->
-
+
-
+
-
+
+
+
+
+
+