1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* This file is part of the wow-apps/symfony-proxybonanza project |
4
|
|
|
* https://github.com/wow-apps/symfony-proxybonanza |
5
|
|
|
* |
6
|
|
|
* (c) 2016 WoW-Apps |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace WowApps\ProxybonanzaBundle\Repository; |
13
|
|
|
|
14
|
|
|
use Doctrine\DBAL\Driver\PDOConnection; |
15
|
|
|
use Doctrine\ORM\EntityManager; |
16
|
|
|
use Doctrine\ORM\EntityRepository; |
17
|
|
|
use Doctrine\ORM\Mapping; |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* Class AbstractRepository |
21
|
|
|
* @author Alexey Samara <[email protected]> |
22
|
|
|
* @package wow-apps/symfony-proxybonanza |
23
|
|
|
*/ |
24
|
|
|
abstract class AbstractRepository extends EntityRepository |
25
|
|
|
{ |
26
|
|
|
/** @var PDOConnection */ |
27
|
|
|
protected $pdoDB; |
28
|
|
|
|
29
|
|
|
/** @var EntityManager */ |
30
|
|
|
protected $entityManager; |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* AbstractRepository constructor. |
34
|
|
|
* @param EntityManager $entityManager |
35
|
|
|
* @param Mapping\ClassMetadata $class |
36
|
|
|
*/ |
37
|
|
|
public function __construct(EntityManager $entityManager, Mapping\ClassMetadata $class) |
38
|
|
|
{ |
39
|
|
|
parent::__construct($entityManager, $class); |
40
|
|
|
$this->entityManager = $entityManager; |
41
|
|
|
$this->pdoDB = $entityManager->getConnection(); |
|
|
|
|
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* @param string $value |
46
|
|
|
* @return string |
47
|
|
|
*/ |
48
|
|
|
protected function quote(string $value): string |
49
|
|
|
{ |
50
|
|
|
$emptyValues = ['%', '%%', '_']; |
51
|
|
|
if (($value === 0) || (!empty($value) && !in_array($value, $emptyValues))) { |
52
|
|
|
return $this->pdoDB->quote($value); |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
return 'NULL'; |
56
|
|
|
} |
57
|
|
|
} |
58
|
|
|
|
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..