Laravel version update
Laravel version update
This commit is contained in:
@@ -29,8 +29,6 @@ abstract class AbstractSurrogateFragmentRenderer extends RoutableFragmentRendere
|
||||
private $signer;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* The "fallback" strategy when surrogate is not available should always be an
|
||||
* instance of InlineFragmentRenderer.
|
||||
*
|
||||
@@ -64,6 +62,10 @@ abstract class AbstractSurrogateFragmentRenderer extends RoutableFragmentRendere
|
||||
public function render($uri, Request $request, array $options = array())
|
||||
{
|
||||
if (!$this->surrogate || !$this->surrogate->hasSurrogateCapability($request)) {
|
||||
if ($uri instanceof ControllerReference && $this->containsNonScalars($uri->attributes)) {
|
||||
@trigger_error('Passing non-scalar values as part of URI attributes to the ESI and SSI rendering strategies is deprecated since Symfony 3.1, and will be removed in 4.0. Use a different rendering strategy or pass scalar values.', E_USER_DEPRECATED);
|
||||
}
|
||||
|
||||
return $this->inlineStrategy->render($uri, $request, $options);
|
||||
}
|
||||
|
||||
@@ -90,6 +92,19 @@ abstract class AbstractSurrogateFragmentRenderer extends RoutableFragmentRendere
|
||||
// we need to sign the absolute URI, but want to return the path only.
|
||||
$fragmentUri = $this->signer->sign($this->generateFragmentUri($uri, $request, true));
|
||||
|
||||
return substr($fragmentUri, strlen($request->getSchemeAndHttpHost()));
|
||||
return substr($fragmentUri, \strlen($request->getSchemeAndHttpHost()));
|
||||
}
|
||||
|
||||
private function containsNonScalars(array $values)
|
||||
{
|
||||
foreach ($values as $value) {
|
||||
if (\is_array($value)) {
|
||||
return $this->containsNonScalars($value);
|
||||
} elseif (!is_scalar($value) && null !== $value) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@@ -11,9 +11,9 @@
|
||||
|
||||
namespace Symfony\Component\HttpKernel\Fragment;
|
||||
|
||||
use Symfony\Component\HttpFoundation\RequestStack;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpFoundation\StreamedResponse;
|
||||
use Symfony\Component\HttpFoundation\RequestStack;
|
||||
use Symfony\Component\HttpKernel\Controller\ControllerReference;
|
||||
|
||||
/**
|
||||
@@ -33,8 +33,6 @@ class FragmentHandler
|
||||
private $requestStack;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @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
|
||||
@@ -50,8 +48,6 @@ class FragmentHandler
|
||||
|
||||
/**
|
||||
* Adds a renderer.
|
||||
*
|
||||
* @param FragmentRendererInterface $renderer A FragmentRendererInterface instance
|
||||
*/
|
||||
public function addRenderer(FragmentRendererInterface $renderer)
|
||||
{
|
||||
@@ -97,8 +93,6 @@ class FragmentHandler
|
||||
* When the Response is a StreamedResponse, the content is streamed immediately
|
||||
* instead of being returned.
|
||||
*
|
||||
* @param Response $response A Response instance
|
||||
*
|
||||
* @return string|null The Response content or null when the Response is streamed
|
||||
*
|
||||
* @throws \RuntimeException when the Response is not successful
|
||||
|
@@ -12,8 +12,8 @@
|
||||
namespace Symfony\Component\HttpKernel\Fragment;
|
||||
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpKernel\Controller\ControllerReference;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpKernel\Controller\ControllerReference;
|
||||
|
||||
/**
|
||||
* Interface implemented by all rendering strategies.
|
||||
|
@@ -13,9 +13,12 @@ namespace Symfony\Component\HttpKernel\Fragment;
|
||||
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Templating\EngineInterface;
|
||||
use Symfony\Component\HttpKernel\Controller\ControllerReference;
|
||||
use Symfony\Component\HttpKernel\UriSigner;
|
||||
use Symfony\Component\Templating\EngineInterface;
|
||||
use Twig\Environment;
|
||||
use Twig\Error\LoaderError;
|
||||
use Twig\Loader\ExistsLoaderInterface;
|
||||
|
||||
/**
|
||||
* Implements the Hinclude rendering strategy.
|
||||
@@ -30,12 +33,10 @@ class HIncludeFragmentRenderer extends RoutableFragmentRenderer
|
||||
private $charset;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param EngineInterface|\Twig_Environment $templating An EngineInterface or a \Twig_Environment instance
|
||||
* @param UriSigner $signer A UriSigner instance
|
||||
* @param string $globalDefaultTemplate The global default content (it can be a template name or the content)
|
||||
* @param string $charset
|
||||
* @param EngineInterface|Environment $templating An EngineInterface or a Twig instance
|
||||
* @param UriSigner $signer A UriSigner instance
|
||||
* @param string $globalDefaultTemplate The global default content (it can be a template name or the content)
|
||||
* @param string $charset
|
||||
*/
|
||||
public function __construct($templating = null, UriSigner $signer = null, $globalDefaultTemplate = null, $charset = 'utf-8')
|
||||
{
|
||||
@@ -48,14 +49,14 @@ class HIncludeFragmentRenderer extends RoutableFragmentRenderer
|
||||
/**
|
||||
* Sets the templating engine to use to render the default content.
|
||||
*
|
||||
* @param EngineInterface|\Twig_Environment|null $templating An EngineInterface or a \Twig_Environment instance
|
||||
* @param EngineInterface|Environment|null $templating An EngineInterface or an Environment instance
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
public function setTemplating($templating)
|
||||
{
|
||||
if (null !== $templating && !$templating instanceof EngineInterface && !$templating instanceof \Twig_Environment) {
|
||||
throw new \InvalidArgumentException('The hinclude rendering strategy needs an instance of \Twig_Environment or Symfony\Component\Templating\EngineInterface');
|
||||
if (null !== $templating && !$templating instanceof EngineInterface && !$templating instanceof Environment) {
|
||||
throw new \InvalidArgumentException('The hinclude rendering strategy needs an instance of Twig\Environment or Symfony\Component\Templating\EngineInterface');
|
||||
}
|
||||
|
||||
$this->templating = $templating;
|
||||
@@ -88,7 +89,7 @@ class HIncludeFragmentRenderer extends RoutableFragmentRenderer
|
||||
}
|
||||
|
||||
// we need to sign the absolute URI, but want to return the path only.
|
||||
$uri = substr($this->signer->sign($this->generateFragmentUri($uri, $request, true)), strlen($request->getSchemeAndHttpHost()));
|
||||
$uri = substr($this->signer->sign($this->generateFragmentUri($uri, $request, true)), \strlen($request->getSchemeAndHttpHost()));
|
||||
}
|
||||
|
||||
// We need to replace ampersands in the URI with the encoded form in order to return valid html/xml content.
|
||||
@@ -101,12 +102,12 @@ class HIncludeFragmentRenderer extends RoutableFragmentRenderer
|
||||
$content = $template;
|
||||
}
|
||||
|
||||
$attributes = isset($options['attributes']) && is_array($options['attributes']) ? $options['attributes'] : array();
|
||||
$attributes = isset($options['attributes']) && \is_array($options['attributes']) ? $options['attributes'] : array();
|
||||
if (isset($options['id']) && $options['id']) {
|
||||
$attributes['id'] = $options['id'];
|
||||
}
|
||||
$renderedAttributes = '';
|
||||
if (count($attributes) > 0) {
|
||||
if (\count($attributes) > 0) {
|
||||
$flags = ENT_QUOTES | ENT_SUBSTITUTE;
|
||||
foreach ($attributes as $attribute => $value) {
|
||||
$renderedAttributes .= sprintf(
|
||||
@@ -130,21 +131,25 @@ class HIncludeFragmentRenderer extends RoutableFragmentRenderer
|
||||
if ($this->templating instanceof EngineInterface) {
|
||||
try {
|
||||
return $this->templating->exists($template);
|
||||
} catch (\InvalidArgumentException $e) {
|
||||
} catch (\Exception $e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
$loader = $this->templating->getLoader();
|
||||
if ($loader instanceof \Twig_ExistsLoaderInterface) {
|
||||
if ($loader instanceof ExistsLoaderInterface || method_exists($loader, 'exists')) {
|
||||
return $loader->exists($template);
|
||||
}
|
||||
|
||||
try {
|
||||
$loader->getSource($template);
|
||||
if (method_exists($loader, 'getSourceContext')) {
|
||||
$loader->getSourceContext($template);
|
||||
} else {
|
||||
$loader->getSource($template);
|
||||
}
|
||||
|
||||
return true;
|
||||
} catch (\Twig_Error_Loader $e) {
|
||||
} catch (LoaderError $e) {
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@@ -11,13 +11,14 @@
|
||||
|
||||
namespace Symfony\Component\HttpKernel\Fragment;
|
||||
|
||||
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpKernel\HttpKernelInterface;
|
||||
use Symfony\Component\HttpKernel\Controller\ControllerReference;
|
||||
use Symfony\Component\HttpKernel\KernelEvents;
|
||||
use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent;
|
||||
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
||||
use Symfony\Component\HttpKernel\HttpCache\SubRequestHandler;
|
||||
use Symfony\Component\HttpKernel\HttpKernelInterface;
|
||||
use Symfony\Component\HttpKernel\KernelEvents;
|
||||
|
||||
/**
|
||||
* Implements the inline rendering strategy where the Request is rendered by the current HTTP kernel.
|
||||
@@ -29,12 +30,6 @@ class InlineFragmentRenderer extends RoutableFragmentRenderer
|
||||
private $kernel;
|
||||
private $dispatcher;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param HttpKernelInterface $kernel A HttpKernelInterface instance
|
||||
* @param EventDispatcherInterface $dispatcher A EventDispatcherInterface instance
|
||||
*/
|
||||
public function __construct(HttpKernelInterface $kernel, EventDispatcherInterface $dispatcher = null)
|
||||
{
|
||||
$this->kernel = $kernel;
|
||||
@@ -82,7 +77,7 @@ class InlineFragmentRenderer extends RoutableFragmentRenderer
|
||||
|
||||
$level = ob_get_level();
|
||||
try {
|
||||
return $this->kernel->handle($subRequest, HttpKernelInterface::SUB_REQUEST, false);
|
||||
return SubRequestHandler::handle($this->kernel, $subRequest, HttpKernelInterface::SUB_REQUEST, false);
|
||||
} catch (\Exception $e) {
|
||||
// we dispatch the exception event to trigger the logging
|
||||
// the response that comes back is simply ignored
|
||||
@@ -115,20 +110,6 @@ class InlineFragmentRenderer extends RoutableFragmentRenderer
|
||||
$cookies = $request->cookies->all();
|
||||
$server = $request->server->all();
|
||||
|
||||
// Override the arguments to emulate a sub-request.
|
||||
// Sub-request object will point to localhost as client ip and real client ip
|
||||
// will be included into trusted header for client ip
|
||||
try {
|
||||
if ($trustedHeaderName = Request::getTrustedHeaderName(Request::HEADER_CLIENT_IP)) {
|
||||
$currentXForwardedFor = $request->headers->get($trustedHeaderName, '');
|
||||
|
||||
$server['HTTP_'.$trustedHeaderName] = ($currentXForwardedFor ? $currentXForwardedFor.', ' : '').$request->getClientIp();
|
||||
}
|
||||
} catch (\InvalidArgumentException $e) {
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
$server['REMOTE_ADDR'] = '127.0.0.1';
|
||||
unset($server['HTTP_IF_MODIFIED_SINCE']);
|
||||
unset($server['HTTP_IF_NONE_MATCH']);
|
||||
|
||||
|
@@ -11,8 +11,8 @@
|
||||
|
||||
namespace Symfony\Component\HttpKernel\Fragment;
|
||||
|
||||
use Symfony\Component\HttpKernel\Controller\ControllerReference;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpKernel\Controller\ControllerReference;
|
||||
use Symfony\Component\HttpKernel\EventListener\FragmentListener;
|
||||
|
||||
/**
|
||||
@@ -80,7 +80,7 @@ abstract class RoutableFragmentRenderer implements FragmentRendererInterface
|
||||
private function checkNonScalar($values)
|
||||
{
|
||||
foreach ($values as $key => $value) {
|
||||
if (is_array($value)) {
|
||||
if (\is_array($value)) {
|
||||
$this->checkNonScalar($value);
|
||||
} elseif (!is_scalar($value) && null !== $value) {
|
||||
throw new \LogicException(sprintf('Controller attributes cannot contain non-scalar/non-null values (value for key "%s" is not a scalar or null).', $key));
|
||||
|
Reference in New Issue
Block a user