1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Jacobemerick\Web\Domain\Waterfall\Watercourse; |
4
|
|
|
|
5
|
|
|
use Aura\Sql\ConnectionLocator; |
6
|
|
|
|
7
|
|
|
class MysqlWatercourseRepository implements WatercourseRepositoryInterface |
8
|
|
|
{ |
9
|
|
|
|
10
|
|
|
/** @var Aura\Sql\ConnectionLocator */ |
11
|
|
|
protected $connections; |
12
|
|
|
|
13
|
|
|
/** |
14
|
|
|
* @param Aura\Sql\ConnectionLocator $connections |
15
|
|
|
*/ |
16
|
|
|
public function __construct(ConnectionLocator $connections) |
17
|
|
|
{ |
18
|
|
|
$this->connections = $connections; |
|
|
|
|
19
|
|
|
} |
20
|
|
|
|
21
|
|
|
// todo wot are you even serious |
22
|
|
|
public function getWatercourseList() |
23
|
|
|
{ |
24
|
|
|
$query = " |
25
|
|
|
SELECT `sum_table`.`name`, `sum_table`.`alias`, SUM(`count`) AS `count` |
26
|
|
|
FROM (( |
27
|
|
|
SELECT `watercourse`.`name`, `watercourse`.`alias`, `parent_count`.`count` |
28
|
|
|
FROM ( |
29
|
|
|
SELECT COUNT(1) AS `count`, `parent` AS `id` |
30
|
|
|
FROM `jpemeric_waterfall`.`watercourse` |
31
|
|
|
INNER JOIN `jpemeric_waterfall`.`waterfall` ON `waterfall`.`watercourse` = `watercourse`.`id` AND |
32
|
|
|
`waterfall`.`is_public` = :public |
33
|
|
|
WHERE `watercourse`.`parent` <> :no_parent |
34
|
|
|
GROUP BY `watercourse`.`id` |
35
|
|
|
) AS `parent_count` |
36
|
|
|
INNER JOIN `jpemeric_waterfall`.`watercourse` ON `watercourse`.`id` = `parent_count`.`id` AND |
37
|
|
|
`watercourse`.`has_page` = :has_page |
38
|
|
|
) UNION ALL ( |
39
|
|
|
SELECT `watercourse`.`name`, `watercourse`.`alias`, COUNT(1) AS `count` |
40
|
|
|
FROM `jpemeric_waterfall`.`watercourse` |
41
|
|
|
INNER JOIN `jpemeric_waterfall`.`waterfall` ON `waterfall`.`watercourse` = `watercourse`.`id` AND |
42
|
|
|
`waterfall`.`is_public` = :public |
43
|
|
|
WHERE `watercourse`.`parent` = :no_parent AND `watercourse`.`has_page` = :has_page |
44
|
|
|
GROUP BY `watercourse`.`id` |
45
|
|
|
)) AS `sum_table` |
46
|
|
|
GROUP BY `alias` |
47
|
|
|
ORDER BY `name`"; |
48
|
|
|
|
49
|
|
|
$bindings = [ |
50
|
|
|
'public' => 1, |
51
|
|
|
'no_parent' => 0, |
52
|
|
|
'has_page' => 1, |
53
|
|
|
]; |
54
|
|
|
|
55
|
|
|
return $this |
56
|
|
|
->connections |
57
|
|
|
->getRead() |
58
|
|
|
->fetchAll($query, $bindings); |
59
|
|
|
} |
60
|
|
|
} |
61
|
|
|
|
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..