/
RoutingException.php
57 lines (50 loc) · 1.98 KB
/
RoutingException.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<?php declare(strict_types=1);
namespace Shopware\Core\Framework\Routing;
use Shopware\Core\Framework\HttpException;
use Shopware\Core\Framework\Log\Package;
use Symfony\Component\HttpFoundation\Response;
#[Package('core')]
class RoutingException extends HttpException
{
public const MISSING_REQUEST_PARAMETER_CODE = 'FRAMEWORK__MISSING_REQUEST_PARAMETER';
public const INVALID_REQUEST_PARAMETER_CODE = 'FRAMEWORK__INVALID_REQUEST_PARAMETER';
public const APP_INTEGRATION_NOT_FOUND = 'FRAMEWORK__APP_INTEGRATION_NOT_FOUND';
public const LANGUAGE_NOT_FOUND = 'FRAMEWORK__LANGUAGE_NOT_FOUND';
public const SALES_CHANNEL_MAINTENANCE_MODE = 'FRAMEWORK__ROUTING_SALES_CHANNEL_MAINTENANCE';
public static function invalidRequestParameter(string $name): self
{
return new self(
Response::HTTP_BAD_REQUEST,
self::INVALID_REQUEST_PARAMETER_CODE,
'The parameter "{{ parameter }}" is invalid.',
['parameter' => $name]
);
}
public static function missingRequestParameter(string $name, string $path = ''): self
{
return new self(
Response::HTTP_BAD_REQUEST,
self::MISSING_REQUEST_PARAMETER_CODE,
'Parameter "{{ parameterName }}" is missing.',
['parameterName' => $name, 'path' => $path]
);
}
public static function languageNotFound(?string $languageId): self
{
return new self(
Response::HTTP_PRECONDITION_FAILED,
self::LANGUAGE_NOT_FOUND,
self::$couldNotFindMessage,
['entity' => 'language', 'field' => 'id', 'value' => $languageId]
);
}
public static function appIntegrationNotFound(string $integrationId): self
{
return new self(
Response::HTTP_BAD_REQUEST,
self::APP_INTEGRATION_NOT_FOUND,
self::$couldNotFindMessage,
['entity' => 'app integration', 'field' => 'id', 'value' => $integrationId]
);
}
}