1 <?php
declare(strict_types
=1);
4 * This file is part of the Rapsys PackBundle package.
6 * (c) Raphaël Gertz <symfony@rapsys.eu>
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Rapsys\PackBundle\Context
;
14 use Symfony\Component\Asset\Context\RequestStackContext
as BaseRequestStackContext
;
15 use Symfony\Component\HttpFoundation\RequestStack
;
20 class RequestStackContext
extends BaseRequestStackContext
{
24 public function __construct(protected RequestStack
$requestStack, protected string $basePath = '', protected bool $secure = false) {
25 //Call parent constructor
26 parent
::__construct($requestStack, $basePath, $secure);
30 * Returns the base url
32 * @return string The base url
34 public function getBaseUrl(): string {
36 if (!$request = $this->requestStack
->getMainRequest()) {
38 return $this->basePath
;
42 return $request->getSchemeAndHttpHost().$request->getBaseUrl();