|
1
|
|
|
<?php declare(strict_types=1); |
|
2
|
|
|
|
|
3
|
|
|
namespace Shopware\Core\Checkout\Customer; |
|
4
|
|
|
|
|
5
|
|
|
use Shopware\Core\Framework\HttpException; |
|
6
|
|
|
use Shopware\Core\Framework\Log\Package; |
|
7
|
|
|
use Shopware\Core\Framework\ShopwareHttpException; |
|
8
|
|
|
use Symfony\Component\HttpFoundation\Response; |
|
9
|
|
|
|
|
10
|
|
|
#[Package('customer-order')] |
|
11
|
|
|
class CustomerException extends HttpException |
|
12
|
|
|
{ |
|
13
|
|
|
public const CUSTOMER_NOT_FOUND = 'CHECKOUT__CUSTOMER_NOT_FOUND'; |
|
14
|
|
|
public const CUSTOMER_GROUP_NOT_FOUND = 'CHECKOUT__CUSTOMER_GROUP_NOT_FOUND'; |
|
15
|
|
|
public const CUSTOMER_GROUP_REQUEST_NOT_FOUND = 'CHECKOUT__CUSTOMER_GROUP_REQUEST_NOT_FOUND'; |
|
16
|
|
|
public const CUSTOMER_NOT_LOGGED_IN = 'CHECKOUT__CUSTOMER_NOT_LOGGED_IN'; |
|
17
|
|
|
public const LINE_ITEM_DOWNLOAD_FILE_NOT_FOUND = 'CHECKOUT__LINE_ITEM_DOWNLOAD_FILE_NOT_FOUND'; |
|
18
|
|
|
public const CUSTOMER_IDS_PARAMETER_IS_MISSING = 'CHECKOUT__CUSTOMER_IDS_PARAMETER_IS_MISSING'; |
|
19
|
|
|
|
|
20
|
|
|
public static function customerGroupNotFound(string $id): self |
|
21
|
|
|
{ |
|
22
|
|
|
return new self( |
|
23
|
|
|
Response::HTTP_BAD_REQUEST, |
|
24
|
|
|
self::CUSTOMER_GROUP_NOT_FOUND, |
|
25
|
|
|
'Customer group with id "{{ id }}" not found', |
|
26
|
|
|
['id' => $id] |
|
27
|
|
|
); |
|
28
|
|
|
} |
|
29
|
|
|
|
|
30
|
|
|
public static function groupRequestNotFound(string $id): self |
|
31
|
|
|
{ |
|
32
|
|
|
return new self( |
|
33
|
|
|
Response::HTTP_BAD_REQUEST, |
|
34
|
|
|
self::CUSTOMER_GROUP_REQUEST_NOT_FOUND, |
|
35
|
|
|
'Group request for customer "{{ id }}" is not found', |
|
36
|
|
|
['id' => $id] |
|
37
|
|
|
); |
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
|
|
/** |
|
41
|
|
|
* @param string[] $ids |
|
42
|
|
|
*/ |
|
43
|
|
|
public static function customersNotFound(array $ids): self |
|
44
|
|
|
{ |
|
45
|
|
|
return new self( |
|
46
|
|
|
Response::HTTP_NOT_FOUND, |
|
47
|
|
|
self::CUSTOMER_NOT_FOUND, |
|
48
|
|
|
'These customers "{{ ids }}" are not found', |
|
49
|
|
|
['ids' => implode(', ', $ids)] |
|
50
|
|
|
); |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
public static function customerNotLoggedIn(): self |
|
54
|
|
|
{ |
|
55
|
|
|
return new self( |
|
56
|
|
|
Response::HTTP_FORBIDDEN, |
|
57
|
|
|
self::CUSTOMER_NOT_LOGGED_IN, |
|
58
|
|
|
'Customer is not logged in.', |
|
59
|
|
|
); |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
public static function downloadFileNotFound(string $downloadId): ShopwareHttpException |
|
63
|
|
|
{ |
|
64
|
|
|
return new self( |
|
65
|
|
|
Response::HTTP_NOT_FOUND, |
|
66
|
|
|
self::LINE_ITEM_DOWNLOAD_FILE_NOT_FOUND, |
|
67
|
|
|
'Line item download file with id "{{ downloadId }}" not found.', |
|
68
|
|
|
['downloadId' => $downloadId] |
|
69
|
|
|
); |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
|
|
public static function customerIdsParameterIsMissing(): ShopwareHttpException |
|
73
|
|
|
{ |
|
74
|
|
|
return new self( |
|
75
|
|
|
Response::HTTP_BAD_REQUEST, |
|
76
|
|
|
self::CUSTOMER_IDS_PARAMETER_IS_MISSING, |
|
77
|
|
|
'Parameter "customerIds" is missing.', |
|
78
|
|
|
); |
|
79
|
|
|
} |
|
80
|
|
|
} |
|
81
|
|
|
|