1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
|
4
|
|
|
namespace Pfilsx\DataGrid\Grid\Providers; |
5
|
|
|
|
6
|
|
|
|
7
|
|
|
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository; |
8
|
|
|
use Doctrine\ORM\EntityManager; |
9
|
|
|
use Doctrine\ORM\EntityRepository; |
10
|
|
|
use Doctrine\ORM\QueryBuilder; |
11
|
|
|
use Pfilsx\DataGrid\DataGridException; |
12
|
|
|
use Pfilsx\DataGrid\Grid\Pager; |
13
|
|
|
use Symfony\Component\Lock\Exception\NotSupportedException; |
|
|
|
|
14
|
|
|
|
15
|
|
|
abstract class DataProvider implements DataProviderInterface |
16
|
|
|
{ |
17
|
|
|
protected $pager; |
18
|
|
|
|
19
|
|
|
protected $countFieldName; |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* @internal |
23
|
|
|
* @return Pager |
24
|
|
|
*/ |
25
|
|
|
public function getPager(): Pager |
26
|
|
|
{ |
27
|
|
|
return $this->pager; |
28
|
|
|
} |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* @internal |
32
|
|
|
* @param Pager $pager |
33
|
|
|
*/ |
34
|
|
|
public function setPager(Pager $pager): void |
35
|
|
|
{ |
36
|
|
|
$this->pager = $pager; |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
public function setCountFieldName(string $name): DataProviderInterface |
40
|
|
|
{ |
41
|
|
|
$this->countFieldName = $name; |
42
|
|
|
return $this; |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
public function getCountFieldName(): string |
46
|
|
|
{ |
47
|
|
|
return $this->countFieldName; |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
public function addEqualFilter(string $attribute, $value): DataProviderInterface |
51
|
|
|
{ |
52
|
|
|
throw new NotSupportedException("Method addEqualFilter() is not supported in " . static::class); |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
public function addLikeFilter(string $attribute, $value): DataProviderInterface |
56
|
|
|
{ |
57
|
|
|
throw new NotSupportedException("Method addLikeFilter() is not supported in " . static::class); |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
public function addRelationFilter(string $attribute, $value, string $relationClass): DataProviderInterface |
61
|
|
|
{ |
62
|
|
|
throw new NotSupportedException("Method addRelationFilter() is not supported in " . static::class); |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
public function addCustomFilter(string $attribute, $value, callable $callback): DataProviderInterface |
66
|
|
|
{ |
67
|
|
|
throw new NotSupportedException("Method addCustomFilter() is not supported in " . static::class); |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
public function addDateFilter(string $attribute, $value, string $comparison = 'equal'): DataProviderInterface |
71
|
|
|
{ |
72
|
|
|
$comparisonFunc = lcfirst($comparison) . 'Date'; |
73
|
|
|
if (method_exists($this, $comparisonFunc)) { |
74
|
|
|
$this->$comparisonFunc($attribute, $value); |
75
|
|
|
} else { |
76
|
|
|
$this->equalDate($attribute, $value); |
77
|
|
|
} |
78
|
|
|
return $this; |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
protected function equalDate($attribute, $value): void |
82
|
|
|
{ |
83
|
|
|
throw new NotSupportedException("Method equalDate() is not supported in " . static::class); |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
|
87
|
|
|
public static function create($data, EntityManager $doctrine = null): DataProviderInterface |
88
|
|
|
{ |
89
|
|
|
if ($data instanceof EntityRepository) { |
90
|
|
|
return new RepositoryDataProvider($data, $doctrine); |
|
|
|
|
91
|
|
|
} |
92
|
|
|
if ($data instanceof QueryBuilder) { |
93
|
|
|
return new QueryBuilderDataProvider($data, $doctrine); |
|
|
|
|
94
|
|
|
} |
95
|
|
|
if (is_array($data)) { |
96
|
|
|
return new ArrayDataProvider($data); |
97
|
|
|
} |
98
|
|
|
throw new DataGridException('Provided data must be one of: ' . implode(', ', [ |
99
|
|
|
ServiceEntityRepository::class, |
100
|
|
|
QueryBuilder::class, |
101
|
|
|
'Array' |
102
|
|
|
]) . ', ' . (($type = gettype($data)) == 'object' ? get_class($data) : $type) . ' given'); |
103
|
|
|
} |
104
|
|
|
} |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths