update v 1.0.7.5
This commit is contained in:
@@ -11,7 +11,7 @@
|
||||
|
||||
namespace Symfony\Component\HttpKernel\Bundle;
|
||||
|
||||
use Symfony\Component\DependencyInjection\ContainerAware;
|
||||
use Symfony\Component\DependencyInjection\ContainerAwareTrait;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Container;
|
||||
use Symfony\Component\Console\Application;
|
||||
@@ -23,11 +23,11 @@ use Symfony\Component\DependencyInjection\Extension\ExtensionInterface;
|
||||
* for DependencyInjection extensions and Console commands.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
abstract class Bundle extends ContainerAware implements BundleInterface
|
||||
abstract class Bundle implements BundleInterface
|
||||
{
|
||||
use ContainerAwareTrait;
|
||||
|
||||
protected $name;
|
||||
protected $extension;
|
||||
protected $path;
|
||||
@@ -66,23 +66,21 @@ abstract class Bundle extends ContainerAware implements BundleInterface
|
||||
* @return ExtensionInterface|null The container extension
|
||||
*
|
||||
* @throws \LogicException
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function getContainerExtension()
|
||||
{
|
||||
if (null === $this->extension) {
|
||||
$class = $this->getContainerExtensionClass();
|
||||
if (class_exists($class)) {
|
||||
$extension = new $class();
|
||||
$extension = $this->createContainerExtension();
|
||||
|
||||
if (null !== $extension) {
|
||||
if (!$extension instanceof ExtensionInterface) {
|
||||
throw new \LogicException(sprintf('Extension %s must implement Symfony\Component\DependencyInjection\Extension\ExtensionInterface.', $class));
|
||||
throw new \LogicException(sprintf('Extension %s must implement Symfony\Component\DependencyInjection\Extension\ExtensionInterface.', get_class($extension)));
|
||||
}
|
||||
|
||||
// check naming convention
|
||||
$basename = preg_replace('/Bundle$/', '', $this->getName());
|
||||
$expectedAlias = Container::underscore($basename);
|
||||
|
||||
if ($expectedAlias != $extension->getAlias()) {
|
||||
throw new \LogicException(sprintf(
|
||||
'Users will expect the alias of the default extension of a bundle to be the underscored version of the bundle name ("%s"). You can override "Bundle::getContainerExtension()" if you want to use "%s" or another alias.',
|
||||
@@ -105,8 +103,6 @@ abstract class Bundle extends ContainerAware implements BundleInterface
|
||||
* Gets the Bundle namespace.
|
||||
*
|
||||
* @return string The Bundle namespace
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function getNamespace()
|
||||
{
|
||||
@@ -119,8 +115,6 @@ abstract class Bundle extends ContainerAware implements BundleInterface
|
||||
* Gets the Bundle directory path.
|
||||
*
|
||||
* @return string The Bundle absolute path
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function getPath()
|
||||
{
|
||||
@@ -136,8 +130,6 @@ abstract class Bundle extends ContainerAware implements BundleInterface
|
||||
* Returns the bundle parent name.
|
||||
*
|
||||
* @return string The Bundle parent name it overrides or null if no parent
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function getParent()
|
||||
{
|
||||
@@ -147,8 +139,6 @@ abstract class Bundle extends ContainerAware implements BundleInterface
|
||||
* Returns the bundle name (the class short name).
|
||||
*
|
||||
* @return string The Bundle name
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
final public function getName()
|
||||
{
|
||||
@@ -178,6 +168,10 @@ abstract class Bundle extends ContainerAware implements BundleInterface
|
||||
return;
|
||||
}
|
||||
|
||||
if (!class_exists('Symfony\Component\Finder\Finder')) {
|
||||
throw new \RuntimeException('You need the symfony/finder component to register bundle commands.');
|
||||
}
|
||||
|
||||
$finder = new Finder();
|
||||
$finder->files()->name('*Command.php')->in($dir);
|
||||
|
||||
@@ -185,7 +179,7 @@ abstract class Bundle extends ContainerAware implements BundleInterface
|
||||
foreach ($finder as $file) {
|
||||
$ns = $prefix;
|
||||
if ($relativePath = $file->getRelativePath()) {
|
||||
$ns .= '\\'.strtr($relativePath, '/', '\\');
|
||||
$ns .= '\\'.str_replace('/', '\\', $relativePath);
|
||||
}
|
||||
$class = $ns.'\\'.$file->getBasename('.php');
|
||||
if ($this->container) {
|
||||
@@ -212,4 +206,16 @@ abstract class Bundle extends ContainerAware implements BundleInterface
|
||||
|
||||
return $this->getNamespace().'\\DependencyInjection\\'.$basename.'Extension';
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the bundle's container extension.
|
||||
*
|
||||
* @return ExtensionInterface|null
|
||||
*/
|
||||
protected function createContainerExtension()
|
||||
{
|
||||
if (class_exists($class = $this->getContainerExtensionClass())) {
|
||||
return new $class();
|
||||
}
|
||||
}
|
||||
}
|
@@ -19,22 +19,16 @@ use Symfony\Component\DependencyInjection\Extension\ExtensionInterface;
|
||||
* BundleInterface.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
interface BundleInterface extends ContainerAwareInterface
|
||||
{
|
||||
/**
|
||||
* Boots the Bundle.
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function boot();
|
||||
|
||||
/**
|
||||
* Shutdowns the Bundle.
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function shutdown();
|
||||
|
||||
@@ -44,8 +38,6 @@ interface BundleInterface extends ContainerAwareInterface
|
||||
* It is only ever called once when the cache is empty.
|
||||
*
|
||||
* @param ContainerBuilder $container A ContainerBuilder instance
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function build(ContainerBuilder $container);
|
||||
|
||||
@@ -53,8 +45,6 @@ interface BundleInterface extends ContainerAwareInterface
|
||||
* Returns the container extension that should be implicitly loaded.
|
||||
*
|
||||
* @return ExtensionInterface|null The default extension or null if there is none
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function getContainerExtension();
|
||||
|
||||
@@ -66,8 +56,6 @@ interface BundleInterface extends ContainerAwareInterface
|
||||
* bundle.
|
||||
*
|
||||
* @return string The Bundle name it overrides or null if no parent
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function getParent();
|
||||
|
||||
@@ -75,8 +63,6 @@ interface BundleInterface extends ContainerAwareInterface
|
||||
* Returns the bundle name (the class short name).
|
||||
*
|
||||
* @return string The Bundle name
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function getName();
|
||||
|
||||
@@ -84,8 +70,6 @@ interface BundleInterface extends ContainerAwareInterface
|
||||
* Gets the Bundle namespace.
|
||||
*
|
||||
* @return string The Bundle namespace
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function getNamespace();
|
||||
|
||||
@@ -95,8 +79,6 @@ interface BundleInterface extends ContainerAwareInterface
|
||||
* The path should always be returned as a Unix path (with /).
|
||||
*
|
||||
* @return string The Bundle absolute path
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function getPath();
|
||||
}
|
@@ -1,6 +1,42 @@
|
||||
CHANGELOG
|
||||
=========
|
||||
|
||||
3.0.0
|
||||
-----
|
||||
|
||||
* removed `Symfony\Component\HttpKernel\Kernel::init()`
|
||||
* 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`
|
||||
* removed `Symfony\Component\HttpKernel\Profiler::import()`
|
||||
* removed `Symfony\Component\HttpKernel\Profiler::export()`
|
||||
|
||||
2.8.0
|
||||
-----
|
||||
|
||||
* deprecated `Profiler::import` and `Profiler::export`
|
||||
|
||||
2.7.0
|
||||
-----
|
||||
|
||||
* added the HTTP status code to profiles
|
||||
|
||||
2.6.0
|
||||
-----
|
||||
|
||||
@@ -24,7 +60,7 @@ CHANGELOG
|
||||
* [BC BREAK] renamed `Symfony\Component\HttpKernel\EventListener\DeprecationLoggerListener` to `Symfony\Component\HttpKernel\EventListener\ErrorsLoggerListener` and changed its constructor
|
||||
* deprecated `Symfony\Component\HttpKernel\Debug\ErrorHandler`, `Symfony\Component\HttpKernel\Debug\ExceptionHandler`,
|
||||
`Symfony\Component\HttpKernel\Exception\FatalErrorException` and `Symfony\Component\HttpKernel\Exception\FlattenException`
|
||||
* deprecated `Symfony\Component\HttpKernel\Kernel::init()``
|
||||
* deprecated `Symfony\Component\HttpKernel\Kernel::init()`
|
||||
* added the possibility to specify an id an extra attributes to hinclude tags
|
||||
* added the collect of data if a controller is a Closure in the Request collector
|
||||
* pass exceptions from the ExceptionListener to the logger using the logging context to allow for more
|
@@ -25,8 +25,6 @@ use Symfony\Component\HttpFoundation\Response;
|
||||
* Client simulates a browser and makes requests to a Kernel object.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
class Client extends BaseClient
|
||||
{
|
||||
@@ -107,7 +105,7 @@ class Client extends BaseClient
|
||||
$code = <<<EOF
|
||||
<?php
|
||||
|
||||
error_reporting($errorReporting & ~E_USER_DEPRECATED);
|
||||
error_reporting($errorReporting);
|
||||
|
||||
require_once '$requirePath';
|
||||
|
@@ -11,14 +11,14 @@
|
||||
|
||||
namespace Symfony\Component\HttpKernel\Config;
|
||||
|
||||
use Symfony\Component\Config\Resource\ResourceInterface;
|
||||
use Symfony\Component\Config\Resource\SelfCheckingResourceInterface;
|
||||
|
||||
/**
|
||||
* EnvParametersResource represents resources stored in prefixed environment variables.
|
||||
*
|
||||
* @author Chris Wilkinson <chriswilkinson84@gmail.com>
|
||||
*/
|
||||
class EnvParametersResource implements ResourceInterface, \Serializable
|
||||
class EnvParametersResource implements SelfCheckingResourceInterface, \Serializable
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
@@ -50,7 +50,7 @@ class EnvParametersResource implements ResourceInterface, \Serializable
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
* @return array An array with two keys: 'prefix' for the prefix used and 'variables' containing all the variables watched by this resource
|
||||
*/
|
||||
public function getResource()
|
||||
{
|
@@ -22,8 +22,6 @@ use Symfony\Component\HttpFoundation\Request;
|
||||
* the controller method arguments.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
class ControllerResolver implements ControllerResolverInterface
|
||||
{
|
||||
@@ -44,14 +42,12 @@ class ControllerResolver implements ControllerResolverInterface
|
||||
*
|
||||
* This method looks for a '_controller' request attribute that represents
|
||||
* the controller name (a string like ClassName::MethodName).
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function getController(Request $request)
|
||||
{
|
||||
if (!$controller = $request->attributes->get('_controller')) {
|
||||
if (null !== $this->logger) {
|
||||
$this->logger->warning('Unable to look for the controller as the "_controller" parameter is missing');
|
||||
$this->logger->warning('Unable to look for the controller as the "_controller" parameter is missing.');
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -80,7 +76,7 @@ class ControllerResolver implements ControllerResolverInterface
|
||||
$callable = $this->createController($controller);
|
||||
|
||||
if (!is_callable($callable)) {
|
||||
throw new \InvalidArgumentException(sprintf('Controller "%s" for URI "%s" is not callable.', $controller, $request->getPathInfo()));
|
||||
throw new \InvalidArgumentException(sprintf('The controller for URI "%s" is not callable. %s', $request->getPathInfo(), $this->getControllerError($callable)));
|
||||
}
|
||||
|
||||
return $callable;
|
||||
@@ -88,8 +84,6 @@ class ControllerResolver implements ControllerResolverInterface
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function getArguments(Request $request, $controller)
|
||||
{
|
||||
@@ -111,7 +105,11 @@ class ControllerResolver implements ControllerResolverInterface
|
||||
$arguments = array();
|
||||
foreach ($parameters as $param) {
|
||||
if (array_key_exists($param->name, $attributes)) {
|
||||
$arguments[] = $attributes[$param->name];
|
||||
if (PHP_VERSION_ID >= 50600 && $param->isVariadic() && is_array($attributes[$param->name])) {
|
||||
$arguments = array_merge($arguments, array_values($attributes[$param->name]));
|
||||
} else {
|
||||
$arguments[] = $attributes[$param->name];
|
||||
}
|
||||
} elseif ($param->getClass() && $param->getClass()->isInstance($request)) {
|
||||
$arguments[] = $request;
|
||||
} elseif ($param->isDefaultValueAvailable()) {
|
||||
@@ -137,7 +135,7 @@ class ControllerResolver implements ControllerResolverInterface
|
||||
*
|
||||
* @param string $controller A Controller string
|
||||
*
|
||||
* @return mixed A PHP callable
|
||||
* @return callable A PHP callable
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
@@ -157,7 +155,7 @@ class ControllerResolver implements ControllerResolverInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an instantiated controller
|
||||
* Returns an instantiated controller.
|
||||
*
|
||||
* @param string $class A class name
|
||||
*
|
||||
@@ -167,4 +165,65 @@ class ControllerResolver implements ControllerResolverInterface
|
||||
{
|
||||
return new $class();
|
||||
}
|
||||
|
||||
private function getControllerError($callable)
|
||||
{
|
||||
if (is_string($callable)) {
|
||||
if (false !== strpos($callable, '::')) {
|
||||
$callable = explode('::', $callable);
|
||||
}
|
||||
|
||||
if (class_exists($callable) && !method_exists($callable, '__invoke')) {
|
||||
return sprintf('Class "%s" does not have a method "__invoke".', $callable);
|
||||
}
|
||||
|
||||
if (!function_exists($callable)) {
|
||||
return sprintf('Function "%s" does not exist.', $callable);
|
||||
}
|
||||
}
|
||||
|
||||
if (!is_array($callable)) {
|
||||
return sprintf('Invalid type for controller given, expected string or array, got "%s".', gettype($callable));
|
||||
}
|
||||
|
||||
if (2 !== count($callable)) {
|
||||
return sprintf('Invalid format for controller, expected array(controller, method) or controller::method.');
|
||||
}
|
||||
|
||||
list($controller, $method) = $callable;
|
||||
|
||||
if (is_string($controller) && !class_exists($controller)) {
|
||||
return sprintf('Class "%s" does not exist.', $controller);
|
||||
}
|
||||
|
||||
$className = is_object($controller) ? get_class($controller) : $controller;
|
||||
|
||||
if (method_exists($controller, $method)) {
|
||||
return sprintf('Method "%s" on class "%s" should be public and non-abstract.', $method, $className);
|
||||
}
|
||||
|
||||
$collection = get_class_methods($controller);
|
||||
|
||||
$alternatives = array();
|
||||
|
||||
foreach ($collection as $item) {
|
||||
$lev = levenshtein($method, $item);
|
||||
|
||||
if ($lev <= strlen($method) / 3 || false !== strpos($item, $method)) {
|
||||
$alternatives[] = $item;
|
||||
}
|
||||
}
|
||||
|
||||
asort($alternatives);
|
||||
|
||||
$message = sprintf('Expected method "%s" on class "%s"', $method, $className);
|
||||
|
||||
if (count($alternatives) > 0) {
|
||||
$message .= sprintf(', did you mean "%s"?', implode('", "', $alternatives));
|
||||
} else {
|
||||
$message .= sprintf('. Available methods: "%s".', implode('", "', $collection));
|
||||
}
|
||||
|
||||
return $message;
|
||||
}
|
||||
}
|
@@ -22,8 +22,6 @@ use Symfony\Component\HttpFoundation\Request;
|
||||
* A Controller can be any valid PHP callable.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
interface ControllerResolverInterface
|
||||
{
|
||||
@@ -42,8 +40,6 @@ interface ControllerResolverInterface
|
||||
* or false if this resolver is not able to determine the controller
|
||||
*
|
||||
* @throws \LogicException If the controller can't be found
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function getController(Request $request);
|
||||
|
||||
@@ -56,8 +52,6 @@ interface ControllerResolverInterface
|
||||
* @return array An array of arguments to pass to the controller
|
||||
*
|
||||
* @throws \RuntimeException When value for argument given is not provided
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function getArguments(Request $request, $controller);
|
||||
}
|
33
vendor/symfony/http-kernel/DataCollector/AjaxDataCollector.php
vendored
Normal file
33
vendor/symfony/http-kernel/DataCollector/AjaxDataCollector.php
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
<?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\DataCollector;
|
||||
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
/**
|
||||
* AjaxDataCollector.
|
||||
*
|
||||
* @author Bart van den Burg <bart@burgov.nl>
|
||||
*/
|
||||
class AjaxDataCollector extends DataCollector
|
||||
{
|
||||
public function collect(Request $request, Response $response, \Exception $exception = null)
|
||||
{
|
||||
// all collecting is done client side
|
||||
}
|
||||
|
||||
public function getName()
|
||||
{
|
||||
return 'ajax';
|
||||
}
|
||||
}
|
@@ -23,9 +23,13 @@ use Symfony\Component\HttpFoundation\Response;
|
||||
*/
|
||||
class ConfigDataCollector extends DataCollector
|
||||
{
|
||||
/**
|
||||
* @var KernelInterface
|
||||
*/
|
||||
private $kernel;
|
||||
private $name;
|
||||
private $version;
|
||||
private $cacheVersionInfo = true;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
@@ -59,6 +63,7 @@ class ConfigDataCollector extends DataCollector
|
||||
'app_version' => $this->version,
|
||||
'token' => $response->headers->get('X-Debug-Token'),
|
||||
'symfony_version' => Kernel::VERSION,
|
||||
'symfony_state' => 'unknown',
|
||||
'name' => isset($this->kernel) ? $this->kernel->getName() : 'n/a',
|
||||
'env' => isset($this->kernel) ? $this->kernel->getEnvironment() : 'n/a',
|
||||
'debug' => isset($this->kernel) ? $this->kernel->isDebug() : 'n/a',
|
||||
@@ -70,13 +75,15 @@ class ConfigDataCollector extends DataCollector
|
||||
'wincache_enabled' => extension_loaded('wincache') && ini_get('wincache.ocenabled'),
|
||||
'zend_opcache_enabled' => extension_loaded('Zend OPcache') && ini_get('opcache.enable'),
|
||||
'bundles' => array(),
|
||||
'sapi_name' => php_sapi_name(),
|
||||
'sapi_name' => PHP_SAPI,
|
||||
);
|
||||
|
||||
if (isset($this->kernel)) {
|
||||
foreach ($this->kernel->getBundles() as $name => $bundle) {
|
||||
$this->data['bundles'][$name] = $bundle->getPath();
|
||||
}
|
||||
|
||||
$this->data['symfony_state'] = $this->determineSymfonyState();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -110,6 +117,21 @@ class ConfigDataCollector extends DataCollector
|
||||
return $this->data['symfony_version'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the state of the current Symfony release.
|
||||
*
|
||||
* @return string One of: unknown, dev, stable, eom, eol
|
||||
*/
|
||||
public function getSymfonyState()
|
||||
{
|
||||
return $this->data['symfony_state'];
|
||||
}
|
||||
|
||||
public function setCacheVersionInfo($cacheVersionInfo)
|
||||
{
|
||||
$this->cacheVersionInfo = $cacheVersionInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the PHP version.
|
||||
*
|
||||
@@ -242,4 +264,28 @@ class ConfigDataCollector extends DataCollector
|
||||
{
|
||||
return 'config';
|
||||
}
|
||||
|
||||
/**
|
||||
* Tries to retrieve information about the current Symfony version.
|
||||
*
|
||||
* @return string One of: dev, stable, eom, eol
|
||||
*/
|
||||
private function determineSymfonyState()
|
||||
{
|
||||
$now = new \DateTime();
|
||||
$eom = \DateTime::createFromFormat('m/Y', Kernel::END_OF_MAINTENANCE)->modify('last day of this month');
|
||||
$eol = \DateTime::createFromFormat('m/Y', Kernel::END_OF_LIFE)->modify('last day of this month');
|
||||
|
||||
if ($now > $eol) {
|
||||
$versionState = 'eol';
|
||||
} elseif ($now > $eom) {
|
||||
$versionState = 'eom';
|
||||
} elseif ('' !== Kernel::EXTRA_VERSION) {
|
||||
$versionState = 'dev';
|
||||
} else {
|
||||
$versionState = 'stable';
|
||||
}
|
||||
|
||||
return $versionState;
|
||||
}
|
||||
}
|
@@ -18,8 +18,6 @@ use Symfony\Component\HttpFoundation\Response;
|
||||
* DataCollectorInterface.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
interface DataCollectorInterface
|
||||
{
|
||||
@@ -29,8 +27,6 @@ interface DataCollectorInterface
|
||||
* @param Request $request A Request instance
|
||||
* @param Response $response A Response instance
|
||||
* @param \Exception $exception An Exception instance
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function collect(Request $request, Response $response, \Exception $exception = null);
|
||||
|
||||
@@ -38,8 +34,6 @@ interface DataCollectorInterface
|
||||
* Returns the name of the collector.
|
||||
*
|
||||
* @return string The collector name
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function getName();
|
||||
}
|
@@ -34,6 +34,7 @@ class DumpDataCollector extends DataCollector implements DataDumperInterface
|
||||
private $clonesIndex = 0;
|
||||
private $rootRefs;
|
||||
private $charset;
|
||||
private $requestStack;
|
||||
private $dumper;
|
||||
private $dumperIsInjected;
|
||||
|
||||
@@ -69,12 +70,7 @@ class DumpDataCollector extends DataCollector implements DataDumperInterface
|
||||
$this->isCollected = false;
|
||||
}
|
||||
|
||||
$trace = PHP_VERSION_ID >= 50306 ? DEBUG_BACKTRACE_PROVIDE_OBJECT | DEBUG_BACKTRACE_IGNORE_ARGS : true;
|
||||
if (PHP_VERSION_ID >= 50400) {
|
||||
$trace = debug_backtrace($trace, 7);
|
||||
} else {
|
||||
$trace = debug_backtrace($trace);
|
||||
}
|
||||
$trace = debug_backtrace(DEBUG_BACKTRACE_PROVIDE_OBJECT | DEBUG_BACKTRACE_IGNORE_ARGS, 7);
|
||||
|
||||
$file = $trace[0]['file'];
|
||||
$line = $trace[0]['line'];
|
||||
@@ -98,9 +94,9 @@ class DumpDataCollector extends DataCollector implements DataDumperInterface
|
||||
} elseif (isset($trace[$i]['object']) && $trace[$i]['object'] instanceof \Twig_Template) {
|
||||
$info = $trace[$i]['object'];
|
||||
$name = $info->getTemplateName();
|
||||
$src = $info->getEnvironment()->getLoader()->getSource($name);
|
||||
$src = method_exists($info, 'getSource') ? $info->getSource() : $info->getEnvironment()->getLoader()->getSource($name);
|
||||
$info = $info->getDebugInfo();
|
||||
if (isset($info[$trace[$i - 1]['line']])) {
|
||||
if (null !== $src && isset($info[$trace[$i - 1]['line']])) {
|
||||
$file = false;
|
||||
$line = $info[$trace[$i - 1]['line']];
|
||||
$src = explode("\n", $src);
|
||||
@@ -120,7 +116,7 @@ class DumpDataCollector extends DataCollector implements DataDumperInterface
|
||||
}
|
||||
|
||||
if (false === $name) {
|
||||
$name = strtr($file, '\\', '/');
|
||||
$name = str_replace('\\', '/', $file);
|
||||
$name = substr($name, strrpos($name, '/') + 1);
|
||||
}
|
||||
|
||||
@@ -204,7 +200,8 @@ class DumpDataCollector extends DataCollector implements DataDumperInterface
|
||||
$dumps = array();
|
||||
|
||||
foreach ($this->data as $dump) {
|
||||
$dumper->dump($dump['data']->getLimitedClone($maxDepthLimit, $maxItemsPerDepth));
|
||||
$dumper->dump($dump['data']->withMaxDepth($maxDepthLimit)->withMaxItemsPerDepth($maxItemsPerDepth));
|
||||
|
||||
rewind($data);
|
||||
$dump['data'] = stream_get_contents($data);
|
||||
ftruncate($data, 0);
|
||||
@@ -251,7 +248,7 @@ class DumpDataCollector extends DataCollector implements DataDumperInterface
|
||||
|
||||
private function doDump($data, $name, $file, $line)
|
||||
{
|
||||
if (PHP_VERSION_ID >= 50400 && $this->dumper instanceof CliDumper) {
|
||||
if ($this->dumper instanceof CliDumper) {
|
||||
$contextDumper = function ($name, $file, $line, $fileLinkFormat) {
|
||||
if ($this instanceof HtmlDumper) {
|
||||
if ('' !== $file) {
|
@@ -22,6 +22,24 @@ use Symfony\Component\HttpKernel\Log\DebugLoggerInterface;
|
||||
*/
|
||||
class LoggerDataCollector extends DataCollector implements LateDataCollectorInterface
|
||||
{
|
||||
private $errorNames = array(
|
||||
E_DEPRECATED => 'E_DEPRECATED',
|
||||
E_USER_DEPRECATED => 'E_USER_DEPRECATED',
|
||||
E_NOTICE => 'E_NOTICE',
|
||||
E_USER_NOTICE => 'E_USER_NOTICE',
|
||||
E_STRICT => 'E_STRICT',
|
||||
E_WARNING => 'E_WARNING',
|
||||
E_USER_WARNING => 'E_USER_WARNING',
|
||||
E_COMPILE_WARNING => 'E_COMPILE_WARNING',
|
||||
E_CORE_WARNING => 'E_CORE_WARNING',
|
||||
E_USER_ERROR => 'E_USER_ERROR',
|
||||
E_RECOVERABLE_ERROR => 'E_RECOVERABLE_ERROR',
|
||||
E_COMPILE_ERROR => 'E_COMPILE_ERROR',
|
||||
E_PARSE => 'E_PARSE',
|
||||
E_ERROR => 'E_ERROR',
|
||||
E_CORE_ERROR => 'E_CORE_ERROR',
|
||||
);
|
||||
|
||||
private $logger;
|
||||
|
||||
public function __construct($logger = null)
|
||||
@@ -97,15 +115,49 @@ class LoggerDataCollector extends DataCollector implements LateDataCollectorInte
|
||||
|
||||
private function sanitizeLogs($logs)
|
||||
{
|
||||
foreach ($logs as $i => $log) {
|
||||
$errorContextById = array();
|
||||
$sanitizedLogs = array();
|
||||
|
||||
foreach ($logs as $log) {
|
||||
$context = $this->sanitizeContext($log['context']);
|
||||
if (isset($context['type'], $context['level']) && !($context['type'] & $context['level'])) {
|
||||
$context['scream'] = true;
|
||||
|
||||
if (isset($context['type'], $context['file'], $context['line'], $context['level'])) {
|
||||
$errorId = md5("{$context['type']}/{$context['line']}/{$context['file']}\x00{$log['message']}", true);
|
||||
$silenced = !($context['type'] & $context['level']);
|
||||
if (isset($this->errorNames[$context['type']])) {
|
||||
$context = array_merge(array('name' => $this->errorNames[$context['type']]), $context);
|
||||
}
|
||||
|
||||
if (isset($errorContextById[$errorId])) {
|
||||
if (isset($errorContextById[$errorId]['errorCount'])) {
|
||||
++$errorContextById[$errorId]['errorCount'];
|
||||
} else {
|
||||
$errorContextById[$errorId]['errorCount'] = 2;
|
||||
}
|
||||
|
||||
if (!$silenced && isset($errorContextById[$errorId]['scream'])) {
|
||||
unset($errorContextById[$errorId]['scream']);
|
||||
$errorContextById[$errorId]['level'] = $context['level'];
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
$errorContextById[$errorId] = &$context;
|
||||
if ($silenced) {
|
||||
$context['scream'] = true;
|
||||
}
|
||||
|
||||
$log['context'] = &$context;
|
||||
unset($context);
|
||||
} else {
|
||||
$log['context'] = $context;
|
||||
}
|
||||
$logs[$i]['context'] = $context;
|
||||
|
||||
$sanitizedLogs[] = $log;
|
||||
}
|
||||
|
||||
return $logs;
|
||||
return $sanitizedLogs;
|
||||
}
|
||||
|
||||
private function sanitizeContext($context)
|
@@ -117,6 +117,10 @@ class RequestDataCollector extends DataCollector implements EventSubscriberInter
|
||||
$this->data['request_server']['PHP_AUTH_PW'] = '******';
|
||||
}
|
||||
|
||||
if (isset($this->data['request_request']['_password'])) {
|
||||
$this->data['request_request']['_password'] = '******';
|
||||
}
|
||||
|
||||
if (isset($this->controllers[$request])) {
|
||||
$controller = $this->controllers[$request];
|
||||
if (is_array($controller)) {
|
@@ -28,13 +28,17 @@ class ValueExporter
|
||||
public function exportValue($value, $depth = 1, $deep = false)
|
||||
{
|
||||
if (is_object($value)) {
|
||||
if ($value instanceof \DateTime || $value instanceof \DateTimeInterface) {
|
||||
if ($value instanceof \DateTimeInterface) {
|
||||
return sprintf('Object(%s) - %s', get_class($value), $value->format(\DateTime::ISO8601));
|
||||
}
|
||||
|
||||
return sprintf('Object(%s)', get_class($value));
|
||||
}
|
||||
|
||||
if ($value instanceof \__PHP_Incomplete_Class) {
|
||||
return sprintf('__PHP_Incomplete_Class(%s)', $this->getClassNameFromIncomplete($value));
|
||||
}
|
||||
|
||||
if (is_array($value)) {
|
||||
if (empty($value)) {
|
||||
return '[]';
|
||||
@@ -54,7 +58,7 @@ class ValueExporter
|
||||
return sprintf("[\n%s%s\n%s]", $indent, implode(sprintf(", \n%s", $indent), $a), str_repeat(' ', $depth - 1));
|
||||
}
|
||||
|
||||
return sprintf("[%s]", implode(', ', $a));
|
||||
return sprintf('[%s]', implode(', ', $a));
|
||||
}
|
||||
|
||||
if (is_resource($value)) {
|
||||
@@ -75,4 +79,11 @@ class ValueExporter
|
||||
|
||||
return (string) $value;
|
||||
}
|
||||
|
||||
private function getClassNameFromIncomplete(\__PHP_Incomplete_Class $value)
|
||||
{
|
||||
$array = new \ArrayObject($value);
|
||||
|
||||
return $array['__PHP_Incomplete_Class_Name'];
|
||||
}
|
||||
}
|
@@ -12,7 +12,6 @@
|
||||
namespace Symfony\Component\HttpKernel\Debug;
|
||||
|
||||
use Symfony\Component\EventDispatcher\Debug\TraceableEventDispatcher as BaseTraceableEventDispatcher;
|
||||
use Symfony\Component\HttpKernel\Profiler\Profiler;
|
||||
use Symfony\Component\HttpKernel\KernelEvents;
|
||||
use Symfony\Component\EventDispatcher\Event;
|
||||
|
||||
@@ -25,21 +24,6 @@ use Symfony\Component\EventDispatcher\Event;
|
||||
*/
|
||||
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 Deprecated since version 2.4, to be removed in 3.0.
|
||||
*/
|
||||
public function setProfiler(Profiler $profiler = null)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
@@ -17,11 +17,11 @@ use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
* This extension sub-class provides first-class integration with the
|
||||
* Config/Definition Component.
|
||||
*
|
||||
* You can use this as base class if you
|
||||
* You can use this as base class if
|
||||
*
|
||||
* a) use the Config/Definition component for configuration
|
||||
* b) your configuration class is named "Configuration" and
|
||||
* c) the configuration class resides in the DependencyInjection sub-folder
|
||||
* a) you use the Config/Definition component for configuration,
|
||||
* b) your configuration class is named "Configuration", and
|
||||
* c) the configuration class resides in the DependencyInjection sub-folder.
|
||||
*
|
||||
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
||||
*/
|
65
vendor/symfony/http-kernel/DependencyInjection/FragmentRendererPass.php
vendored
Normal file
65
vendor/symfony/http-kernel/DependencyInjection/FragmentRendererPass.php
vendored
Normal file
@@ -0,0 +1,65 @@
|
||||
<?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\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
|
||||
|
||||
/**
|
||||
* Adds services tagged kernel.fragment_renderer as HTTP content rendering strategies.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*/
|
||||
class FragmentRendererPass implements CompilerPassInterface
|
||||
{
|
||||
private $handlerService;
|
||||
private $rendererTag;
|
||||
|
||||
/**
|
||||
* @param string $handlerService Service name of the fragment handler in the container
|
||||
* @param string $rendererTag Tag name used for fragments
|
||||
*/
|
||||
public function __construct($handlerService = 'fragment.handler', $rendererTag = 'kernel.fragment_renderer')
|
||||
{
|
||||
$this->handlerService = $handlerService;
|
||||
$this->rendererTag = $rendererTag;
|
||||
}
|
||||
|
||||
public function process(ContainerBuilder $container)
|
||||
{
|
||||
if (!$container->hasDefinition($this->handlerService)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$definition = $container->getDefinition($this->handlerService);
|
||||
foreach ($container->findTaggedServiceIds($this->rendererTag) as $id => $tags) {
|
||||
$def = $container->getDefinition($id);
|
||||
if (!$def->isPublic()) {
|
||||
throw new \InvalidArgumentException(sprintf('The service "%s" must be public as fragment renderer are lazy-loaded.', $id));
|
||||
}
|
||||
|
||||
if ($def->isAbstract()) {
|
||||
throw new \InvalidArgumentException(sprintf('The service "%s" must not be abstract as fragment renderer are lazy-loaded.', $id));
|
||||
}
|
||||
|
||||
$class = $container->getParameterBag()->resolveValue($def->getClass());
|
||||
$interface = 'Symfony\Component\HttpKernel\Fragment\FragmentRendererInterface';
|
||||
if (!is_subclass_of($class, $interface)) {
|
||||
throw new \InvalidArgumentException(sprintf('Service "%s" must implement interface "%s".', $id, $interface));
|
||||
}
|
||||
|
||||
foreach ($tags as $tag) {
|
||||
$definition->addMethodCall('addRendererService', array($tag['alias'], $id));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
65
vendor/symfony/http-kernel/DependencyInjection/LazyLoadingFragmentHandler.php
vendored
Normal file
65
vendor/symfony/http-kernel/DependencyInjection/LazyLoadingFragmentHandler.php
vendored
Normal file
@@ -0,0 +1,65 @@
|
||||
<?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\DependencyInjection\ContainerInterface;
|
||||
use Symfony\Component\HttpFoundation\RequestStack;
|
||||
use Symfony\Component\HttpKernel\Fragment\FragmentHandler;
|
||||
|
||||
/**
|
||||
* Lazily loads fragment renderers from the dependency injection container.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*/
|
||||
class LazyLoadingFragmentHandler extends FragmentHandler
|
||||
{
|
||||
private $container;
|
||||
private $rendererIds = array();
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param ContainerInterface $container A container
|
||||
* @param RequestStack $requestStack The Request stack that controls the lifecycle of requests
|
||||
* @param bool $debug Whether the debug mode is enabled or not
|
||||
*/
|
||||
public function __construct(ContainerInterface $container, RequestStack $requestStack, $debug = false)
|
||||
{
|
||||
$this->container = $container;
|
||||
|
||||
parent::__construct($requestStack, array(), $debug);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a service as a fragment renderer.
|
||||
*
|
||||
* @param string $renderer The render service id
|
||||
*/
|
||||
public function addRendererService($name, $renderer)
|
||||
{
|
||||
$this->rendererIds[$name] = $renderer;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function render($uri, $renderer = 'inline', array $options = array())
|
||||
{
|
||||
if (isset($this->rendererIds[$renderer])) {
|
||||
$this->addRenderer($this->container->get($this->rendererIds[$renderer]));
|
||||
|
||||
unset($this->rendererIds[$renderer]);
|
||||
}
|
||||
|
||||
return parent::render($uri, $renderer, $options);
|
||||
}
|
||||
}
|
@@ -24,19 +24,15 @@ use Symfony\Component\HttpFoundation\Request;
|
||||
* Controllers should be callables.
|
||||
*
|
||||
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
class FilterControllerEvent extends KernelEvent
|
||||
{
|
||||
/**
|
||||
* The current controller.
|
||||
*
|
||||
* @var callable
|
||||
*/
|
||||
private $controller;
|
||||
|
||||
public function __construct(HttpKernelInterface $kernel, $controller, Request $request, $requestType)
|
||||
public function __construct(HttpKernelInterface $kernel, callable $controller, Request $request, $requestType)
|
||||
{
|
||||
parent::__construct($kernel, $request, $requestType);
|
||||
|
||||
@@ -47,8 +43,6 @@ class FilterControllerEvent extends KernelEvent
|
||||
* Returns the current controller.
|
||||
*
|
||||
* @return callable
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function getController()
|
||||
{
|
||||
@@ -61,50 +55,9 @@ class FilterControllerEvent extends KernelEvent
|
||||
* @param callable $controller
|
||||
*
|
||||
* @throws \LogicException
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function setController($controller)
|
||||
public function setController(callable $controller)
|
||||
{
|
||||
// controller must be a callable
|
||||
if (!is_callable($controller)) {
|
||||
throw new \LogicException(sprintf('The controller must be a callable (%s given).', $this->varToString($controller)));
|
||||
}
|
||||
|
||||
$this->controller = $controller;
|
||||
}
|
||||
|
||||
private function varToString($var)
|
||||
{
|
||||
if (is_object($var)) {
|
||||
return sprintf('Object(%s)', get_class($var));
|
||||
}
|
||||
|
||||
if (is_array($var)) {
|
||||
$a = array();
|
||||
foreach ($var as $k => $v) {
|
||||
$a[] = sprintf('%s => %s', $k, $this->varToString($v));
|
||||
}
|
||||
|
||||
return sprintf('Array(%s)', implode(', ', $a));
|
||||
}
|
||||
|
||||
if (is_resource($var)) {
|
||||
return sprintf('Resource(%s)', get_resource_type($var));
|
||||
}
|
||||
|
||||
if (null === $var) {
|
||||
return 'null';
|
||||
}
|
||||
|
||||
if (false === $var) {
|
||||
return 'false';
|
||||
}
|
||||
|
||||
if (true === $var) {
|
||||
return 'true';
|
||||
}
|
||||
|
||||
return (string) $var;
|
||||
}
|
||||
}
|
@@ -23,8 +23,6 @@ use Symfony\Component\HttpFoundation\Response;
|
||||
* browser.
|
||||
*
|
||||
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
class FilterResponseEvent extends KernelEvent
|
||||
{
|
||||
@@ -46,8 +44,6 @@ class FilterResponseEvent extends KernelEvent
|
||||
* Returns the current response object.
|
||||
*
|
||||
* @return Response
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function getResponse()
|
||||
{
|
||||
@@ -58,8 +54,6 @@ class FilterResponseEvent extends KernelEvent
|
||||
* Sets a new response object.
|
||||
*
|
||||
* @param Response $response
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function setResponse(Response $response)
|
||||
{
|
@@ -21,8 +21,6 @@ use Symfony\Component\HttpFoundation\Response;
|
||||
* response is set.
|
||||
*
|
||||
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
class GetResponseEvent extends KernelEvent
|
||||
{
|
||||
@@ -37,8 +35,6 @@ class GetResponseEvent extends KernelEvent
|
||||
* Returns the response object.
|
||||
*
|
||||
* @return Response
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function getResponse()
|
||||
{
|
||||
@@ -49,8 +45,6 @@ class GetResponseEvent extends KernelEvent
|
||||
* Sets a response and stops event propagation.
|
||||
*
|
||||
* @param Response $response
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function setResponse(Response $response)
|
||||
{
|
||||
@@ -63,8 +57,6 @@ class GetResponseEvent extends KernelEvent
|
||||
* Returns whether a response was set.
|
||||
*
|
||||
* @return bool Whether a response was set
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function hasResponse()
|
||||
{
|
@@ -22,8 +22,6 @@ use Symfony\Component\HttpFoundation\Request;
|
||||
* response is set.
|
||||
*
|
||||
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
class GetResponseForControllerResultEvent extends GetResponseEvent
|
||||
{
|
||||
@@ -45,8 +43,6 @@ class GetResponseForControllerResultEvent extends GetResponseEvent
|
||||
* Returns the return value of the controller.
|
||||
*
|
||||
* @return mixed The controller return value
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function getControllerResult()
|
||||
{
|
||||
@@ -57,8 +53,6 @@ class GetResponseForControllerResultEvent extends GetResponseEvent
|
||||
* Assigns the return value of the controller.
|
||||
*
|
||||
* @param mixed $controllerResult The controller return value
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function setControllerResult($controllerResult)
|
||||
{
|
@@ -26,8 +26,6 @@ use Symfony\Component\HttpFoundation\Request;
|
||||
* event.
|
||||
*
|
||||
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
class GetResponseForExceptionEvent extends GetResponseEvent
|
||||
{
|
||||
@@ -49,8 +47,6 @@ class GetResponseForExceptionEvent extends GetResponseEvent
|
||||
* Returns the thrown exception.
|
||||
*
|
||||
* @return \Exception The thrown exception
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function getException()
|
||||
{
|
||||
@@ -63,8 +59,6 @@ class GetResponseForExceptionEvent extends GetResponseEvent
|
||||
* This exception will be thrown if no response is set in the event.
|
||||
*
|
||||
* @param \Exception $exception The thrown exception
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function setException(\Exception $exception)
|
||||
{
|
@@ -19,8 +19,6 @@ use Symfony\Component\EventDispatcher\Event;
|
||||
* Base class for events thrown in the HttpKernel component.
|
||||
*
|
||||
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
class KernelEvent extends Event
|
||||
{
|
||||
@@ -57,8 +55,6 @@ class KernelEvent extends Event
|
||||
* Returns the kernel in which this event was thrown.
|
||||
*
|
||||
* @return HttpKernelInterface
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function getKernel()
|
||||
{
|
||||
@@ -69,8 +65,6 @@ class KernelEvent extends Event
|
||||
* Returns the request the kernel is currently processing.
|
||||
*
|
||||
* @return Request
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function getRequest()
|
||||
{
|
||||
@@ -82,8 +76,6 @@ class KernelEvent extends Event
|
||||
*
|
||||
* @return int One of HttpKernelInterface::MASTER_REQUEST and
|
||||
* HttpKernelInterface::SUB_REQUEST
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function getRequestType()
|
||||
{
|
||||
@@ -94,8 +86,6 @@ class KernelEvent extends Event
|
||||
* Checks if this is a master request.
|
||||
*
|
||||
* @return bool True if the request is a master request
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function isMasterRequest()
|
||||
{
|
@@ -12,55 +12,28 @@
|
||||
namespace Symfony\Component\HttpKernel\Event;
|
||||
|
||||
use Symfony\Component\HttpKernel\HttpKernelInterface;
|
||||
use Symfony\Component\EventDispatcher\Event;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
/**
|
||||
* Allows to execute logic after a response was sent.
|
||||
*
|
||||
* Since it's only triggered on master requests, the `getRequestType()` method
|
||||
* will always return the value of `HttpKernelInterface::MASTER_REQUEST`.
|
||||
*
|
||||
* @author Jordi Boggiano <j.boggiano@seld.be>
|
||||
*/
|
||||
class PostResponseEvent extends Event
|
||||
class PostResponseEvent extends KernelEvent
|
||||
{
|
||||
/**
|
||||
* The kernel in which this event was thrown.
|
||||
*
|
||||
* @var HttpKernelInterface
|
||||
*/
|
||||
private $kernel;
|
||||
|
||||
private $request;
|
||||
|
||||
private $response;
|
||||
|
||||
public function __construct(HttpKernelInterface $kernel, Request $request, Response $response)
|
||||
{
|
||||
$this->kernel = $kernel;
|
||||
$this->request = $request;
|
||||
parent::__construct($kernel, $request, HttpKernelInterface::MASTER_REQUEST);
|
||||
|
||||
$this->response = $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the kernel in which this event was thrown.
|
||||
*
|
||||
* @return HttpKernelInterface
|
||||
*/
|
||||
public function getKernel()
|
||||
{
|
||||
return $this->kernel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the request for which this event was thrown.
|
||||
*
|
||||
* @return Request
|
||||
*/
|
||||
public function getRequest()
|
||||
{
|
||||
return $this->request;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the response for which this event was thrown.
|
||||
*
|
@@ -16,7 +16,7 @@ use Symfony\Component\HttpKernel\KernelEvents;
|
||||
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
|
||||
|
||||
/**
|
||||
* Adds configured formats to each request
|
||||
* Adds configured formats to each request.
|
||||
*
|
||||
* @author Gildas Quemener <gildas.quemener@gmail.com>
|
||||
*/
|
||||
@@ -36,7 +36,7 @@ class AddRequestFormatsListener implements EventSubscriberInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds request formats
|
||||
* Adds request formats.
|
||||
*
|
||||
* @param GetResponseEvent $event
|
||||
*/
|
@@ -45,12 +45,12 @@ class DebugHandlersListener implements EventSubscriberInterface
|
||||
* @param bool $scream Enables/disables screaming mode, where even silenced errors are logged
|
||||
* @param string $fileLinkFormat The format for links to source files
|
||||
*/
|
||||
public function __construct($exceptionHandler, LoggerInterface $logger = null, $levels = null, $throwAt = -1, $scream = true, $fileLinkFormat = null)
|
||||
public function __construct(callable $exceptionHandler = null, LoggerInterface $logger = null, $levels = E_ALL, $throwAt = E_ALL, $scream = true, $fileLinkFormat = null)
|
||||
{
|
||||
$this->exceptionHandler = $exceptionHandler;
|
||||
$this->logger = $logger;
|
||||
$this->levels = $levels;
|
||||
$this->throwAt = is_numeric($throwAt) ? (int) $throwAt : (null === $throwAt ? null : ($throwAt ? -1 : null));
|
||||
$this->levels = null === $levels ? E_ALL : $levels;
|
||||
$this->throwAt = is_numeric($throwAt) ? (int) $throwAt : (null === $throwAt ? null : ($throwAt ? E_ALL : null));
|
||||
$this->scream = (bool) $scream;
|
||||
$this->fileLinkFormat = $fileLinkFormat ?: ini_get('xdebug.file_link_format') ?: get_cfg_var('xdebug.file_link_format');
|
||||
}
|
||||
@@ -67,7 +67,7 @@ class DebugHandlersListener implements EventSubscriberInterface
|
||||
}
|
||||
$this->firstCall = false;
|
||||
if ($this->logger || null !== $this->throwAt) {
|
||||
$handler = set_error_handler('var_dump', 0);
|
||||
$handler = set_error_handler('var_dump');
|
||||
$handler = is_array($handler) ? $handler[0] : null;
|
||||
restore_error_handler();
|
||||
if ($handler instanceof ErrorHandler) {
|
||||
@@ -79,7 +79,7 @@ class DebugHandlersListener implements EventSubscriberInterface
|
||||
$scream |= $type;
|
||||
}
|
||||
} else {
|
||||
$scream = null === $this->levels ? E_ALL | E_STRICT : $this->levels;
|
||||
$scream = $this->levels;
|
||||
}
|
||||
if ($this->scream) {
|
||||
$handler->screamAt($scream);
|
||||
@@ -93,7 +93,9 @@ class DebugHandlersListener implements EventSubscriberInterface
|
||||
}
|
||||
if (!$this->exceptionHandler) {
|
||||
if ($event instanceof KernelEvent) {
|
||||
$this->exceptionHandler = array($event->getKernel(), 'terminateWithException');
|
||||
if (method_exists($event->getKernel(), 'terminateWithException')) {
|
||||
$this->exceptionHandler = array($event->getKernel(), 'terminateWithException');
|
||||
}
|
||||
} elseif ($event instanceof ConsoleEvent && $app = $event->getCommand()->getApplication()) {
|
||||
$output = $event->getOutput();
|
||||
if ($output instanceof ConsoleOutputInterface) {
|
@@ -49,7 +49,7 @@ class ExceptionListener implements EventSubscriberInterface
|
||||
try {
|
||||
$response = $event->getKernel()->handle($request, HttpKernelInterface::SUB_REQUEST, false);
|
||||
} catch (\Exception $e) {
|
||||
$this->logException($e, sprintf('Exception thrown when handling an exception (%s: %s at %s line %s)', get_class($e), $e->getMessage(), $e->getFile(), $e->getLine()), false);
|
||||
$this->logException($e, sprintf('Exception thrown when handling an exception (%s: %s at %s line %s)', get_class($e), $e->getMessage(), $e->getFile(), $e->getLine()));
|
||||
|
||||
$wrapper = $e;
|
||||
|
||||
@@ -81,20 +81,15 @@ class ExceptionListener implements EventSubscriberInterface
|
||||
*
|
||||
* @param \Exception $exception The \Exception instance
|
||||
* @param string $message The error message to log
|
||||
* @param bool $original False when the handling of the exception thrown another exception
|
||||
*/
|
||||
protected function logException(\Exception $exception, $message, $original = true)
|
||||
protected function logException(\Exception $exception, $message)
|
||||
{
|
||||
$isCritical = !$exception instanceof HttpExceptionInterface || $exception->getStatusCode() >= 500;
|
||||
$context = array('exception' => $exception);
|
||||
if (null !== $this->logger) {
|
||||
if ($isCritical) {
|
||||
$this->logger->critical($message, $context);
|
||||
if (!$exception instanceof HttpExceptionInterface || $exception->getStatusCode() >= 500) {
|
||||
$this->logger->critical($message, array('exception' => $exception));
|
||||
} else {
|
||||
$this->logger->error($message, $context);
|
||||
$this->logger->error($message, array('exception' => $exception));
|
||||
}
|
||||
} elseif (!$original || $isCritical) {
|
||||
error_log($message);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -112,10 +107,6 @@ class ExceptionListener implements EventSubscriberInterface
|
||||
'_controller' => $this->controller,
|
||||
'exception' => FlattenException::create($exception),
|
||||
'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 in 2.4, to be removed in 3.0
|
||||
'format' => $request->getRequestFormat(),
|
||||
);
|
||||
$request = $request->duplicate(null, null, $attributes);
|
||||
$request->setMethod('GET');
|
@@ -57,7 +57,14 @@ class FragmentListener implements EventSubscriberInterface
|
||||
{
|
||||
$request = $event->getRequest();
|
||||
|
||||
if ($request->attributes->has('_controller') || $this->fragmentPath !== rawurldecode($request->getPathInfo())) {
|
||||
if ($this->fragmentPath !== rawurldecode($request->getPathInfo())) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ($request->attributes->has('_controller')) {
|
||||
// Is a sub-request: no need to parse _path but it should still be removed from query parameters as below.
|
||||
$request->query->remove('_path');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -87,16 +94,6 @@ class FragmentListener implements EventSubscriberInterface
|
||||
throw new AccessDeniedHttpException();
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Deprecated since 2.3.19, to be removed in 3.0.
|
||||
*
|
||||
* @return string[]
|
||||
*/
|
||||
protected function getLocalIpAddresses()
|
||||
{
|
||||
return array('127.0.0.1', 'fe80::1', '::1');
|
||||
}
|
||||
|
||||
public static function getSubscribedEvents()
|
||||
{
|
||||
return array(
|
@@ -22,11 +22,6 @@ use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||
/**
|
||||
* Initializes the locale based on the current request.
|
||||
*
|
||||
* This listener works in 2 modes:
|
||||
*
|
||||
* * 2.3 compatibility mode where you must call setRequest whenever the Request changes.
|
||||
* * 2.4+ mode where you must pass a RequestStack instance in the constructor.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*/
|
||||
class LocaleListener implements EventSubscriberInterface
|
||||
@@ -36,36 +31,19 @@ class LocaleListener implements EventSubscriberInterface
|
||||
private $requestStack;
|
||||
|
||||
/**
|
||||
* RequestStack will become required in 3.0.
|
||||
* Constructor.
|
||||
*
|
||||
* @param RequestStack $requestStack A RequestStack instance
|
||||
* @param string $defaultLocale The default locale
|
||||
* @param RequestContextAwareInterface|null $router The router
|
||||
*/
|
||||
public function __construct($defaultLocale = 'en', RequestContextAwareInterface $router = null, RequestStack $requestStack = null)
|
||||
public function __construct(RequestStack $requestStack, $defaultLocale = 'en', RequestContextAwareInterface $router = null)
|
||||
{
|
||||
$this->defaultLocale = $defaultLocale;
|
||||
$this->requestStack = $requestStack;
|
||||
$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 Deprecated since version 2.4, to be removed in 3.0.
|
||||
*/
|
||||
public function setRequest(Request $request = null)
|
||||
{
|
||||
if (null === $request) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->setLocale($request);
|
||||
$this->setRouterContext($request);
|
||||
}
|
||||
|
||||
public function onKernelRequest(GetResponseEvent $event)
|
||||
{
|
||||
$request = $event->getRequest();
|
||||
@@ -77,10 +55,6 @@ class LocaleListener implements EventSubscriberInterface
|
||||
|
||||
public function onKernelFinishRequest(FinishRequestEvent $event)
|
||||
{
|
||||
if (null === $this->requestStack) {
|
||||
return; // removed when requestStack is required
|
||||
}
|
||||
|
||||
if (null !== $parentRequest = $this->requestStack->getParentRequest()) {
|
||||
$this->setRouterContext($parentRequest);
|
||||
}
|
@@ -11,7 +11,6 @@
|
||||
|
||||
namespace Symfony\Component\HttpKernel\EventListener;
|
||||
|
||||
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
|
||||
use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent;
|
||||
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
|
||||
use Symfony\Component\HttpKernel\Event\PostResponseEvent;
|
||||
@@ -22,7 +21,7 @@ use Symfony\Component\HttpFoundation\RequestStack;
|
||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||
|
||||
/**
|
||||
* ProfilerListener collects data for the current request by listening to the onKernelResponse event.
|
||||
* ProfilerListener collects data for the current request by listening to the kernel events.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*/
|
||||
@@ -33,7 +32,6 @@ class ProfilerListener implements EventSubscriberInterface
|
||||
protected $onlyException;
|
||||
protected $onlyMasterRequests;
|
||||
protected $exception;
|
||||
protected $requests = array();
|
||||
protected $profiles;
|
||||
protected $requestStack;
|
||||
protected $parents;
|
||||
@@ -42,12 +40,12 @@ class ProfilerListener implements EventSubscriberInterface
|
||||
* Constructor.
|
||||
*
|
||||
* @param Profiler $profiler A Profiler instance
|
||||
* @param RequestStack $requestStack A RequestStack instance
|
||||
* @param RequestMatcherInterface|null $matcher A RequestMatcher instance
|
||||
* @param bool $onlyException true if the profiler only collects data when an exception occurs, false otherwise
|
||||
* @param bool $onlyMasterRequests true if the profiler only collects data when the request is a master request, false otherwise
|
||||
* @param RequestStack|null $requestStack A RequestStack instance
|
||||
*/
|
||||
public function __construct(Profiler $profiler, RequestMatcherInterface $matcher = null, $onlyException = false, $onlyMasterRequests = false, RequestStack $requestStack = null)
|
||||
public function __construct(Profiler $profiler, RequestStack $requestStack, RequestMatcherInterface $matcher = null, $onlyException = false, $onlyMasterRequests = false)
|
||||
{
|
||||
$this->profiler = $profiler;
|
||||
$this->matcher = $matcher;
|
||||
@@ -72,16 +70,6 @@ class ProfilerListener implements EventSubscriberInterface
|
||||
$this->exception = $event->getException();
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated 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.
|
||||
*
|
||||
@@ -112,14 +100,7 @@ class ProfilerListener implements EventSubscriberInterface
|
||||
|
||||
$this->profiles[$request] = $profile;
|
||||
|
||||
if (null !== $this->requestStack) {
|
||||
$this->parents[$request] = $this->requestStack->getParentRequest();
|
||||
} elseif (!$master) {
|
||||
// to be removed when requestStack is required
|
||||
array_pop($this->requests);
|
||||
|
||||
$this->parents[$request] = end($this->requests);
|
||||
}
|
||||
$this->parents[$request] = $this->requestStack->getParentRequest();
|
||||
}
|
||||
|
||||
public function onKernelTerminate(PostResponseEvent $event)
|
||||
@@ -141,15 +122,11 @@ class ProfilerListener implements EventSubscriberInterface
|
||||
|
||||
$this->profiles = new \SplObjectStorage();
|
||||
$this->parents = new \SplObjectStorage();
|
||||
$this->requests = array();
|
||||
}
|
||||
|
||||
public static function getSubscribedEvents()
|
||||
{
|
||||
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::EXCEPTION => 'onKernelException',
|
||||
KernelEvents::TERMINATE => array('onKernelTerminate', -1024),
|
@@ -30,11 +30,6 @@ use Symfony\Component\HttpFoundation\Request;
|
||||
/**
|
||||
* Initializes the context from the request and sets request attributes based on a matching route.
|
||||
*
|
||||
* This listener works in 2 modes:
|
||||
*
|
||||
* * 2.3 compatibility mode where you must call setRequest whenever the Request changes.
|
||||
* * 2.4+ mode where you must pass a RequestStack instance in the constructor.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*/
|
||||
class RouterListener implements EventSubscriberInterface
|
||||
@@ -42,22 +37,19 @@ class RouterListener implements EventSubscriberInterface
|
||||
private $matcher;
|
||||
private $context;
|
||||
private $logger;
|
||||
private $request;
|
||||
private $requestStack;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* RequestStack will become required in 3.0.
|
||||
*
|
||||
* @param UrlMatcherInterface|RequestMatcherInterface $matcher The Url or Request matcher
|
||||
* @param RequestStack $requestStack A RequestStack instance
|
||||
* @param RequestContext|null $context The RequestContext (can be null when $matcher implements RequestContextAwareInterface)
|
||||
* @param LoggerInterface|null $logger The logger
|
||||
* @param RequestStack|null $requestStack A RequestStack instance
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
public function __construct($matcher, RequestContext $context = null, LoggerInterface $logger = null, RequestStack $requestStack = null)
|
||||
public function __construct($matcher, RequestStack $requestStack, RequestContext $context = null, LoggerInterface $logger = null)
|
||||
{
|
||||
if (!$matcher instanceof UrlMatcherInterface && !$matcher instanceof RequestMatcherInterface) {
|
||||
throw new \InvalidArgumentException('Matcher must either implement UrlMatcherInterface or RequestMatcherInterface.');
|
||||
@@ -73,45 +65,29 @@ class RouterListener implements EventSubscriberInterface
|
||||
$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 Deprecated since version 2.4, to be moved to a private function in 3.0.
|
||||
*/
|
||||
public function setRequest(Request $request = null)
|
||||
private function setCurrentRequest(Request $request = null)
|
||||
{
|
||||
if (null !== $request && $this->request !== $request) {
|
||||
if (null !== $request) {
|
||||
$this->context->fromRequest($request);
|
||||
}
|
||||
$this->request = $request;
|
||||
}
|
||||
|
||||
/**
|
||||
* After a sub-request is done, we need to reset the routing context to the parent request so that the URL generator
|
||||
* operates on the correct context again.
|
||||
*
|
||||
* @param FinishRequestEvent $event
|
||||
*/
|
||||
public function onKernelFinishRequest(FinishRequestEvent $event)
|
||||
{
|
||||
if (null === $this->requestStack) {
|
||||
return; // removed when requestStack is required
|
||||
}
|
||||
|
||||
$this->setRequest($this->requestStack->getParentRequest());
|
||||
$this->setCurrentRequest($this->requestStack->getParentRequest());
|
||||
}
|
||||
|
||||
public function onKernelRequest(GetResponseEvent $event)
|
||||
{
|
||||
$request = $event->getRequest();
|
||||
|
||||
// initialize the context that is also used by the generator (assuming matcher and generator share the same context instance)
|
||||
// we call setRequest even if most of the time, it has already been done to keep compatibility
|
||||
// with frameworks which do not use the Symfony service container
|
||||
// when we have a RequestStack, no need to do it
|
||||
if (null !== $this->requestStack) {
|
||||
$this->setRequest($request);
|
||||
}
|
||||
$this->setCurrentRequest($request);
|
||||
|
||||
if ($request->attributes->has('_controller')) {
|
||||
// routing is already done
|
||||
@@ -128,7 +104,10 @@ class RouterListener implements EventSubscriberInterface
|
||||
}
|
||||
|
||||
if (null !== $this->logger) {
|
||||
$this->logger->info(sprintf('Matched route "%s" (parameters: %s)', $parameters['_route'], $this->parametersToString($parameters)));
|
||||
$this->logger->info(sprintf('Matched route "%s".', isset($parameters['_route']) ? $parameters['_route'] : 'n/a'), array(
|
||||
'route_parameters' => $parameters,
|
||||
'request_uri' => $request->getUri(),
|
||||
));
|
||||
}
|
||||
|
||||
$request->attributes->add($parameters);
|
||||
@@ -149,16 +128,6 @@ class RouterListener implements EventSubscriberInterface
|
||||
}
|
||||
}
|
||||
|
||||
private function parametersToString(array $parameters)
|
||||
{
|
||||
$pieces = array();
|
||||
foreach ($parameters as $key => $val) {
|
||||
$pieces[] = sprintf('"%s": "%s"', $key, (is_string($val) ? $val : json_encode($val)));
|
||||
}
|
||||
|
||||
return implode(', ', $pieces);
|
||||
}
|
||||
|
||||
public static function getSubscribedEvents()
|
||||
{
|
||||
return array(
|
@@ -17,7 +17,7 @@ use Symfony\Component\HttpKernel\KernelEvents;
|
||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||
|
||||
/**
|
||||
* SurrogateListener adds a Surrogate-Control HTTP header when the Response needs to be parsed for Surrogates
|
||||
* SurrogateListener adds a Surrogate-Control HTTP header when the Response needs to be parsed for Surrogates.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*/
|
@@ -48,7 +48,7 @@ abstract class TestSessionListener implements EventSubscriberInterface
|
||||
|
||||
/**
|
||||
* Checks if session was initialized and saves if current request is master
|
||||
* Runs on 'kernel.response' in test environment
|
||||
* Runs on 'kernel.response' in test environment.
|
||||
*
|
||||
* @param FilterResponseEvent $event
|
||||
*/
|
@@ -11,7 +11,6 @@
|
||||
|
||||
namespace Symfony\Component\HttpKernel\Fragment;
|
||||
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpFoundation\StreamedResponse;
|
||||
use Symfony\Component\HttpFoundation\RequestStack;
|
||||
@@ -23,11 +22,6 @@ use Symfony\Component\HttpKernel\Controller\ControllerReference;
|
||||
* This class handles the rendering of resource fragments that are included into
|
||||
* a main resource. The handling of the rendering is managed by specialized renderers.
|
||||
*
|
||||
* This listener works in 2 modes:
|
||||
*
|
||||
* * 2.3 compatibility mode where you must call setRequest whenever the Request changes.
|
||||
* * 2.4+ mode where you must pass a RequestStack instance in the constructor.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* @see FragmentRendererInterface
|
||||
@@ -36,19 +30,16 @@ class FragmentHandler
|
||||
{
|
||||
private $debug;
|
||||
private $renderers = array();
|
||||
private $request;
|
||||
private $requestStack;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* RequestStack will become required in 3.0.
|
||||
*
|
||||
* @param RequestStack $requestStack The Request stack that controls the lifecycle of requests
|
||||
* @param FragmentRendererInterface[] $renderers An array of FragmentRendererInterface instances
|
||||
* @param bool $debug Whether the debug mode is enabled or not
|
||||
* @param RequestStack|null $requestStack The Request stack that controls the lifecycle of requests
|
||||
*/
|
||||
public function __construct(array $renderers = array(), $debug = false, RequestStack $requestStack = null)
|
||||
public function __construct(RequestStack $requestStack, array $renderers = array(), $debug = false)
|
||||
{
|
||||
$this->requestStack = $requestStack;
|
||||
foreach ($renderers as $renderer) {
|
||||
@@ -67,22 +58,6 @@ class FragmentHandler
|
||||
$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 Deprecated since version 2.4, to be removed in 3.0.
|
||||
*/
|
||||
public function setRequest(Request $request = null)
|
||||
{
|
||||
$this->request = $request;
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders a URI and returns the Response content.
|
||||
*
|
||||
@@ -109,7 +84,7 @@ class FragmentHandler
|
||||
throw new \InvalidArgumentException(sprintf('The "%s" renderer does not exist.', $renderer));
|
||||
}
|
||||
|
||||
if (!$request = $this->getRequest()) {
|
||||
if (!$request = $this->requestStack->getCurrentRequest()) {
|
||||
throw new \LogicException('Rendering a fragment can only be done when handling a Request.');
|
||||
}
|
||||
|
||||
@@ -131,7 +106,7 @@ class FragmentHandler
|
||||
protected function deliver(Response $response)
|
||||
{
|
||||
if (!$response->isSuccessful()) {
|
||||
throw new \RuntimeException(sprintf('Error when rendering "%s" (Status code is %s).', $this->getRequest()->getUri(), $response->getStatusCode()));
|
||||
throw new \RuntimeException(sprintf('Error when rendering "%s" (Status code is %s).', $this->requestStack->getCurrentRequest()->getUri(), $response->getStatusCode()));
|
||||
}
|
||||
|
||||
if (!$response instanceof StreamedResponse) {
|
||||
@@ -140,9 +115,4 @@ class FragmentHandler
|
||||
|
||||
$response->sendContent();
|
||||
}
|
||||
|
||||
private function getRequest()
|
||||
{
|
||||
return $this->requestStack ? $this->requestStack->getCurrentRequest() : $this->request;
|
||||
}
|
||||
}
|
@@ -107,11 +107,7 @@ class HIncludeFragmentRenderer extends RoutableFragmentRenderer
|
||||
}
|
||||
$renderedAttributes = '';
|
||||
if (count($attributes) > 0) {
|
||||
if (PHP_VERSION_ID >= 50400) {
|
||||
$flags = ENT_QUOTES | ENT_SUBSTITUTE;
|
||||
} else {
|
||||
$flags = ENT_QUOTES;
|
||||
}
|
||||
$flags = ENT_QUOTES | ENT_SUBSTITUTE;
|
||||
foreach ($attributes as $attribute => $value) {
|
||||
$renderedAttributes .= sprintf(
|
||||
' %s="%s"',
|
@@ -57,7 +57,7 @@ class Esi implements SurrogateInterface
|
||||
*/
|
||||
public function createCacheStrategy()
|
||||
{
|
||||
return new EsiResponseCacheStrategy();
|
||||
return new ResponseCacheStrategy();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -68,20 +68,6 @@ class Esi implements SurrogateInterface
|
||||
* @return bool true if one surrogate has ESI/1.0 capability, false otherwise
|
||||
*/
|
||||
public function hasSurrogateCapability(Request $request)
|
||||
{
|
||||
return $this->hasSurrogateEsiCapability($request);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 Deprecated since version 2.6, to be removed in 3.0. Use hasSurrogateCapability() instead
|
||||
*/
|
||||
public function hasSurrogateEsiCapability(Request $request)
|
||||
{
|
||||
if (null === $value = $request->headers->get('Surrogate-Capability')) {
|
||||
return false;
|
||||
@@ -96,18 +82,6 @@ class Esi implements SurrogateInterface
|
||||
* @param Request $request A Request instance
|
||||
*/
|
||||
public function addSurrogateCapability(Request $request)
|
||||
{
|
||||
$this->addSurrogateEsiCapability($request);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds ESI/1.0 capability to the given Request.
|
||||
*
|
||||
* @param Request $request A Request instance
|
||||
*
|
||||
* @deprecated Deprecated since version 2.6, to be removed in 3.0. Use addSurrogateCapability() instead
|
||||
*/
|
||||
public function addSurrogateEsiCapability(Request $request)
|
||||
{
|
||||
$current = $request->headers->get('Surrogate-Capability');
|
||||
$new = 'symfony2="ESI/1.0"';
|
||||
@@ -137,20 +111,6 @@ class Esi implements SurrogateInterface
|
||||
* @return bool true if the Response needs to be parsed, false otherwise
|
||||
*/
|
||||
public function needsParsing(Response $response)
|
||||
{
|
||||
return $this->needsEsiParsing($response);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 Deprecated since version 2.6, to be removed in 3.0. Use needsParsing() instead
|
||||
*/
|
||||
public function needsEsiParsing(Response $response)
|
||||
{
|
||||
if (!$control = $response->headers->get('Surrogate-Control')) {
|
||||
return false;
|
||||
@@ -194,7 +154,6 @@ class Esi implements SurrogateInterface
|
||||
*/
|
||||
public function process(Request $request, Response $response)
|
||||
{
|
||||
$this->request = $request;
|
||||
$type = $response->headers->get('Content-Type');
|
||||
if (empty($type)) {
|
||||
$type = 'text/html';
|
||||
@@ -207,8 +166,8 @@ class Esi implements SurrogateInterface
|
||||
|
||||
// we don't use a proper XML parser here as we can have ESI tags in a plain text response
|
||||
$content = $response->getContent();
|
||||
$content = preg_replace('#<esi\:remove>.*?</esi\:remove>#', '', $content);
|
||||
$content = preg_replace('#<esi\:comment[^>]*(?:/|</esi\:comment)>#', '', $content);
|
||||
$content = preg_replace('#<esi\:remove>.*?</esi\:remove>#s', '', $content);
|
||||
$content = preg_replace('#<esi\:comment[^>]+>#s', '', $content);
|
||||
|
||||
$chunks = preg_split('#<esi\:include\s+(.*?)\s*(?:/|</esi\:include)>#', $content, -1, PREG_SPLIT_DELIM_CAPTURE);
|
||||
$chunks[0] = str_replace($this->phpEscapeMap[0], $this->phpEscapeMap[1], $chunks[0]);
|
@@ -24,8 +24,6 @@ use Symfony\Component\HttpFoundation\Response;
|
||||
* Cache provides HTTP caching.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
class HttpCache implements HttpKernelInterface, TerminableInterface
|
||||
{
|
||||
@@ -155,36 +153,17 @@ class HttpCache implements HttpKernelInterface, TerminableInterface
|
||||
/**
|
||||
* Gets the Surrogate instance.
|
||||
*
|
||||
* @throws \LogicException
|
||||
* @return SurrogateInterface A Surrogate instance
|
||||
*
|
||||
* @throws \LogicException
|
||||
*/
|
||||
public function getSurrogate()
|
||||
{
|
||||
return $this->getEsi();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the Esi instance.
|
||||
*
|
||||
* @throws \LogicException
|
||||
*
|
||||
* @return Esi An Esi instance
|
||||
*
|
||||
* @deprecated Deprecated since version 2.6, to be removed in 3.0. Use getSurrogate() instead
|
||||
*/
|
||||
public function getEsi()
|
||||
{
|
||||
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}
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = true)
|
||||
{
|
||||
@@ -213,7 +192,7 @@ class HttpCache implements HttpKernelInterface, TerminableInterface
|
||||
|
||||
$this->restoreResponseBody($request, $response);
|
||||
|
||||
$response->setDate(new \DateTime(null, new \DateTimeZone('UTC')));
|
||||
$response->setDate(\DateTime::createFromFormat('U', time(), new \DateTimeZone('UTC')));
|
||||
|
||||
if (HttpKernelInterface::MASTER_REQUEST === $type && $this->options['debug']) {
|
||||
$response->headers->set('X-Symfony-Cache', $this->getLog());
|
||||
@@ -236,8 +215,6 @@ class HttpCache implements HttpKernelInterface, TerminableInterface
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function terminate(Request $request, Response $response)
|
||||
{
|
||||
@@ -280,7 +257,7 @@ class HttpCache implements HttpKernelInterface, TerminableInterface
|
||||
// invalidate only when the response is successful
|
||||
if ($response->isSuccessful() || $response->isRedirect()) {
|
||||
try {
|
||||
$this->store->invalidate($request, $catch);
|
||||
$this->store->invalidate($request);
|
||||
|
||||
// As per the RFC, invalidate Location and Content-Location URLs if present
|
||||
foreach (array('Location', 'Content-Location') as $header) {
|
||||
@@ -506,7 +483,7 @@ class HttpCache implements HttpKernelInterface, TerminableInterface
|
||||
$this->processResponseBody($request, $response);
|
||||
|
||||
if ($this->isPrivateRequest($request) && !$response->headers->hasCacheControlDirective('public')) {
|
||||
$response->setPrivate(true);
|
||||
$response->setPrivate();
|
||||
} elseif ($this->options['default_ttl'] > 0 && null === $response->getTtl() && !$response->headers->getCacheControlDirective('must-revalidate')) {
|
||||
$response->setTtl($this->options['default_ttl']);
|
||||
}
|
||||
@@ -569,7 +546,7 @@ class HttpCache implements HttpKernelInterface, TerminableInterface
|
||||
$wait += 50000;
|
||||
}
|
||||
|
||||
if ($wait < 2000000) {
|
||||
if ($wait < 5000000) {
|
||||
// replace the current entry with the fresh one
|
||||
$new = $this->lookup($request);
|
||||
$entry->headers = $new->headers;
|
@@ -32,6 +32,7 @@ class ResponseCacheStrategy implements ResponseCacheStrategyInterface
|
||||
private $embeddedResponses = 0;
|
||||
private $ttls = array();
|
||||
private $maxAges = array();
|
||||
private $isNotCacheableResponseEmbedded = false;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
@@ -41,11 +42,16 @@ class ResponseCacheStrategy implements ResponseCacheStrategyInterface
|
||||
if ($response->isValidateable()) {
|
||||
$this->cacheable = false;
|
||||
} else {
|
||||
$maxAge = $response->getMaxAge();
|
||||
$this->ttls[] = $response->getTtl();
|
||||
$this->maxAges[] = $response->getMaxAge();
|
||||
$this->maxAges[] = $maxAge;
|
||||
|
||||
if (null === $maxAge) {
|
||||
$this->isNotCacheableResponseEmbedded = true;
|
||||
}
|
||||
}
|
||||
|
||||
$this->embeddedResponses++;
|
||||
++$this->embeddedResponses;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -76,7 +82,9 @@ class ResponseCacheStrategy implements ResponseCacheStrategyInterface
|
||||
$this->ttls[] = $response->getTtl();
|
||||
$this->maxAges[] = $response->getMaxAge();
|
||||
|
||||
if (null !== $maxAge = min($this->maxAges)) {
|
||||
if ($this->isNotCacheableResponseEmbedded) {
|
||||
$response->headers->removeCacheControlDirective('s-maxage');
|
||||
} elseif (null !== $maxAge = min($this->maxAges)) {
|
||||
$response->setSharedMaxAge($maxAge);
|
||||
$response->headers->set('Age', $maxAge - min($this->ttls));
|
||||
}
|
@@ -113,7 +113,6 @@ class Ssi implements SurrogateInterface
|
||||
*/
|
||||
public function process(Request $request, Response $response)
|
||||
{
|
||||
$this->request = $request;
|
||||
$type = $response->headers->get('Content-Type');
|
||||
if (empty($type)) {
|
||||
$type = 'text/html';
|
@@ -32,12 +32,14 @@ class Store implements StoreInterface
|
||||
* Constructor.
|
||||
*
|
||||
* @param string $root The path to the cache directory
|
||||
*
|
||||
* @throws \RuntimeException
|
||||
*/
|
||||
public function __construct($root)
|
||||
{
|
||||
$this->root = $root;
|
||||
if (!is_dir($this->root)) {
|
||||
mkdir($this->root, 0777, true);
|
||||
if (!is_dir($this->root) && !@mkdir($this->root, 0777, true) && !is_dir($this->root)) {
|
||||
throw new \RuntimeException(sprintf('Unable to create the store directory (%s).', $this->root));
|
||||
}
|
||||
$this->keyCache = new \SplObjectStorage();
|
||||
$this->locks = array();
|
||||
@@ -74,7 +76,7 @@ class Store implements StoreInterface
|
||||
public function lock(Request $request)
|
||||
{
|
||||
$path = $this->getPath($this->getCacheKey($request).'.lck');
|
||||
if (!is_dir(dirname($path)) && false === @mkdir(dirname($path), 0777, true)) {
|
||||
if (!is_dir(dirname($path)) && false === @mkdir(dirname($path), 0777, true) && !is_dir(dirname($path))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -106,7 +108,10 @@ class Store implements StoreInterface
|
||||
|
||||
public function isLocked(Request $request)
|
||||
{
|
||||
return is_file($this->getPath($this->getCacheKey($request).'.lck'));
|
||||
$path = $this->getPath($this->getCacheKey($request).'.lck');
|
||||
clearstatcache(true, $path);
|
||||
|
||||
return is_file($path);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -242,10 +247,8 @@ class Store implements StoreInterface
|
||||
}
|
||||
}
|
||||
|
||||
if ($modified) {
|
||||
if (false === $this->save($key, serialize($entries))) {
|
||||
throw new \RuntimeException('Unable to store the metadata.');
|
||||
}
|
||||
if ($modified && false === $this->save($key, serialize($entries))) {
|
||||
throw new \RuntimeException('Unable to store the metadata.');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -266,7 +269,7 @@ class Store implements StoreInterface
|
||||
}
|
||||
|
||||
foreach (preg_split('/[\s,]+/', $vary) as $header) {
|
||||
$key = strtr(strtolower($header), '_', '-');
|
||||
$key = str_replace('_', '-', strtolower($header));
|
||||
$v1 = isset($env1[$key]) ? $env1[$key] : null;
|
||||
$v2 = isset($env2[$key]) ? $env2[$key] : null;
|
||||
if ($v1 !== $v2) {
|
||||
@@ -338,7 +341,7 @@ class Store implements StoreInterface
|
||||
private function save($key, $data)
|
||||
{
|
||||
$path = $this->getPath($key);
|
||||
if (!is_dir(dirname($path)) && false === @mkdir(dirname($path), 0777, true)) {
|
||||
if (!is_dir(dirname($path)) && false === @mkdir(dirname($path), 0777, true) && !is_dir(dirname($path))) {
|
||||
return false;
|
||||
}
|
||||
|
@@ -17,7 +17,7 @@ use Symfony\Component\HttpFoundation\Response;
|
||||
interface SurrogateInterface
|
||||
{
|
||||
/**
|
||||
* Returns surrogate name
|
||||
* Returns surrogate name.
|
||||
*
|
||||
* @return string
|
||||
*/
|
@@ -30,8 +30,6 @@ use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
||||
* HttpKernel notifies events to convert a Request object to a Response one.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
class HttpKernel implements HttpKernelInterface, TerminableInterface
|
||||
{
|
||||
@@ -45,8 +43,6 @@ class HttpKernel implements HttpKernelInterface, TerminableInterface
|
||||
* @param EventDispatcherInterface $dispatcher An EventDispatcherInterface instance
|
||||
* @param ControllerResolverInterface $resolver A ControllerResolverInterface instance
|
||||
* @param RequestStack $requestStack A stack for master/sub requests
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function __construct(EventDispatcherInterface $dispatcher, ControllerResolverInterface $resolver, RequestStack $requestStack = null)
|
||||
{
|
||||
@@ -57,11 +53,11 @@ class HttpKernel implements HttpKernelInterface, TerminableInterface
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = true)
|
||||
{
|
||||
$request->headers->set('X-Php-Ob-Level', ob_get_level());
|
||||
|
||||
try {
|
||||
return $this->handleRaw($request, $type);
|
||||
} catch (\Exception $e) {
|
||||
@@ -77,8 +73,6 @@ class HttpKernel implements HttpKernelInterface, TerminableInterface
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function terminate(Request $request, Response $response)
|
||||
{
|
@@ -18,8 +18,6 @@ use Symfony\Component\HttpFoundation\Response;
|
||||
* HttpKernelInterface handles a Request to convert it to a Response.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
interface HttpKernelInterface
|
||||
{
|
||||
@@ -40,8 +38,6 @@ interface HttpKernelInterface
|
||||
* @return Response A Response instance
|
||||
*
|
||||
* @throws \Exception When an Exception occurs during processing
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function handle(Request $request, $type = self::MASTER_REQUEST, $catch = true);
|
||||
}
|
@@ -21,6 +21,7 @@ use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
|
||||
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
|
||||
use Symfony\Component\DependencyInjection\Loader\IniFileLoader;
|
||||
use Symfony\Component\DependencyInjection\Loader\PhpFileLoader;
|
||||
use Symfony\Component\DependencyInjection\Loader\DirectoryLoader;
|
||||
use Symfony\Component\DependencyInjection\Loader\ClosureLoader;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
@@ -40,8 +41,6 @@ use Symfony\Component\ClassLoader\ClassCollectionLoader;
|
||||
* It manages an environment made of bundles.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
abstract class Kernel implements KernelInterface, TerminableInterface
|
||||
{
|
||||
@@ -60,20 +59,21 @@ abstract class Kernel implements KernelInterface, TerminableInterface
|
||||
protected $startTime;
|
||||
protected $loadClassCache;
|
||||
|
||||
const VERSION = '2.6.13';
|
||||
const VERSION_ID = '20613';
|
||||
const MAJOR_VERSION = '2';
|
||||
const MINOR_VERSION = '6';
|
||||
const RELEASE_VERSION = '13';
|
||||
const VERSION = '3.0.7';
|
||||
const VERSION_ID = 30007;
|
||||
const MAJOR_VERSION = 3;
|
||||
const MINOR_VERSION = 0;
|
||||
const RELEASE_VERSION = 7;
|
||||
const EXTRA_VERSION = '';
|
||||
|
||||
const END_OF_MAINTENANCE = '07/2016';
|
||||
const END_OF_LIFE = '01/2017';
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param string $environment The environment
|
||||
* @param bool $debug Whether to enable debugging or not
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function __construct($environment, $debug)
|
||||
{
|
||||
@@ -85,15 +85,6 @@ abstract class Kernel implements KernelInterface, TerminableInterface
|
||||
if ($this->debug) {
|
||||
$this->startTime = microtime(true);
|
||||
}
|
||||
|
||||
$this->init();
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Deprecated since version 2.3, to be removed in 3.0. Move your logic in the constructor instead.
|
||||
*/
|
||||
public function init()
|
||||
{
|
||||
}
|
||||
|
||||
public function __clone()
|
||||
@@ -108,8 +99,6 @@ abstract class Kernel implements KernelInterface, TerminableInterface
|
||||
|
||||
/**
|
||||
* Boots the current kernel.
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
@@ -137,8 +126,6 @@ abstract class Kernel implements KernelInterface, TerminableInterface
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function terminate(Request $request, Response $response)
|
||||
{
|
||||
@@ -153,8 +140,6 @@ abstract class Kernel implements KernelInterface, TerminableInterface
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function shutdown()
|
||||
{
|
||||
@@ -174,8 +159,6 @@ abstract class Kernel implements KernelInterface, TerminableInterface
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = true)
|
||||
{
|
||||
@@ -198,8 +181,6 @@ abstract class Kernel implements KernelInterface, TerminableInterface
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function getBundles()
|
||||
{
|
||||
@@ -208,26 +189,6 @@ abstract class Kernel implements KernelInterface, TerminableInterface
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @api
|
||||
*
|
||||
* @deprecated Deprecated since version 2.6, to be removed in 3.0.
|
||||
*/
|
||||
public function isClassInActiveBundle($class)
|
||||
{
|
||||
foreach ($this->getBundles() as $bundle) {
|
||||
if (0 === strpos($class, $bundle->getNamespace())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function getBundle($name, $first = true)
|
||||
{
|
||||
@@ -303,8 +264,6 @@ abstract class Kernel implements KernelInterface, TerminableInterface
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
@@ -317,8 +276,6 @@ abstract class Kernel implements KernelInterface, TerminableInterface
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function getEnvironment()
|
||||
{
|
||||
@@ -327,8 +284,6 @@ abstract class Kernel implements KernelInterface, TerminableInterface
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function isDebug()
|
||||
{
|
||||
@@ -337,14 +292,12 @@ abstract class Kernel implements KernelInterface, TerminableInterface
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function getRootDir()
|
||||
{
|
||||
if (null === $this->rootDir) {
|
||||
$r = new \ReflectionObject($this);
|
||||
$this->rootDir = str_replace('\\', '/', dirname($r->getFileName()));
|
||||
$this->rootDir = dirname($r->getFileName());
|
||||
}
|
||||
|
||||
return $this->rootDir;
|
||||
@@ -352,8 +305,6 @@ abstract class Kernel implements KernelInterface, TerminableInterface
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function getContainer()
|
||||
{
|
||||
@@ -387,8 +338,6 @@ abstract class Kernel implements KernelInterface, TerminableInterface
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function getStartTime()
|
||||
{
|
||||
@@ -397,8 +346,6 @@ abstract class Kernel implements KernelInterface, TerminableInterface
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function getCacheDir()
|
||||
{
|
||||
@@ -407,8 +354,6 @@ abstract class Kernel implements KernelInterface, TerminableInterface
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function getLogDir()
|
||||
{
|
||||
@@ -417,8 +362,6 @@ abstract class Kernel implements KernelInterface, TerminableInterface
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function getCharset()
|
||||
{
|
||||
@@ -537,7 +480,7 @@ abstract class Kernel implements KernelInterface, TerminableInterface
|
||||
$fresh = false;
|
||||
}
|
||||
|
||||
require_once $cache;
|
||||
require_once $cache->getPath();
|
||||
|
||||
$this->container = new $class();
|
||||
$this->container->set('kernel', $this);
|
||||
@@ -683,13 +626,10 @@ abstract class Kernel implements KernelInterface, TerminableInterface
|
||||
$dumper = new PhpDumper($container);
|
||||
|
||||
if (class_exists('ProxyManager\Configuration') && class_exists('Symfony\Bridge\ProxyManager\LazyProxy\PhpDumper\ProxyDumper')) {
|
||||
$dumper->setProxyDumper(new ProxyDumper(md5((string) $cache)));
|
||||
$dumper->setProxyDumper(new ProxyDumper(md5($cache->getPath())));
|
||||
}
|
||||
|
||||
$content = $dumper->dump(array('class' => $class, 'base_class' => $baseClass, 'file' => (string) $cache));
|
||||
if (!$this->debug) {
|
||||
$content = static::stripComments($content);
|
||||
}
|
||||
$content = $dumper->dump(array('class' => $class, 'base_class' => $baseClass, 'file' => $cache->getPath(), 'debug' => $this->debug));
|
||||
|
||||
$cache->write($content, $container->getResources());
|
||||
}
|
||||
@@ -709,6 +649,7 @@ abstract class Kernel implements KernelInterface, TerminableInterface
|
||||
new YamlFileLoader($container, $locator),
|
||||
new IniFileLoader($container, $locator),
|
||||
new PhpFileLoader($container, $locator),
|
||||
new DirectoryLoader($container, $locator),
|
||||
new ClosureLoader($container),
|
||||
));
|
||||
|
||||
@@ -735,14 +676,15 @@ abstract class Kernel implements KernelInterface, TerminableInterface
|
||||
$output = '';
|
||||
$tokens = token_get_all($source);
|
||||
$ignoreSpace = false;
|
||||
for (reset($tokens); false !== $token = current($tokens); next($tokens)) {
|
||||
if (is_string($token)) {
|
||||
for ($i = 0; isset($tokens[$i]); ++$i) {
|
||||
$token = $tokens[$i];
|
||||
if (!isset($token[1]) || 'b"' === $token) {
|
||||
$rawChunk .= $token;
|
||||
} elseif (T_START_HEREDOC === $token[0]) {
|
||||
$output .= $rawChunk.$token[1];
|
||||
do {
|
||||
$token = next($tokens);
|
||||
$output .= $token[1];
|
||||
$token = $tokens[++$i];
|
||||
$output .= isset($token[1]) && 'b"' !== $token ? $token[1] : $token;
|
||||
} while ($token[0] !== T_END_HEREDOC);
|
||||
$rawChunk = '';
|
||||
} elseif (T_WHITESPACE === $token[0]) {
|
||||
@@ -768,6 +710,12 @@ abstract class Kernel implements KernelInterface, TerminableInterface
|
||||
|
||||
$output .= $rawChunk;
|
||||
|
||||
if (PHP_VERSION_ID >= 70000) {
|
||||
// PHP 7 memory manager will not release after token_get_all(), see https://bugs.php.net/70098
|
||||
unset($tokens, $rawChunk);
|
||||
gc_mem_caches();
|
||||
}
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
@@ -15,8 +15,6 @@ namespace Symfony\Component\HttpKernel;
|
||||
* Contains all events thrown in the HttpKernel component.
|
||||
*
|
||||
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
final class KernelEvents
|
||||
{
|
||||
@@ -32,8 +30,6 @@ final class KernelEvents
|
||||
* @Event
|
||||
*
|
||||
* @var string
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
const REQUEST = 'kernel.request';
|
||||
|
||||
@@ -48,8 +44,6 @@ final class KernelEvents
|
||||
* @Event
|
||||
*
|
||||
* @var string
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
const EXCEPTION = 'kernel.exception';
|
||||
|
||||
@@ -65,8 +59,6 @@ final class KernelEvents
|
||||
* @Event
|
||||
*
|
||||
* @var string
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
const VIEW = 'kernel.view';
|
||||
|
||||
@@ -81,8 +73,6 @@ final class KernelEvents
|
||||
* @Event
|
||||
*
|
||||
* @var string
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
const CONTROLLER = 'kernel.controller';
|
||||
|
||||
@@ -97,8 +87,6 @@ final class KernelEvents
|
||||
* @Event
|
||||
*
|
||||
* @var string
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
const RESPONSE = 'kernel.response';
|
||||
|
||||
@@ -120,6 +108,10 @@ final class KernelEvents
|
||||
*
|
||||
* This event allows you to reset the global and environmental state of
|
||||
* the application, when it was changed during the request.
|
||||
* The event listener method receives a
|
||||
* Symfony\Component\HttpKernel\Event\FinishRequestEvent instance.
|
||||
*
|
||||
* @Event
|
||||
*
|
||||
* @var string
|
||||
*/
|
@@ -21,8 +21,6 @@ use Symfony\Component\Config\Loader\LoaderInterface;
|
||||
* It manages an environment made of bundles.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
interface KernelInterface extends HttpKernelInterface, \Serializable
|
||||
{
|
||||
@@ -30,8 +28,6 @@ interface KernelInterface extends HttpKernelInterface, \Serializable
|
||||
* Returns an array of bundles to register.
|
||||
*
|
||||
* @return BundleInterface[] An array of bundle instances.
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function registerBundles();
|
||||
|
||||
@@ -39,15 +35,11 @@ interface KernelInterface extends HttpKernelInterface, \Serializable
|
||||
* Loads the container configuration.
|
||||
*
|
||||
* @param LoaderInterface $loader A LoaderInterface instance
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function registerContainerConfiguration(LoaderInterface $loader);
|
||||
|
||||
/**
|
||||
* Boots the current kernel.
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function boot();
|
||||
|
||||
@@ -55,8 +47,6 @@ interface KernelInterface extends HttpKernelInterface, \Serializable
|
||||
* Shutdowns the kernel.
|
||||
*
|
||||
* This method is mainly useful when doing functional testing.
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function shutdown();
|
||||
|
||||
@@ -64,24 +54,9 @@ interface KernelInterface extends HttpKernelInterface, \Serializable
|
||||
* Gets the registered bundle instances.
|
||||
*
|
||||
* @return BundleInterface[] An array of registered bundle instances
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function getBundles();
|
||||
|
||||
/**
|
||||
* Checks if a given class name belongs to an active bundle.
|
||||
*
|
||||
* @param string $class A class name
|
||||
*
|
||||
* @return bool true if the class belongs to an active bundle, false otherwise
|
||||
*
|
||||
* @api
|
||||
*
|
||||
* @deprecated Deprecated since version 2.6, to be removed in 3.0.
|
||||
*/
|
||||
public function isClassInActiveBundle($class);
|
||||
|
||||
/**
|
||||
* Returns a bundle and optionally its descendants by its name.
|
||||
*
|
||||
@@ -91,8 +66,6 @@ interface KernelInterface extends HttpKernelInterface, \Serializable
|
||||
* @return BundleInterface|BundleInterface[] A BundleInterface instance or an array of BundleInterface instances if $first is false
|
||||
*
|
||||
* @throws \InvalidArgumentException when the bundle is not enabled
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function getBundle($name, $first = true);
|
||||
|
||||
@@ -123,8 +96,6 @@ interface KernelInterface extends HttpKernelInterface, \Serializable
|
||||
*
|
||||
* @throws \InvalidArgumentException if the file cannot be found or the name is not valid
|
||||
* @throws \RuntimeException if the name contains invalid/unsafe characters
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function locateResource($name, $dir = null, $first = true);
|
||||
|
||||
@@ -132,8 +103,6 @@ interface KernelInterface extends HttpKernelInterface, \Serializable
|
||||
* Gets the name of the kernel.
|
||||
*
|
||||
* @return string The kernel name
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function getName();
|
||||
|
||||
@@ -141,8 +110,6 @@ interface KernelInterface extends HttpKernelInterface, \Serializable
|
||||
* Gets the environment.
|
||||
*
|
||||
* @return string The current environment
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function getEnvironment();
|
||||
|
||||
@@ -150,8 +117,6 @@ interface KernelInterface extends HttpKernelInterface, \Serializable
|
||||
* Checks if debug mode is enabled.
|
||||
*
|
||||
* @return bool true if debug mode is enabled, false otherwise
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function isDebug();
|
||||
|
||||
@@ -159,8 +124,6 @@ interface KernelInterface extends HttpKernelInterface, \Serializable
|
||||
* Gets the application root dir.
|
||||
*
|
||||
* @return string The application root dir
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function getRootDir();
|
||||
|
||||
@@ -168,8 +131,6 @@ interface KernelInterface extends HttpKernelInterface, \Serializable
|
||||
* Gets the current container.
|
||||
*
|
||||
* @return ContainerInterface A ContainerInterface instance
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function getContainer();
|
||||
|
||||
@@ -177,8 +138,6 @@ interface KernelInterface extends HttpKernelInterface, \Serializable
|
||||
* Gets the request start time (not available if debug is disabled).
|
||||
*
|
||||
* @return int The request start timestamp
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function getStartTime();
|
||||
|
||||
@@ -186,8 +145,6 @@ interface KernelInterface extends HttpKernelInterface, \Serializable
|
||||
* Gets the cache directory.
|
||||
*
|
||||
* @return string The cache directory
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function getCacheDir();
|
||||
|
||||
@@ -195,8 +152,6 @@ interface KernelInterface extends HttpKernelInterface, \Serializable
|
||||
* Gets the log directory.
|
||||
*
|
||||
* @return string The log directory
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function getLogDir();
|
||||
|
||||
@@ -204,8 +159,6 @@ interface KernelInterface extends HttpKernelInterface, \Serializable
|
||||
* Gets the charset of the application.
|
||||
*
|
||||
* @return string The charset
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function getCharset();
|
||||
}
|
@@ -1,4 +1,4 @@
|
||||
Copyright (c) 2004-2015 Fabien Potencier
|
||||
Copyright (c) 2004-2016 Fabien Potencier
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user