From 8f846ec4d74b6d95511dccb1bf2dbca55da1e645 Mon Sep 17 00:00:00 2001 From: lenybernard Date: Fri, 14 Feb 2014 14:20:51 +0100 Subject: [PATCH 1/2] Fix PathPackage CLI use by injecting RequestStack instead of Request If there is no request in stack, we set / as default basePath --- .../Resources/config/templating_php.xml | 2 +- .../Templating/Asset/PathPackage.php | 19 +++++++++++++------ 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/templating_php.xml b/src/Symfony/Bundle/FrameworkBundle/Resources/config/templating_php.xml index 0ebb44bbd2708..8cdd039d86980 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/templating_php.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/templating_php.xml @@ -44,7 +44,7 @@ - + diff --git a/src/Symfony/Bundle/FrameworkBundle/Templating/Asset/PathPackage.php b/src/Symfony/Bundle/FrameworkBundle/Templating/Asset/PathPackage.php index 6aa8c58824669..d01cff60268a3 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Templating/Asset/PathPackage.php +++ b/src/Symfony/Bundle/FrameworkBundle/Templating/Asset/PathPackage.php @@ -11,8 +11,9 @@ namespace Symfony\Bundle\FrameworkBundle\Templating\Asset; -use Symfony\Component\HttpFoundation\Request; use Symfony\Component\Templating\Asset\PathPackage as BasePathPackage; +use Symfony\Component\HttpFoundation\RequestStack; +use Symfony\Component\HttpFoundation\Request; /** * The path packages adds a version and a base path to asset URLs. @@ -24,12 +25,18 @@ class PathPackage extends BasePathPackage /** * Constructor. * - * @param Request $request The current request - * @param string $version The version - * @param string $format The version format + * @param Request $requestStack The current request + * @param string $version The version + * @param string $format The version format */ - public function __construct(Request $request, $version = null, $format = null) + public function __construct(RequestStack $requestStack, $version = null, $format = null) { - parent::__construct($request->getBasePath(), $version, $format); + if ($request = $requestStack->getCurrentRequest() instanceof Request) { + $path = $request->getBasePath(); + } else { + $path = "/"; + } + + parent::__construct($path, $version, $format); } } From a56de86be2397fcfb98e96be55b6ed1c3ad452ad Mon Sep 17 00:00:00 2001 From: lenybernard Date: Fri, 14 Feb 2014 14:54:57 +0100 Subject: [PATCH 2/2] fix bad syntax --- .../Bundle/FrameworkBundle/Templating/Asset/PathPackage.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/Templating/Asset/PathPackage.php b/src/Symfony/Bundle/FrameworkBundle/Templating/Asset/PathPackage.php index d01cff60268a3..ca9bb573d2173 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Templating/Asset/PathPackage.php +++ b/src/Symfony/Bundle/FrameworkBundle/Templating/Asset/PathPackage.php @@ -31,8 +31,8 @@ class PathPackage extends BasePathPackage */ public function __construct(RequestStack $requestStack, $version = null, $format = null) { - if ($request = $requestStack->getCurrentRequest() instanceof Request) { - $path = $request->getBasePath(); + if ($requestStack->getCurrentRequest() instanceof Request) { + $path = $requestStack->getCurrentRequest()->getBasePath(); } else { $path = "/"; } pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy