1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Finder\Http\Actions; |
4
|
|
|
|
5
|
|
|
use Population\Manipule\Managers\PostManager; |
6
|
|
|
use Illuminate\Contracts\Cache\Factory as CacheManager; |
7
|
|
|
use Illuminate\Contracts\Routing\ResponseFactory; |
8
|
|
|
use Illuminate\Http\JsonResponse; |
9
|
|
|
|
10
|
|
|
/** |
11
|
|
|
* Class PostDeleteByIdAction. |
12
|
|
|
* |
13
|
|
|
* @package Finder\Http\Actions |
14
|
|
|
*/ |
15
|
|
|
class PostDeleteByIdAction |
16
|
|
|
{ |
17
|
|
|
/** |
18
|
|
|
* @var ResponseFactory |
19
|
|
|
*/ |
20
|
|
|
private $responseFactory; |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* @var PostManager |
24
|
|
|
*/ |
25
|
|
|
private $postManager; |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* @var CacheManager |
29
|
|
|
*/ |
30
|
|
|
private $cacheManager; |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* PostDeleteByIdAction constructor. |
34
|
|
|
* |
35
|
|
|
* @param ResponseFactory $responseFactory |
36
|
|
|
* @param PostManager $postManager |
37
|
|
|
* @param CacheManager $cacheManager |
38
|
|
|
*/ |
39
|
|
|
public function __construct(ResponseFactory $responseFactory, PostManager $postManager, CacheManager $cacheManager) |
40
|
|
|
{ |
41
|
|
|
$this->responseFactory = $responseFactory; |
42
|
|
|
$this->postManager = $postManager; |
43
|
|
|
$this->cacheManager = $cacheManager; |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* @apiVersion 1.0.0 |
48
|
|
|
* @api {delete} /v1/posts/:post_id Delete |
49
|
|
|
* @apiName Delete |
50
|
|
|
* @apiGroup Posts |
51
|
|
|
* @apiHeader {String} Accept application/json |
52
|
|
|
* @apiParam {Integer{1..N}} :post_id Unique resource ID. |
53
|
|
|
* @apiSuccessExample {json} Success-Response: |
54
|
|
|
* HTTP/1.1 204 No Content |
55
|
|
|
*/ |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* Delete a post. |
59
|
|
|
* |
60
|
|
|
* @param mixed $id |
61
|
|
|
* @return JsonResponse |
62
|
|
|
*/ |
63
|
|
|
public function __invoke($id): JsonResponse |
64
|
|
|
{ |
65
|
|
|
$this->postManager->deleteById((int) $id); |
66
|
|
|
|
67
|
|
|
$this->cacheManager->tags(['posts', 'photos', 'tags'])->flush(); |
|
|
|
|
68
|
|
|
|
69
|
|
|
return $this->responseFactory->json(null, JsonResponse::HTTP_NO_CONTENT); |
70
|
|
|
} |
71
|
|
|
} |
72
|
|
|
|
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.