1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Ps2alerts\Api\Controller\Statistics; |
4
|
|
|
|
5
|
|
|
use League\Route\Http\JsonResponse as Response; |
6
|
|
|
use Ps2alerts\Api\Controller\EndpointBaseController; |
7
|
|
|
use Ps2alerts\Api\Loader\Statistics\AlertStatisticsLoader; |
8
|
|
|
use Symfony\Component\HttpFoundation\Request; |
9
|
|
|
|
10
|
|
|
class AlertStatisticsEndpoint extends EndpointBaseController |
11
|
|
|
{ |
12
|
|
|
/** |
13
|
|
|
* Construct |
14
|
|
|
* |
15
|
|
|
* @param \Ps2alerts\Api\Loader\Statistics\AlertStatisticsLoader $loader |
16
|
|
|
*/ |
17
|
|
|
public function __construct(AlertStatisticsLoader $loader) |
18
|
|
|
{ |
19
|
|
|
$this->loader = $loader; |
20
|
|
|
} |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* Gets total alerts based on provided parameters |
24
|
|
|
* |
25
|
|
|
* @param \Symfony\Component\HttpFoundation\Request $request |
26
|
|
|
* |
27
|
|
|
* @return \League\Route\Http\JsonResponse |
28
|
|
|
*/ |
29
|
|
|
public function readTotals(Request $request) |
30
|
|
|
{ |
31
|
|
|
$post = $request->request->all(); |
32
|
|
|
|
33
|
|
|
$this->getLogDriver()->addDebug(json_encode($post)); |
34
|
|
|
|
35
|
|
|
$return = $this->loader->readTotals($post); |
|
|
|
|
36
|
|
|
|
37
|
|
|
if (empty($return)) { |
38
|
|
|
return new Response\NoContent(); |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
return new Response\Ok($return); |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* Retrieves the zones totals |
46
|
|
|
* |
47
|
|
|
* @param \Symfony\Component\HttpFoundation\Request $request |
48
|
|
|
* |
49
|
|
|
* @return \League\Route\Http\JsonResponse |
50
|
|
|
*/ |
51
|
|
|
public function readZoneTotals(Request $request) |
|
|
|
|
52
|
|
|
{ |
53
|
|
|
$return = $this->loader->readZoneTotals(); |
|
|
|
|
54
|
|
|
|
55
|
|
|
if (empty($return)) { |
56
|
|
|
return new Response\NoContent(); |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
return new Response\Ok($return); |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* Retrieves the victory summary (daily or monthly) |
64
|
|
|
* |
65
|
|
|
* @param \Symfony\Component\HttpFoundation\Request $request |
66
|
|
|
* |
67
|
|
|
* @return \League\Route\Http\JsonResponse |
68
|
|
|
*/ |
69
|
|
|
public function readHistorySummary(Request $request) |
70
|
|
|
{ |
71
|
|
|
$post = $request->request->all(); |
72
|
|
|
|
73
|
|
|
$return = $this->loader->readHistorySummary($post); |
|
|
|
|
74
|
|
|
|
75
|
|
|
if (empty($return)) { |
76
|
|
|
return new Response\NoContent(); |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
return new Response\Ok($return); |
80
|
|
|
} |
81
|
|
|
} |
82
|
|
|
|
It seems like the method you are trying to call exists only in some of the possible types.
Let’s take a look at an example:
Available Fixes
Add an additional type-check:
Only allow a single type to be passed if the variable comes from a parameter: