⬆️ N°4770 Update to latest Symfony 3.4

This commit is contained in:
Pierre Goiffon
2022-02-10 15:18:50 +01:00
parent b494ff2ce6
commit f29a8792af
401 changed files with 4329 additions and 2378 deletions

View File

@@ -11,7 +11,8 @@
namespace Symfony\Bundle\FrameworkBundle\Controller;
use Doctrine\Common\Persistence\ManagerRegistry;
use Doctrine\Common\Persistence\ManagerRegistry as LegacyManagerRegistry;
use Doctrine\Persistence\ManagerRegistry;
use Psr\Container\ContainerInterface;
use Symfony\Component\DependencyInjection\ServiceSubscriberInterface;
use Symfony\Component\Form\FormFactoryInterface;
@@ -63,7 +64,7 @@ abstract class AbstractController implements ServiceSubscriberInterface
'security.authorization_checker' => '?'.AuthorizationCheckerInterface::class,
'templating' => '?'.EngineInterface::class,
'twig' => '?'.Environment::class,
'doctrine' => '?'.ManagerRegistry::class,
'doctrine' => '?'.(interface_exists(ManagerRegistry::class) ? ManagerRegistry::class : LegacyManagerRegistry::class),
'form.factory' => '?'.FormFactoryInterface::class,
'security.token_storage' => '?'.TokenStorageInterface::class,
'security.csrf.token_manager' => '?'.CsrfTokenManagerInterface::class,

View File

@@ -11,7 +11,8 @@
namespace Symfony\Bundle\FrameworkBundle\Controller;
use Doctrine\Common\Persistence\ManagerRegistry;
use Doctrine\Common\Persistence\ManagerRegistry as LegacyManagerRegistry;
use Doctrine\Persistence\ManagerRegistry;
use Psr\Container\ContainerInterface;
use Symfony\Component\Form\Extension\Core\Type\FormType;
use Symfony\Component\Form\FormBuilderInterface;
@@ -26,6 +27,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Symfony\Component\HttpKernel\HttpKernelInterface;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
use Symfony\Component\Security\Core\User\UserInterface;
use Symfony\Component\Security\Csrf\CsrfToken;
/**
@@ -185,7 +187,7 @@ trait ControllerTrait
* Adds a flash message to the current session for type.
*
* @param string $type The type
* @param string $message The message
* @param mixed $message The message
*
* @throws \LogicException
*
@@ -413,7 +415,7 @@ trait ControllerTrait
/**
* Shortcut to return the Doctrine Registry service.
*
* @return ManagerRegistry
* @return ManagerRegistry|LegacyManagerRegistry
*
* @throws \LogicException If DoctrineBundle is not available
*
@@ -431,7 +433,7 @@ trait ControllerTrait
/**
* Get a user from the Security Token Storage.
*
* @return object|null
* @return UserInterface|object|null
*
* @throws \LogicException If SecurityBundle is not available
*

View File

@@ -49,7 +49,7 @@ class RedirectController implements ContainerAwareInterface
*/
public function setContainer(ContainerInterface $container = null)
{
@trigger_error(sprintf('The "%s()" method is deprecated since Symfony 3.4 and will be removed in 4.0. Inject an UrlGeneratorInterface using the constructor instead.', __METHOD__), E_USER_DEPRECATED);
@trigger_error(sprintf('The "%s()" method is deprecated since Symfony 3.4 and will be removed in 4.0. Inject an UrlGeneratorInterface using the constructor instead.', __METHOD__), \E_USER_DEPRECATED);
$this->container = $container;
$this->router = $container->get('router');
@@ -120,7 +120,7 @@ class RedirectController implements ContainerAwareInterface
$statusCode = $permanent ? 301 : 302;
// redirect if the path is a full URL
if (parse_url($path, PHP_URL_SCHEME)) {
if (parse_url($path, \PHP_URL_SCHEME)) {
return new RedirectResponse($path, $statusCode);
}
@@ -128,8 +128,7 @@ class RedirectController implements ContainerAwareInterface
$scheme = $request->getScheme();
}
$qs = $request->getQueryString();
if ($qs) {
if ($qs = $request->server->get('QUERY_STRING') ?: $request->getQueryString()) {
if (false === strpos($path, '?')) {
$qs = '?'.$qs;
} else {
@@ -143,7 +142,7 @@ class RedirectController implements ContainerAwareInterface
if ('http' === $request->getScheme()) {
$httpPort = $request->getPort();
} elseif ($this->container && $this->container->hasParameter('request_listener.http_port')) {
@trigger_error(sprintf('Passing the http port as a container parameter is deprecated since Symfony 3.4 and won\'t be possible in 4.0. Pass it to the constructor of the "%s" class instead.', __CLASS__), E_USER_DEPRECATED);
@trigger_error(sprintf('Passing the http port as a container parameter is deprecated since Symfony 3.4 and won\'t be possible in 4.0. Pass it to the constructor of the "%s" class instead.', __CLASS__), \E_USER_DEPRECATED);
$httpPort = $this->container->getParameter('request_listener.http_port');
} else {
$httpPort = $this->httpPort;
@@ -158,7 +157,7 @@ class RedirectController implements ContainerAwareInterface
if ('https' === $request->getScheme()) {
$httpsPort = $request->getPort();
} elseif ($this->container && $this->container->hasParameter('request_listener.https_port')) {
@trigger_error(sprintf('Passing the https port as a container parameter is deprecated since Symfony 3.4 and won\'t be possible in 4.0. Pass it to the constructor of the "%s" class instead.', __CLASS__), E_USER_DEPRECATED);
@trigger_error(sprintf('Passing the https port as a container parameter is deprecated since Symfony 3.4 and won\'t be possible in 4.0. Pass it to the constructor of the "%s" class instead.', __CLASS__), \E_USER_DEPRECATED);
$httpsPort = $this->container->getParameter('request_listener.https_port');
} else {
$httpsPort = $this->httpsPort;

View File

@@ -45,7 +45,7 @@ class TemplateController implements ContainerAwareInterface
*/
public function setContainer(ContainerInterface $container = null)
{
@trigger_error(sprintf('The "%s()" method is deprecated since Symfony 3.4 and will be removed in 4.0. Inject a Twig Environment or an EngineInterface using the constructor instead.', __METHOD__), E_USER_DEPRECATED);
@trigger_error(sprintf('The "%s()" method is deprecated since Symfony 3.4 and will be removed in 4.0. Inject a Twig Environment or an EngineInterface using the constructor instead.', __METHOD__), \E_USER_DEPRECATED);
if ($container->has('templating')) {
$this->templating = $container->get('templating');
@@ -75,17 +75,17 @@ class TemplateController implements ContainerAwareInterface
throw new \LogicException('You can not use the TemplateController if the Templating Component or the Twig Bundle are not available.');
}
if ($maxAge) {
if (null !== $maxAge) {
$response->setMaxAge($maxAge);
}
if ($sharedAge) {
if (null !== $sharedAge) {
$response->setSharedMaxAge($sharedAge);
}
if ($private) {
$response->setPrivate();
} elseif (false === $private || (null === $private && ($maxAge || $sharedAge))) {
} elseif (false === $private || (null === $private && (null !== $maxAge || null !== $sharedAge))) {
$response->setPublic();
}