[3.0][HttpKernel] remove deprecated functions and classes

This commit is contained in:
Vincent AUBERT 2015-05-14 14:53:43 +02:00
parent 7ce4e032dd
commit c19f91892b
26 changed files with 24 additions and 848 deletions

View File

@ -142,7 +142,7 @@ class FrameworkExtension extends Extension
$loader->load('debug.xml'); $loader->load('debug.xml');
$definition = $container->findDefinition('http_kernel'); $definition = $container->findDefinition('http_kernel');
$definition->replaceArgument(2, new Reference('debug.controller_resolver')); $definition->replaceArgument(1, new Reference('debug.controller_resolver'));
// replace the regular event_dispatcher service with the debug one // replace the regular event_dispatcher service with the debug one
$definition = $container->findDefinition('event_dispatcher'); $definition = $container->findDefinition('event_dispatcher');

View File

@ -9,9 +9,8 @@
<argument type="service" id="service_container" /> <argument type="service" id="service_container" />
</service> </service>
<service id="http_kernel" class="Symfony\Component\HttpKernel\DependencyInjection\ContainerAwareHttpKernel"> <service id="http_kernel" class="Symfony\Component\HttpKernel\HttpKernel">
<argument type="service" id="event_dispatcher" /> <argument type="service" id="event_dispatcher" />
<argument type="service" id="service_container" />
<argument type="service" id="controller_resolver" /> <argument type="service" id="controller_resolver" />
<argument type="service" id="request_stack" /> <argument type="service" id="request_stack" />
</service> </service>

View File

@ -6,6 +6,24 @@ CHANGELOG
* removed `Symfony\Component\HttpKernel\Kernel::init()` * removed `Symfony\Component\HttpKernel\Kernel::init()`
* removed `Symfony\Component\HttpKernel\Kernel::isClassInActiveBundle()` and `Symfony\Component\HttpKernel\KernelInterface::isClassInActiveBundle()` * removed `Symfony\Component\HttpKernel\Kernel::isClassInActiveBundle()` and `Symfony\Component\HttpKernel\KernelInterface::isClassInActiveBundle()`
* removed `Symfony\Component\HttpKernel\Debug\TraceableEventDispatcher::setProfiler()`
* removed `Symfony\Component\HttpKernel\EventListener\FragmentListener::getLocalIpAddresses()`
* removed `Symfony\Component\HttpKernel\EventListener\LocaleListener::setRequest()`
* removed `Symfony\Component\HttpKernel\EventListener\RouterListener::setRequest()`
* removed `Symfony\Component\HttpKernel\EventListener\ProfilerListener::onKernelRequest()`
* removed `Symfony\Component\HttpKernel\Fragment\FragmentHandler::setRequest()`
* removed `Symfony\Component\HttpKernel\HttpCache\Esi::hasSurrogateEsiCapability()`
* removed `Symfony\Component\HttpKernel\HttpCache\Esi::addSurrogateEsiCapability()`
* removed `Symfony\Component\HttpKernel\HttpCache\Esi::needsEsiParsing()`
* removed `Symfony\Component\HttpKernel\HttpCache\HttpCache::getEsi()`
* removed `Symfony\Component\HttpKernel\DependencyInjection\ContainerAwareHttpKernel`
* removed `Symfony\Component\HttpKernel\DependencyInjection\RegisterListenersPass`
* removed `Symfony\Component\HttpKernel\EventListener\ErrorsLoggerListener`
* removed `Symfony\Component\HttpKernel\EventListener\EsiListener`
* removed `Symfony\Component\HttpKernel\HttpCache\EsiResponseCacheStrategy`
* removed `Symfony\Component\HttpKernel\HttpCache\EsiResponseCacheStrategyInterface`
* removed `Symfony\Component\HttpKernel\Log\LoggerInterface`
* removed `Symfony\Component\HttpKernel\Log\NullLogger`
2.7.0 2.7.0
----- -----

View File

@ -199,12 +199,8 @@ class DumpDataCollector extends DataCollector implements DataDumperInterface
$dumps = array(); $dumps = array();
foreach ($this->data as $dump) { foreach ($this->data as $dump) {
if (method_exists($dump['data'], 'withMaxDepth')) {
$dumper->dump($dump['data']->withMaxDepth($maxDepthLimit)->withMaxItemsPerDepth($maxItemsPerDepth)); $dumper->dump($dump['data']->withMaxDepth($maxDepthLimit)->withMaxItemsPerDepth($maxItemsPerDepth));
} else {
// getLimitedClone is @deprecated, to be removed in 3.0
$dumper->dump($dump['data']->getLimitedClone($maxDepthLimit, $maxItemsPerDepth));
}
rewind($data); rewind($data);
$dump['data'] = stream_get_contents($data); $dump['data'] = stream_get_contents($data);
ftruncate($data, 0); ftruncate($data, 0);

View File

@ -12,7 +12,6 @@
namespace Symfony\Component\HttpKernel\Debug; namespace Symfony\Component\HttpKernel\Debug;
use Symfony\Component\EventDispatcher\Debug\TraceableEventDispatcher as BaseTraceableEventDispatcher; use Symfony\Component\EventDispatcher\Debug\TraceableEventDispatcher as BaseTraceableEventDispatcher;
use Symfony\Component\HttpKernel\Profiler\Profiler;
use Symfony\Component\HttpKernel\KernelEvents; use Symfony\Component\HttpKernel\KernelEvents;
use Symfony\Component\EventDispatcher\Event; use Symfony\Component\EventDispatcher\Event;
@ -25,22 +24,6 @@ use Symfony\Component\EventDispatcher\Event;
*/ */
class TraceableEventDispatcher extends BaseTraceableEventDispatcher class TraceableEventDispatcher extends BaseTraceableEventDispatcher
{ {
/**
* Sets the profiler.
*
* The traceable event dispatcher does not use the profiler anymore.
* The job is now done directly by the Profiler listener and the
* data collectors themselves.
*
* @param Profiler|null $profiler A Profiler instance
*
* @deprecated since version 2.4, to be removed in 3.0.
*/
public function setProfiler(Profiler $profiler = null)
{
trigger_error('The '.__METHOD__.' method is deprecated since version 2.4 and will be removed in 3.0.', E_USER_DEPRECATED);
}
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */

View File

@ -1,77 +0,0 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\HttpKernel\DependencyInjection;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\HttpKernel\HttpKernelInterface;
use Symfony\Component\HttpKernel\HttpKernel;
use Symfony\Component\HttpKernel\Controller\ControllerResolverInterface;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\DependencyInjection\Scope;
/**
* Adds a managed request scope.
*
* @author Fabien Potencier <fabien@symfony.com>
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
*
* @deprecated since version 2.7, to be removed in 3.0.
*/
class ContainerAwareHttpKernel extends HttpKernel
{
protected $container;
/**
* Constructor.
*
* @param EventDispatcherInterface $dispatcher An EventDispatcherInterface instance
* @param ContainerInterface $container A ContainerInterface instance
* @param ControllerResolverInterface $controllerResolver A ControllerResolverInterface instance
* @param RequestStack $requestStack A stack for master/sub requests
*/
public function __construct(EventDispatcherInterface $dispatcher, ContainerInterface $container, ControllerResolverInterface $controllerResolver, RequestStack $requestStack = null)
{
parent::__construct($dispatcher, $controllerResolver, $requestStack);
$this->container = $container;
// the request scope might have been created before (see FrameworkBundle)
if (!$container->hasScope('request')) {
$container->addScope(new Scope('request'));
}
}
/**
* {@inheritdoc}
*/
public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = true)
{
$this->container->enterScope('request');
$this->container->set('request', $request, 'request');
try {
$response = parent::handle($request, $type, $catch);
} catch (\Exception $e) {
$this->container->set('request', null, 'request');
$this->container->leaveScope('request');
throw $e;
}
$this->container->set('request', null, 'request');
$this->container->leaveScope('request');
return $response;
}
}

View File

@ -12,7 +12,6 @@
namespace Symfony\Component\HttpKernel\DependencyInjection; namespace Symfony\Component\HttpKernel\DependencyInjection;
use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Reference;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
/** /**
@ -59,15 +58,8 @@ class FragmentRendererPass implements CompilerPassInterface
} }
foreach ($tags as $tag) { foreach ($tags as $tag) {
if (!isset($tag['alias'])) {
trigger_error(sprintf('Service "%s" will have to define the "alias" attribute on the "%s" tag as of Symfony 3.0.', $id, $this->rendererTag), E_USER_DEPRECATED);
// register the handler as a non-lazy-loaded one
$definition->addMethodCall('addRenderer', array(new Reference($id)));
} else {
$definition->addMethodCall('addRendererService', array($tag['alias'], $id)); $definition->addMethodCall('addRendererService', array($tag['alias'], $id));
} }
} }
} }
} }
}

View File

@ -1,25 +0,0 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\HttpKernel\DependencyInjection;
trigger_error('The '.__NAMESPACE__.'\RegisterListenersPass is deprecated since version 2.5 and will be removed in 3.0. Use the Symfony\Component\EventDispatcher\DependencyInjection\RegisterListenersPass class instead.', E_USER_DEPRECATED);
use Symfony\Component\EventDispatcher\DependencyInjection\RegisterListenersPass as BaseRegisterListenersPass;
/**
* Compiler pass to register tagged services for an event dispatcher.
*
* @deprecated since version 2.5, to be removed in 3.0. Use the Symfony\Component\EventDispatcher\DependencyInjection\RegisterListenersPass class instead.
*/
class RegisterListenersPass extends BaseRegisterListenersPass
{
}

View File

@ -1,52 +0,0 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\HttpKernel\EventListener;
trigger_error('The '.__NAMESPACE__.'\ErrorsLoggerListener class is deprecated since version 2.6 and will be removed in 3.0. Use the Symfony\Component\HttpKernel\EventListener\DebugHandlersListener class instead.', E_USER_DEPRECATED);
use Psr\Log\LoggerInterface;
use Symfony\Component\Debug\ErrorHandler;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpKernel\KernelEvents;
/**
* Injects the logger into the ErrorHandler, so that it can log various errors.
*
* @author Colin Frei <colin@colinfrei.com>
* @author Konstantin Myakshin <koc-dp@yandex.ru>
*
* @deprecated since version 2.6, to be removed in 3.0. Use the DebugHandlersListener class instead.
*/
class ErrorsLoggerListener implements EventSubscriberInterface
{
private $channel;
private $logger;
public function __construct($channel, LoggerInterface $logger = null)
{
$this->channel = $channel;
$this->logger = $logger;
}
public function injectLogger()
{
if (null !== $this->logger) {
ErrorHandler::setLogger($this->logger, $this->channel);
$this->logger = null;
}
}
public static function getSubscribedEvents()
{
return array(KernelEvents::REQUEST => array('injectLogger', 2048));
}
}

View File

@ -1,25 +0,0 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\HttpKernel\EventListener;
trigger_error('The '.__NAMESPACE__.'\EsiListener class is deprecated since version 2.6 and will be removed in 3.0. Use the Symfony\Component\HttpKernel\EventListener\SurrogateListener class instead.', E_USER_DEPRECATED);
/**
* EsiListener adds a Surrogate-Control HTTP header when the Response needs to be parsed for ESI.
*
* @author Fabien Potencier <fabien@symfony.com>
*
* @deprecated since version 2.6, to be removed in 3.0. Use SurrogateListener instead
*/
class EsiListener extends SurrogateListener
{
}

View File

@ -107,10 +107,6 @@ class ExceptionListener implements EventSubscriberInterface
'_controller' => $this->controller, '_controller' => $this->controller,
'exception' => FlattenException::create($exception), 'exception' => FlattenException::create($exception),
'logger' => $this->logger instanceof DebugLoggerInterface ? $this->logger : null, 'logger' => $this->logger instanceof DebugLoggerInterface ? $this->logger : null,
// keep for BC -- as $format can be an argument of the controller callable
// see src/Symfony/Bundle/TwigBundle/Controller/ExceptionController.php
// @deprecated since version 2.4, to be removed in 3.0
'format' => $request->getRequestFormat(),
); );
$request = $request->duplicate(null, null, $attributes); $request = $request->duplicate(null, null, $attributes);
$request->setMethod('GET'); $request->setMethod('GET');

View File

@ -87,18 +87,6 @@ class FragmentListener implements EventSubscriberInterface
throw new AccessDeniedHttpException(); throw new AccessDeniedHttpException();
} }
/**
* @deprecated since version 2.3.19, to be removed in 3.0.
*
* @return string[]
*/
protected function getLocalIpAddresses()
{
trigger_error('The '.__METHOD__.' method is deprecated since version 2.3.19 and will be removed in 3.0.', E_USER_DEPRECATED);
return array('127.0.0.1', 'fe80::1', '::1');
}
public static function getSubscribedEvents() public static function getSubscribedEvents()
{ {
return array( return array(

View File

@ -45,29 +45,6 @@ class LocaleListener implements EventSubscriberInterface
$this->router = $router; $this->router = $router;
} }
/**
* Sets the current Request.
*
* This method was used to synchronize the Request, but as the HttpKernel
* is doing that automatically now, you should never call it directly.
* It is kept public for BC with the 2.3 version.
*
* @param Request|null $request A Request instance
*
* @deprecated since version 2.4, to be removed in 3.0.
*/
public function setRequest(Request $request = null)
{
trigger_error('The '.__METHOD__.' method is deprecated since version 2.4 and will be removed in 3.0.', E_USER_DEPRECATED);
if (null === $request) {
return;
}
$this->setLocale($request);
$this->setRouterContext($request);
}
public function onKernelRequest(GetResponseEvent $event) public function onKernelRequest(GetResponseEvent $event)
{ {
$request = $event->getRequest(); $request = $event->getRequest();

View File

@ -11,7 +11,6 @@
namespace Symfony\Component\HttpKernel\EventListener; namespace Symfony\Component\HttpKernel\EventListener;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent; use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent;
use Symfony\Component\HttpKernel\Event\FilterResponseEvent; use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
use Symfony\Component\HttpKernel\Event\PostResponseEvent; use Symfony\Component\HttpKernel\Event\PostResponseEvent;
@ -49,13 +48,6 @@ class ProfilerListener implements EventSubscriberInterface
*/ */
public function __construct(Profiler $profiler, RequestMatcherInterface $matcher = null, $onlyException = false, $onlyMasterRequests = false, RequestStack $requestStack = null) public function __construct(Profiler $profiler, RequestMatcherInterface $matcher = null, $onlyException = false, $onlyMasterRequests = false, RequestStack $requestStack = null)
{ {
if (null === $requestStack) {
// Prevent the deprecation notice to be triggered all the time.
// The onKernelRequest() method fires some logic only when the
// RequestStack instance is not provided as a dependency.
trigger_error('Since version 2.4, the '.__METHOD__.' method must accept a RequestStack instance to get the request instead of using the '.__CLASS__.'::onKernelRequest method that will be removed in 3.0.', E_USER_DEPRECATED);
}
$this->profiler = $profiler; $this->profiler = $profiler;
$this->matcher = $matcher; $this->matcher = $matcher;
$this->onlyException = (bool) $onlyException; $this->onlyException = (bool) $onlyException;
@ -79,16 +71,6 @@ class ProfilerListener implements EventSubscriberInterface
$this->exception = $event->getException(); $this->exception = $event->getException();
} }
/**
* @deprecated since version 2.4, to be removed in 3.0.
*/
public function onKernelRequest(GetResponseEvent $event)
{
if (null === $this->requestStack) {
$this->requests[] = $event->getRequest();
}
}
/** /**
* Handles the onKernelResponse event. * Handles the onKernelResponse event.
* *
@ -154,9 +136,6 @@ class ProfilerListener implements EventSubscriberInterface
public static function getSubscribedEvents() public static function getSubscribedEvents()
{ {
return array( return array(
// kernel.request must be registered as early as possible to not break
// when an exception is thrown in any other kernel.request listener
KernelEvents::REQUEST => array('onKernelRequest', 1024),
KernelEvents::RESPONSE => array('onKernelResponse', -100), KernelEvents::RESPONSE => array('onKernelResponse', -100),
KernelEvents::EXCEPTION => 'onKernelException', KernelEvents::EXCEPTION => 'onKernelException',
KernelEvents::TERMINATE => array('onKernelTerminate', -1024), KernelEvents::TERMINATE => array('onKernelTerminate', -1024),

View File

@ -67,34 +67,12 @@ class RouterListener implements EventSubscriberInterface
throw new \InvalidArgumentException('You must either pass a RequestContext or the matcher must implement RequestContextAwareInterface.'); throw new \InvalidArgumentException('You must either pass a RequestContext or the matcher must implement RequestContextAwareInterface.');
} }
if (!$requestStack instanceof RequestStack) {
trigger_error('The '.__METHOD__.' method now requires a RequestStack instance as '.__CLASS__.'::setRequest method will not be supported anymore in 3.0.', E_USER_DEPRECATED);
}
$this->matcher = $matcher; $this->matcher = $matcher;
$this->context = $context ?: $matcher->getContext(); $this->context = $context ?: $matcher->getContext();
$this->requestStack = $requestStack; $this->requestStack = $requestStack;
$this->logger = $logger; $this->logger = $logger;
} }
/**
* Sets the current Request.
*
* This method was used to synchronize the Request, but as the HttpKernel
* is doing that automatically now, you should never call it directly.
* It is kept public for BC with the 2.3 version.
*
* @param Request|null $request A Request instance
*
* @deprecated since version 2.4, to be removed in 3.0.
*/
public function setRequest(Request $request = null)
{
trigger_error('The '.__METHOD__.' method is deprecated since version 2.4 and will be made private in 3.0.', E_USER_DEPRECATED);
$this->setCurrentRequest($request);
}
private function setCurrentRequest(Request $request = null) private function setCurrentRequest(Request $request = null)
{ {
if (null !== $request && $this->request !== $request) { if (null !== $request && $this->request !== $request) {

View File

@ -67,24 +67,6 @@ class FragmentHandler
$this->renderers[$renderer->getName()] = $renderer; $this->renderers[$renderer->getName()] = $renderer;
} }
/**
* Sets the current Request.
*
* This method was used to synchronize the Request, but as the HttpKernel
* is doing that automatically now, you should never call it directly.
* It is kept public for BC with the 2.3 version.
*
* @param Request|null $request A Request instance
*
* @deprecated since version 2.4, to be removed in 3.0.
*/
public function setRequest(Request $request = null)
{
trigger_error('The '.__METHOD__.' method is deprecated since version 2.4 and will be removed in 3.0.', E_USER_DEPRECATED);
$this->request = $request;
}
/** /**
* Renders a URI and returns the Response content. * Renders a URI and returns the Response content.
* *

View File

@ -76,22 +76,6 @@ class Esi implements SurrogateInterface
return false !== strpos($value, 'ESI/1.0'); return false !== strpos($value, 'ESI/1.0');
} }
/**
* Checks that at least one surrogate has ESI/1.0 capability.
*
* @param Request $request A Request instance
*
* @return bool true if one surrogate has ESI/1.0 capability, false otherwise
*
* @deprecated since version 2.6, to be removed in 3.0. Use hasSurrogateCapability() instead
*/
public function hasSurrogateEsiCapability(Request $request)
{
trigger_error('The '.__METHOD__.' method is deprecated since version 2.6 and will be removed in 3.0. Use the hasSurrogateCapability() method instead.', E_USER_DEPRECATED);
return $this->hasSurrogateCapability($request);
}
/** /**
* Adds ESI/1.0 capability to the given Request. * Adds ESI/1.0 capability to the given Request.
* *
@ -105,20 +89,6 @@ class Esi implements SurrogateInterface
$request->headers->set('Surrogate-Capability', $current ? $current.', '.$new : $new); $request->headers->set('Surrogate-Capability', $current ? $current.', '.$new : $new);
} }
/**
* Adds ESI/1.0 capability to the given Request.
*
* @param Request $request A Request instance
*
* @deprecated since version 2.6, to be removed in 3.0. Use addSurrogateCapability() instead
*/
public function addSurrogateEsiCapability(Request $request)
{
trigger_error('The '.__METHOD__.' method is deprecated since version 2.6 and will be removed in 3.0. Use the addSurrogateCapability() method instead.', E_USER_DEPRECATED);
$this->addSurrogateCapability($request);
}
/** /**
* Adds HTTP headers to specify that the Response needs to be parsed for ESI. * Adds HTTP headers to specify that the Response needs to be parsed for ESI.
* *
@ -149,22 +119,6 @@ class Esi implements SurrogateInterface
return (bool) preg_match('#content="[^"]*ESI/1.0[^"]*"#', $control); return (bool) preg_match('#content="[^"]*ESI/1.0[^"]*"#', $control);
} }
/**
* Checks that the Response needs to be parsed for ESI tags.
*
* @param Response $response A Response instance
*
* @return bool true if the Response needs to be parsed, false otherwise
*
* @deprecated since version 2.6, to be removed in 3.0. Use needsParsing() instead
*/
public function needsEsiParsing(Response $response)
{
trigger_error('The '.__METHOD__.' method is deprecated since version 2.6 and will be removed in 3.0. Use the needsParsing() method instead.', E_USER_DEPRECATED);
return $this->needsParsing($response);
}
/** /**
* Renders an ESI tag. * Renders an ESI tag.
* *

View File

@ -1,33 +0,0 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* This code is partially based on the Rack-Cache library by Ryan Tomayko,
* which is released under the MIT license.
* (based on commit 02d2b48d75bcb63cf1c0c7149c077ad256542801)
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\HttpKernel\HttpCache;
trigger_error('The '.__NAMESPACE__.'\EsiResponseCacheStrategy class is deprecated since version 2.6 and will be removed in 3.0. Use the Symfony\Component\HttpKernel\HttpCache\ResponseCacheStrategy class instead.', E_USER_DEPRECATED);
/**
* EsiResponseCacheStrategy knows how to compute the Response cache HTTP header
* based on the different ESI response cache headers.
*
* This implementation changes the master response TTL to the smallest TTL received
* or force validation if one of the ESI has validation cache strategy.
*
* @author Fabien Potencier <fabien@symfony.com>
*
* @deprecated since version 2.6, to be removed in 3.0. Use ResponseCacheStrategy instead
*/
class EsiResponseCacheStrategy extends ResponseCacheStrategy implements EsiResponseCacheStrategyInterface
{
}

View File

@ -1,30 +0,0 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* This code is partially based on the Rack-Cache library by Ryan Tomayko,
* which is released under the MIT license.
* (based on commit 02d2b48d75bcb63cf1c0c7149c077ad256542801)
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\HttpKernel\HttpCache;
trigger_error('The '.__NAMESPACE__.'\EsiResponseCacheStrategyInterface class is deprecated since version 2.6 and will be removed in 3.0. Use the Symfony\Component\HttpKernel\HttpCache\ResponseCacheStrategyInterface class instead.', E_USER_DEPRECATED);
/**
* ResponseCacheStrategyInterface implementations know how to compute the
* Response cache HTTP header based on the different response cache headers.
*
* @author Fabien Potencier <fabien@symfony.com>
*
* @deprecated since version 2.6, to be removed in 3.0. Use ResponseCacheStrategyInterface instead.
*/
interface EsiResponseCacheStrategyInterface extends ResponseCacheStrategyInterface
{
}

View File

@ -156,6 +156,7 @@ class HttpCache implements HttpKernelInterface, TerminableInterface
* Gets the Surrogate instance. * Gets the Surrogate instance.
* *
* @throws \LogicException * @throws \LogicException
*
* @return SurrogateInterface A Surrogate instance * @return SurrogateInterface A Surrogate instance
*/ */
public function getSurrogate() public function getSurrogate()
@ -163,26 +164,6 @@ class HttpCache implements HttpKernelInterface, TerminableInterface
return $this->getEsi(); return $this->getEsi();
} }
/**
* Gets the Esi instance.
*
* @throws \LogicException
*
* @return Esi An Esi instance
*
* @deprecated since version 2.6, to be removed in 3.0. Use getSurrogate() instead
*/
public function getEsi()
{
trigger_error('The '.__METHOD__.' method is deprecated since version 2.6 and will be removed in 3.0. Use the getSurrogate() method instead.', E_USER_DEPRECATED);
if (!$this->surrogate instanceof Esi) {
throw new \LogicException('This instance of HttpCache was not set up to use ESI as surrogate handler. You must overwrite and use createSurrogate');
}
return $this->surrogate;
}
/** /**
* {@inheritdoc} * {@inheritdoc}
* *

View File

@ -1,54 +0,0 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\HttpKernel\Log;
use Psr\Log\LoggerInterface as PsrLogger;
/**
* LoggerInterface.
*
* @author Fabien Potencier <fabien@symfony.com>
*
* @deprecated since version 2.2, to be removed in 3.0. Type-hint \Psr\Log\LoggerInterface instead.
*
* @api
*/
interface LoggerInterface extends PsrLogger
{
/**
* @api
*
* @deprecated since version 2.2, to be removed in 3.0. Use emergency() which is PSR-3 compatible.
*/
public function emerg($message, array $context = array());
/**
* @api
*
* @deprecated since version 2.2, to be removed in 3.0. Use critical() which is PSR-3 compatible.
*/
public function crit($message, array $context = array());
/**
* @api
*
* @deprecated since version 2.2, to be removed in 3.0. Use error() which is PSR-3 compatible.
*/
public function err($message, array $context = array());
/**
* @api
*
* @deprecated since version 2.2, to be removed in 3.0. Use warning() which is PSR-3 compatible.
*/
public function warn($message, array $context = array());
}

View File

@ -1,58 +0,0 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\HttpKernel\Log;
trigger_error('The '.__NAMESPACE__.'\NullLogger class is deprecated since version 2.2 and will be removed in 3.0. Use the Psr\Log\NullLogger class instead from the psr/log Composer package.', E_USER_DEPRECATED);
use Psr\Log\NullLogger as PsrNullLogger;
/**
* NullLogger.
*
* @author Fabien Potencier <fabien@symfony.com>
*
* @api
*/
class NullLogger extends PsrNullLogger implements LoggerInterface
{
/**
* @api
*/
public function emerg($message, array $context = array())
{
trigger_error('The '.__METHOD__.' method is deprecated since version 2.2 and will be removed in 3.0. You should use the new emergency() method instead, which is PSR-3 compatible.', E_USER_DEPRECATED);
}
/**
* @api
*/
public function crit($message, array $context = array())
{
trigger_error('The '.__METHOD__.' method is deprecated since version 2.2 and will be removed in 3.0. You should use the new critical() method instead, which is PSR-3 compatible.', E_USER_DEPRECATED);
}
/**
* @api
*/
public function err($message, array $context = array())
{
trigger_error('The '.__METHOD__.' method is deprecated since version 2.2 and will be removed in 3.0. You should use the new error() method instead, which is PSR-3 compatible.', E_USER_DEPRECATED);
}
/**
* @api
*/
public function warn($message, array $context = array())
{
trigger_error('The '.__METHOD__.' method is deprecated since version 2.2 and will be removed in 3.0. You should use the new warning() method instead, which is PSR-3 compatible.', E_USER_DEPRECATED);
}
}

View File

@ -1,165 +0,0 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\HttpKernel\Tests\DependencyInjection;
use Symfony\Component\HttpKernel\HttpKernelInterface;
use Symfony\Component\HttpKernel\DependencyInjection\ContainerAwareHttpKernel;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\EventDispatcher\EventDispatcher;
class ContainerAwareHttpKernelTest extends \PHPUnit_Framework_TestCase
{
/**
* @dataProvider getProviderTypes
*/
public function testHandle($type)
{
$request = new Request();
$expected = new Response();
$controller = function () use ($expected) {
return $expected;
};
$container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
$this
->expectsEnterScopeOnce($container)
->expectsLeaveScopeOnce($container)
->expectsSetRequestWithAt($container, $request, 3)
->expectsSetRequestWithAt($container, null, 4)
;
$dispatcher = new EventDispatcher();
$resolver = $this->getResolverMockFor($controller, $request);
$stack = new RequestStack();
$kernel = new ContainerAwareHttpKernel($dispatcher, $container, $resolver, $stack);
$actual = $kernel->handle($request, $type);
$this->assertSame($expected, $actual, '->handle() returns the response');
}
/**
* @dataProvider getProviderTypes
*/
public function testVerifyRequestStackPushPopDuringHandle($type)
{
$request = new Request();
$expected = new Response();
$controller = function () use ($expected) {
return $expected;
};
$stack = $this->getMock('Symfony\Component\HttpFoundation\RequestStack', array('push', 'pop'));
$stack->expects($this->at(0))->method('push')->with($this->equalTo($request));
$stack->expects($this->at(1))->method('pop');
$container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
$dispatcher = new EventDispatcher();
$resolver = $this->getResolverMockFor($controller, $request);
$kernel = new ContainerAwareHttpKernel($dispatcher, $container, $resolver, $stack);
$kernel->handle($request, $type);
}
/**
* @dataProvider getProviderTypes
*/
public function testHandleRestoresThePreviousRequestOnException($type)
{
$request = new Request();
$expected = new \Exception();
$controller = function () use ($expected) {
throw $expected;
};
$container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
$this
->expectsEnterScopeOnce($container)
->expectsLeaveScopeOnce($container)
->expectsSetRequestWithAt($container, $request, 3)
->expectsSetRequestWithAt($container, null, 4)
;
$dispatcher = new EventDispatcher();
$resolver = $this->getMock('Symfony\\Component\\HttpKernel\\Controller\\ControllerResolverInterface');
$resolver = $this->getResolverMockFor($controller, $request);
$stack = new RequestStack();
$kernel = new ContainerAwareHttpKernel($dispatcher, $container, $resolver, $stack);
try {
$kernel->handle($request, $type);
$this->fail('->handle() suppresses the controller exception');
} catch (\PHPUnit_Framework_Exception $exception) {
throw $exception;
} catch (\Exception $actual) {
$this->assertSame($expected, $actual, '->handle() throws the controller exception');
}
}
public function getProviderTypes()
{
return array(
array(HttpKernelInterface::MASTER_REQUEST),
array(HttpKernelInterface::SUB_REQUEST),
);
}
private function getResolverMockFor($controller, $request)
{
$resolver = $this->getMock('Symfony\\Component\\HttpKernel\\Controller\\ControllerResolverInterface');
$resolver->expects($this->once())
->method('getController')
->with($request)
->will($this->returnValue($controller));
$resolver->expects($this->once())
->method('getArguments')
->with($request, $controller)
->will($this->returnValue(array()));
return $resolver;
}
private function expectsSetRequestWithAt($container, $with, $at)
{
$container
->expects($this->at($at))
->method('set')
->with($this->equalTo('request'), $this->equalTo($with), $this->equalTo('request'))
;
return $this;
}
private function expectsEnterScopeOnce($container)
{
$container
->expects($this->once())
->method('enterScope')
->with($this->equalTo('request'))
;
return $this;
}
private function expectsLeaveScopeOnce($container)
{
$container
->expects($this->once())
->method('leaveScope')
->with($this->equalTo('request'))
;
return $this;
}
}

View File

@ -11,63 +11,12 @@
namespace Symfony\Component\HttpKernel\Tests\DependencyInjection; namespace Symfony\Component\HttpKernel\Tests\DependencyInjection;
use Symfony\Component\DependencyInjection\Reference;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\DependencyInjection\FragmentRendererPass; use Symfony\Component\HttpKernel\DependencyInjection\FragmentRendererPass;
use Symfony\Component\HttpKernel\Fragment\FragmentRendererInterface; use Symfony\Component\HttpKernel\Fragment\FragmentRendererInterface;
class FragmentRendererPassTest extends \PHPUnit_Framework_TestCase class FragmentRendererPassTest extends \PHPUnit_Framework_TestCase
{ {
/**
* @group legacy
*/
public function testLegacyFragmentRedererWithoutAlias()
{
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
// no alias
$services = array(
'my_content_renderer' => array(array()),
);
$renderer = $this->getMock('Symfony\Component\DependencyInjection\Definition');
$renderer
->expects($this->once())
->method('addMethodCall')
->with('addRenderer', array(new Reference('my_content_renderer')))
;
$definition = $this->getMock('Symfony\Component\DependencyInjection\Definition');
$definition->expects($this->atLeastOnce())
->method('getClass')
->will($this->returnValue('Symfony\Component\HttpKernel\Tests\DependencyInjection\RendererService'));
$definition
->expects($this->once())
->method('isPublic')
->will($this->returnValue(true))
;
$builder = $this->getMock(
'Symfony\Component\DependencyInjection\ContainerBuilder',
array('hasDefinition', 'findTaggedServiceIds', 'getDefinition')
);
$builder->expects($this->any())
->method('hasDefinition')
->will($this->returnValue(true));
// We don't test kernel.fragment_renderer here
$builder->expects($this->atLeastOnce())
->method('findTaggedServiceIds')
->will($this->returnValue($services));
$builder->expects($this->atLeastOnce())
->method('getDefinition')
->will($this->onConsecutiveCalls($renderer, $definition));
$pass = new FragmentRendererPass();
$pass->process($builder);
}
/** /**
* Tests that content rendering not implementing FragmentRendererInterface * Tests that content rendering not implementing FragmentRendererInterface
* trigger an exception. * trigger an exception.

View File

@ -14,7 +14,6 @@ namespace Symfony\Component\HttpKernel\Tests\EventListener;
use Symfony\Component\HttpFoundation\RequestStack; use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\HttpKernel\EventListener\ProfilerListener; use Symfony\Component\HttpKernel\EventListener\ProfilerListener;
use Symfony\Component\HttpKernel\Event\FilterResponseEvent; use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent; use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent;
use Symfony\Component\HttpKernel\Event\PostResponseEvent; use Symfony\Component\HttpKernel\Event\PostResponseEvent;
use Symfony\Component\HttpKernel\Exception\HttpException; use Symfony\Component\HttpKernel\Exception\HttpException;
@ -22,42 +21,6 @@ use Symfony\Component\HttpKernel\Kernel;
class ProfilerListenerTest extends \PHPUnit_Framework_TestCase class ProfilerListenerTest extends \PHPUnit_Framework_TestCase
{ {
/**
* Test to ensure BC without RequestStack
*
* @group legacy
*/
public function testLegacyEventsWithoutRequestStack()
{
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
$profile = $this->getMockBuilder('Symfony\Component\HttpKernel\Profiler\Profile')
->disableOriginalConstructor()
->getMock();
$profiler = $this->getMockBuilder('Symfony\Component\HttpKernel\Profiler\Profiler')
->disableOriginalConstructor()
->getMock();
$profiler->expects($this->once())
->method('collect')
->will($this->returnValue($profile));
$kernel = $this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface');
$request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')
->disableOriginalConstructor()
->getMock();
$response = $this->getMockBuilder('Symfony\Component\HttpFoundation\Response')
->disableOriginalConstructor()
->getMock();
$listener = new ProfilerListener($profiler);
$listener->onKernelRequest(new GetResponseEvent($kernel, $request, Kernel::MASTER_REQUEST));
$listener->onKernelResponse(new FilterResponseEvent($kernel, $request, Kernel::MASTER_REQUEST, $response));
$listener->onKernelTerminate(new PostResponseEvent($kernel, $request, $response));
}
/** /**
* Test a master and sub request with an exception and `onlyException` profiler option enabled. * Test a master and sub request with an exception and `onlyException` profiler option enabled.
*/ */

View File

@ -85,44 +85,4 @@ class Logger implements LoggerInterface
{ {
$this->log('debug', $message, $context); $this->log('debug', $message, $context);
} }
/**
* @deprecated
*/
public function emerg($message, array $context = array())
{
trigger_error('Use emergency() which is PSR-3 compatible', E_USER_DEPRECATED);
$this->log('emergency', $message, $context);
}
/**
* @deprecated
*/
public function crit($message, array $context = array())
{
trigger_error('Use critical() which is PSR-3 compatible', E_USER_DEPRECATED);
$this->log('critical', $message, $context);
}
/**
* @deprecated
*/
public function err($message, array $context = array())
{
trigger_error('Use error() which is PSR-3 compatible', E_USER_DEPRECATED);
$this->log('error', $message, $context);
}
/**
* @deprecated
*/
public function warn($message, array $context = array())
{
trigger_error('Use warning() which is PSR-3 compatible', E_USER_DEPRECATED);
$this->log('warning', $message, $context);
}
} }