1
|
|
|
<?php declare(strict_types=1); |
2
|
|
|
|
3
|
|
|
namespace Shopware\Storefront\Controller\Exception; |
4
|
|
|
|
5
|
|
|
use Shopware\Core\Framework\HttpException; |
6
|
|
|
use Shopware\Core\Framework\Log\Package; |
7
|
|
|
use Symfony\Component\HttpFoundation\Response; |
8
|
|
|
|
9
|
|
|
#[Package('storefront')] |
10
|
|
|
class StorefrontException extends HttpException |
11
|
|
|
{ |
12
|
|
|
final public const CAN_NOT_RENDER_VIEW = 'STOREFRONT__CAN_NOT_RENDER_VIEW'; |
13
|
|
|
final public const UN_SUPPORT_STOREFRONT_RESPONSE = 'STOREFRONT__UN_SUPPORT_STOREFRONT_RESPONSE'; |
14
|
|
|
final public const CLASS_DONT_HAVE_TWIG_INJECTED = 'STOREFRONT__CLASS_DONT_HAVE_TWIG_INJECTED'; |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* @param array<string, mixed> $parameters |
18
|
|
|
*/ |
19
|
|
|
public static function cannotRenderView(string $view, string $message, array $parameters): self |
20
|
|
|
{ |
21
|
|
|
return new self( |
22
|
|
|
Response::HTTP_INTERNAL_SERVER_ERROR, |
23
|
|
|
self::CAN_NOT_RENDER_VIEW, |
24
|
|
|
'Can not render {{ view }} view: {{ message }} with these parameters: {{ parameters }}', |
25
|
|
|
[ |
26
|
|
|
'message' => $message, |
27
|
|
|
'view' => $view, |
28
|
|
|
'parameters' => \json_encode($parameters), |
29
|
|
|
] |
30
|
|
|
); |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
public static function unSupportStorefrontResponse(): self |
34
|
|
|
{ |
35
|
|
|
return new self( |
36
|
|
|
Response::HTTP_INTERNAL_SERVER_ERROR, |
37
|
|
|
self::UN_SUPPORT_STOREFRONT_RESPONSE, |
38
|
|
|
'Symfony render implementation changed. Providing a response is no longer supported' |
39
|
|
|
); |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
public static function dontHaveTwigInjected(string $class): self |
43
|
|
|
{ |
44
|
|
|
return new self( |
45
|
|
|
Response::HTTP_INTERNAL_SERVER_ERROR, |
46
|
|
|
self::CLASS_DONT_HAVE_TWIG_INJECTED, |
47
|
|
|
'Class {{ class }} does not have twig injected. Add to your service definition a method call to setTwig with the twig instance', |
48
|
|
|
['class' => $class] |
49
|
|
|
); |
50
|
|
|
} |
51
|
|
|
} |
52
|
|
|
|