|
1
|
|
|
<?php namespace Neomerx\Limoncello\Errors; |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* Copyright 2015 [email protected] (www.neomerx.com) |
|
5
|
|
|
* |
|
6
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
7
|
|
|
* you may not use this file except in compliance with the License. |
|
8
|
|
|
* You may obtain a copy of the License at |
|
9
|
|
|
* |
|
10
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0 |
|
11
|
|
|
* |
|
12
|
|
|
* Unless required by applicable law or agreed to in writing, software |
|
13
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS, |
|
14
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
15
|
|
|
* See the License for the specific language governing permissions and |
|
16
|
|
|
* limitations under the License. |
|
17
|
|
|
*/ |
|
18
|
|
|
|
|
19
|
|
|
use \Symfony\Component\HttpKernel\Exception\ConflictHttpException; |
|
20
|
|
|
use \Symfony\Component\HttpKernel\Exception\BadRequestHttpException; |
|
21
|
|
|
use \Neomerx\JsonApi\Contracts\Integration\ExceptionThrowerInterface; |
|
22
|
|
|
use \Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException; |
|
23
|
|
|
use \Symfony\Component\HttpKernel\Exception\NotAcceptableHttpException; |
|
24
|
|
|
use \Symfony\Component\HttpKernel\Exception\UnsupportedMediaTypeHttpException; |
|
25
|
|
|
|
|
26
|
|
|
/** |
|
27
|
|
|
* @package Neomerx\Limoncello |
|
28
|
|
|
*/ |
|
29
|
|
|
class ExceptionThrower implements ExceptionThrowerInterface |
|
30
|
|
|
{ |
|
31
|
|
|
/** |
|
32
|
|
|
* @inheritdoc |
|
33
|
|
|
*/ |
|
34
|
1 |
|
public function throwBadRequest() |
|
35
|
|
|
{ |
|
36
|
1 |
|
throw new BadRequestHttpException(); |
|
37
|
|
|
} |
|
38
|
|
|
|
|
39
|
|
|
/** |
|
40
|
|
|
* @inheritdoc |
|
41
|
|
|
*/ |
|
42
|
1 |
|
public function throwForbidden() |
|
43
|
|
|
{ |
|
44
|
1 |
|
throw new AccessDeniedHttpException(); |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
/** |
|
48
|
|
|
* @inheritdoc |
|
49
|
|
|
*/ |
|
50
|
1 |
|
public function throwNotAcceptable() |
|
51
|
|
|
{ |
|
52
|
1 |
|
throw new NotAcceptableHttpException(); |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
/** |
|
56
|
|
|
* @inheritdoc |
|
57
|
|
|
*/ |
|
58
|
1 |
|
public function throwConflict() |
|
59
|
|
|
{ |
|
60
|
1 |
|
throw new ConflictHttpException(); |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
/** |
|
64
|
|
|
* @inheritdoc |
|
65
|
|
|
*/ |
|
66
|
1 |
|
public function throwUnsupportedMediaType() |
|
67
|
|
|
{ |
|
68
|
1 |
|
throw new UnsupportedMediaTypeHttpException(); |
|
69
|
|
|
} |
|
70
|
|
|
} |
|
71
|
|
|
|