1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* To change this license header, choose License Headers in Project Properties. |
5
|
|
|
* To change this template file, choose Tools | Templates |
6
|
|
|
* and open the template in the editor. |
7
|
|
|
*/ |
8
|
|
|
|
9
|
|
|
namespace Maslosoft\Manganel\Helpers; |
10
|
|
|
|
11
|
|
|
use Maslosoft\Gazebo\PluginFactory; |
12
|
|
|
use Maslosoft\Manganel\Interfaces\QueryBuilder\BodyDecoratorInterface; |
13
|
|
|
use Maslosoft\Manganel\Interfaces\QueryBuilder\ConditionsAwareInterface; |
14
|
|
|
use Maslosoft\Manganel\Interfaces\QueryBuilder\DecoratorInterface; |
15
|
|
|
use Maslosoft\Manganel\Manganel; |
16
|
|
|
use Maslosoft\Manganel\SearchCriteria; |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* QueryBuilderDecorator |
20
|
|
|
* |
21
|
|
|
* @author Piotr Maselkowski <pmaselkowski at gmail.com> |
22
|
|
|
*/ |
23
|
|
|
class QueryBuilderDecorator |
24
|
|
|
{ |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* Manganel instance |
28
|
|
|
* @var Mangangel |
29
|
|
|
*/ |
30
|
|
|
private $manganel = null; |
31
|
|
|
|
32
|
7 |
|
public function __construct(Manganel $manganel) |
33
|
|
|
{ |
34
|
7 |
|
$this->manganel = $manganel; |
|
|
|
|
35
|
7 |
|
} |
36
|
|
|
|
37
|
7 |
|
public function decorate(&$body, SearchCriteria $criteria) |
38
|
|
|
{ |
39
|
7 |
|
$bodyDecorators = (new PluginFactory())->instance($this->manganel->decorators, $criteria, [ |
40
|
|
|
BodyDecoratorInterface::class |
41
|
7 |
|
]); |
42
|
7 |
|
$conditionsDecorators = (new PluginFactory())->instance($this->manganel->decorators, $criteria, [ |
43
|
|
|
DecoratorInterface::class |
44
|
7 |
|
]); |
45
|
|
|
|
46
|
7 |
|
$conditions = []; |
47
|
7 |
|
foreach ($conditionsDecorators as $decorator) |
48
|
|
|
{ |
49
|
|
|
/* @var $decorator DecoratorInterface */ |
50
|
7 |
|
$decorator->decorate($conditions, $criteria); |
51
|
|
|
} |
52
|
|
|
|
53
|
7 |
|
foreach ($bodyDecorators as $decorator) |
54
|
|
|
{ |
55
|
|
|
/* @var $decorator BodyDecoratorInterface */ |
56
|
7 |
|
if ($decorator instanceof ConditionsAwareInterface) |
57
|
|
|
{ |
58
|
7 |
|
$decorator->setConditions($conditions); |
59
|
|
|
} |
60
|
7 |
|
$decorator->decorate($body, $criteria); |
61
|
|
|
} |
62
|
7 |
|
} |
63
|
|
|
|
64
|
|
|
} |
65
|
|
|
|
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..