Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Symfony 3.x compatibility #90

Closed
wants to merge 10 commits into from
2 changes: 1 addition & 1 deletion bundle/Controller/LegacySetupController.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public function init()
$this->kernelFactory->setBuildEventsEnabled(false);

/** @var $request \Symfony\Component\HttpFoundation\ParameterBag */
$request = $this->container->get('request')->request;
$request = $this->container->get('request_stack')->getCurrentRequest()->request;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couldn't the request be injected as an argument?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure can, but then it's a breaking change :)


// inject the extra ezpublish-community folders we want permissions checked for
switch ($request->get('eZSetup_current_step')) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ public function process(ContainerBuilder $container)
return;
}

$listenerDef = $container->findDefinition('security.authentication.listener.rememberme');
$listenerDef->addMethodCall('setConfigResolver', array(new Reference('ezpublish.config.resolver')));
$container->findDefinition('security.authentication.listener.rememberme')
->setClass('eZ\Bundle\EzPublishLegacyBundle\Security\RememberMeListener')
->addMethodCall('setConfigResolver', array(new Reference('ezpublish.config.resolver')));
}
}
5 changes: 5 additions & 0 deletions bundle/DependencyInjection/Compiler/RoutingPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,10 @@ public function process(ContainerBuilder $container)
'setLegacyAwareRoutes',
['%ezpublish.default_router.legacy_aware_routes%']
);

if ($container->hasDefinition('ezpublish_rest.templated_router')) {
$container->getDefinition('ezpublish_rest.templated_router')
->setClass('eZ\Bundle\EzPublishLegacyBundle\Routing\DefaultRouter');
}
}
}
5 changes: 3 additions & 2 deletions bundle/DependencyInjection/Compiler/TwigPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ public function process(ContainerBuilder $container)

// Adding setLegacyEngine method call here to avoid side effect in redefining the twig service completely.
// Mentioned side effects are losing extensions/loaders addition for which method calls are added in the TwigEnvironmentPass
$def = $container->getDefinition('twig');
$def->addMethodCall('setEzLegacyEngine', array(new Reference('templating.engine.eztpl')));
$container->getDefinition('twig')
->setClass('eZ\Publish\Core\MVC\Legacy\Templating\Twig\Environment')
->addMethodCall('setEzLegacyEngine', array(new Reference('templating.engine.eztpl')));
}
}
2 changes: 1 addition & 1 deletion bundle/Resources/config/services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ parameters:

# Core overrides
ezpublish.security.login_listener.class: eZ\Bundle\EzPublishLegacyBundle\Security\SecurityListener
security.authentication.listener.rememberme.class: eZ\Bundle\EzPublishLegacyBundle\Security\RememberMeListener

ezpublish_legacy.kernel.lazy_loader.class: eZ\Publish\Core\MVC\Legacy\Kernel\Loader
ezpublish_legacy.kernel_handler.class: ezpKernelHandler
Expand Down Expand Up @@ -95,6 +94,7 @@ services:
- "@?logger"
calls:
- [setContainer, ["@service_container"]]
- [setRequestStack, ["@request_stack"]]

ezpublish_legacy.rest.kernel_handler:
class: "%ezpublish_legacy.kernel_handler.rest.class%"
Expand Down
1 change: 0 additions & 1 deletion bundle/Resources/config/templating.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ parameters:
# eZ Template as a real template engine
templating.engine.eztpl.class: eZ\Publish\Core\MVC\Legacy\Templating\LegacyEngine
assetic.eztpl_formula_loader.class: eZ\Publish\Core\MVC\Legacy\Templating\LegacyFormulaLoader
twig.class: eZ\Publish\Core\MVC\Legacy\Templating\Twig\Environment
twig.loader.string.class: eZ\Publish\Core\MVC\Legacy\Templating\Twig\LoaderString

services:
Expand Down
18 changes: 16 additions & 2 deletions mvc/Kernel/Loader.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
use Psr\Log\LoggerInterface;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\HttpFoundation\ParameterBag;
use Symfony\Component\HttpFoundation\RequestStack;

/**
* Legacy kernel loader.
Expand Down Expand Up @@ -68,6 +69,11 @@ class Loader
/** @var ezpKernelHandler */
private $restHandler;

/**
* @var \Symfony\Component\HttpFoundation\RequestStack
*/
private $requestStack;

public function __construct($legacyRootDir, $webrootDir, EventDispatcherInterface $eventDispatcher, URIHelper $uriHelper, LoggerInterface $logger = null)
{
$this->legacyRootDir = $legacyRootDir;
Expand All @@ -77,6 +83,14 @@ public function __construct($legacyRootDir, $webrootDir, EventDispatcherInterfac
$this->logger = $logger;
}

/**
* @param \Symfony\Component\HttpFoundation\RequestStack $requestStack
*/
public function setRequestStack(RequestStack $requestStack)
{
$this->requestStack = $requestStack;
}

/**
* @param bool $enabled
*/
Expand Down Expand Up @@ -152,7 +166,7 @@ public function buildLegacyKernelHandlerWeb($webHandlerClass, array $defaultLega

$legacyParameters = new ParameterBag($defaultLegacyOptions);
$legacyParameters->set('service-container', $container);
$request = $container->get('request');
$request = $this->requestStack->getCurrentRequest();

if ($that->getBuildEventsEnabled()) {
// PRE_BUILD_LEGACY_KERNEL for non request related stuff
Expand Down Expand Up @@ -277,7 +291,7 @@ public function buildLegacyKernelHandlerRest($mvcConfiguration)
chdir($legacyRootDir);

$legacyParameters = new ParameterBag();
$request = $container->get('request');
$request = $this->requestStack->getCurrentRequest();

if ($that->getBuildEventsEnabled()) {
// PRE_BUILD_LEGACY_KERNEL for non request related stuff
Expand Down