|
1
|
|
|
<?php declare(strict_types=1); |
|
2
|
|
|
|
|
3
|
|
|
namespace Shopware\Core\Content\Seo; |
|
4
|
|
|
|
|
5
|
|
|
use Shopware\Core\Content\Seo\Exception\InvalidTemplateException; |
|
6
|
|
|
use Shopware\Core\Content\Seo\Exception\NoEntitiesForPreviewException; |
|
7
|
|
|
use Shopware\Core\Content\Seo\Exception\SeoUrlRouteNotFoundException; |
|
8
|
|
|
use Shopware\Core\Framework\Api\Exception\InvalidSalesChannelIdException; |
|
9
|
|
|
use Shopware\Core\Framework\HttpException; |
|
10
|
|
|
use Shopware\Core\Framework\Log\Package; |
|
11
|
|
|
use Shopware\Core\Framework\ShopwareHttpException; |
|
12
|
|
|
use Symfony\Component\HttpFoundation\Response; |
|
13
|
|
|
|
|
14
|
|
|
#[Package('sales-channel')] |
|
15
|
|
|
class SeoException extends HttpException |
|
16
|
|
|
{ |
|
17
|
|
|
public const SALES_CHANNEL_ID_PARAMETER_IS_MISSING = 'FRAMEWORK__SALES_CHANNEL_ID_PARAMETER_IS_MISSING'; |
|
18
|
|
|
public const TEMPLATE_PARAMETER_IS_MISSING = 'FRAMEWORK__TEMPLATE_PARAMETER_IS_MISSING'; |
|
19
|
|
|
public const ROUTE_NAME_PARAMETER_IS_MISSING = 'FRAMEWORK__ROUTE_NAME_PARAMETER_IS_MISSING'; |
|
20
|
|
|
public const ENTITY_NAME_PARAMETER_IS_MISSING = 'FRAMEWORK__ENTITY_NAME_PARAMETER_IS_MISSING'; |
|
21
|
|
|
public const SALES_CHANNEL_NOT_FOUND = 'FRAMEWORK__SALES_CHANNEL_NOT_FOUND'; |
|
22
|
|
|
|
|
23
|
|
|
public static function invalidSalesChannelId(string $salesChannelId): ShopwareHttpException |
|
24
|
|
|
{ |
|
25
|
|
|
return new InvalidSalesChannelIdException($salesChannelId); |
|
26
|
|
|
} |
|
27
|
|
|
|
|
28
|
|
|
public static function salesChannelIdParameterIsMissing(): self |
|
29
|
|
|
{ |
|
30
|
|
|
return new self( |
|
31
|
|
|
Response::HTTP_BAD_REQUEST, |
|
32
|
|
|
self::SALES_CHANNEL_ID_PARAMETER_IS_MISSING, |
|
33
|
|
|
'Parameter "salesChannelId" is missing.', |
|
34
|
|
|
); |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
|
|
public static function templateParameterIsMissing(): self |
|
38
|
|
|
{ |
|
39
|
|
|
return new self( |
|
40
|
|
|
Response::HTTP_BAD_REQUEST, |
|
41
|
|
|
self::TEMPLATE_PARAMETER_IS_MISSING, |
|
42
|
|
|
'Parameter "template" is missing.', |
|
43
|
|
|
); |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
public static function entityNameParameterIsMissing(): self |
|
47
|
|
|
{ |
|
48
|
|
|
return new self( |
|
49
|
|
|
Response::HTTP_BAD_REQUEST, |
|
50
|
|
|
self::ENTITY_NAME_PARAMETER_IS_MISSING, |
|
51
|
|
|
'Parameter "entityName" is missing.', |
|
52
|
|
|
); |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
public static function routeNameParameterIsMissing(): self |
|
56
|
|
|
{ |
|
57
|
|
|
return new self( |
|
58
|
|
|
Response::HTTP_BAD_REQUEST, |
|
59
|
|
|
self::ROUTE_NAME_PARAMETER_IS_MISSING, |
|
60
|
|
|
'Parameter "routeName" is missing.', |
|
61
|
|
|
); |
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
|
|
public static function salesChannelNotFound(string $salesChannelId): self |
|
65
|
|
|
{ |
|
66
|
|
|
return new self( |
|
67
|
|
|
Response::HTTP_NOT_FOUND, |
|
68
|
|
|
self::SALES_CHANNEL_NOT_FOUND, |
|
69
|
|
|
'Sales channel with id "{{ salesChannelId }}" not found.', |
|
70
|
|
|
['salesChannelId' => $salesChannelId] |
|
71
|
|
|
); |
|
72
|
|
|
} |
|
73
|
|
|
|
|
74
|
|
|
public static function seoUrlRouteNotFound(string $routeName): ShopwareHttpException |
|
75
|
|
|
{ |
|
76
|
|
|
return new SeoUrlRouteNotFoundException($routeName); |
|
77
|
|
|
} |
|
78
|
|
|
|
|
79
|
|
|
public static function noEntitiesForPreview(string $entityName, string $routeName): ShopwareHttpException |
|
80
|
|
|
{ |
|
81
|
|
|
return new NoEntitiesForPreviewException($entityName, $routeName); |
|
82
|
|
|
} |
|
83
|
|
|
|
|
84
|
|
|
public static function invalidTemplate(string $message): ShopwareHttpException |
|
85
|
|
|
{ |
|
86
|
|
|
return new InvalidTemplateException($message); |
|
87
|
|
|
} |
|
88
|
|
|
} |
|
89
|
|
|
|