|
1
|
|
|
<?php declare(strict_types=1); |
|
2
|
|
|
|
|
3
|
|
|
namespace TemplateNamespace\Entity\Repositories; |
|
4
|
|
|
|
|
5
|
|
|
use EdmondsCommerce\DoctrineStaticMeta\Entity\Interfaces\EntityInterface; |
|
6
|
|
|
use TemplateNamespace\Entity\Interfaces\TemplateEntityInterface; |
|
7
|
|
|
use TemplateNamespace\Entity\Repositories\AbstractEntityRepository as ProjectAbstractEntityRepository; |
|
8
|
|
|
|
|
9
|
|
|
|
|
10
|
|
|
class TemplateEntityRepository extends ProjectAbstractEntityRepository |
|
11
|
|
|
{ |
|
12
|
|
|
public function find($id, ?int $lockMode = null, ?int $lockVersion = null): ?TemplateEntityInterface |
|
13
|
|
|
{ |
|
14
|
|
|
$result = parent::find($id, $lockMode, $lockVersion); |
|
15
|
|
|
if ($result === null || $result instanceof TemplateEntityInterface) { |
|
16
|
|
|
return $result; |
|
17
|
|
|
} |
|
18
|
|
|
|
|
19
|
|
|
throw new \RuntimeException('Unknown entity type of ' . \get_class($result) . ' returned'); |
|
20
|
|
|
} |
|
21
|
|
|
|
|
22
|
|
|
public function get($id, ?int $lockMode = null, ?int $lockVersion = null): TemplateEntityInterface |
|
23
|
|
|
{ |
|
24
|
|
|
$result = parent::get($id, $lockMode, $lockVersion); |
|
25
|
|
|
if ($result instanceof TemplateEntityInterface) { |
|
26
|
|
|
return $result; |
|
27
|
|
|
} |
|
28
|
|
|
throw new \RuntimeException('Unknown entity type of ' . \get_class($result) . ' returned'); |
|
29
|
|
|
} |
|
30
|
|
|
|
|
31
|
|
|
public function getOneBy(array $criteria, ?array $orderBy = null): TemplateEntityInterface |
|
32
|
|
|
{ |
|
33
|
|
|
$result = $this->findOneBy($criteria, $orderBy); |
|
|
|
|
|
|
34
|
|
|
if ($result === null) { |
|
|
|
|
|
|
35
|
|
|
throw new \RuntimeException('Could not find the entity'); |
|
36
|
|
|
} |
|
37
|
|
|
|
|
38
|
|
|
return $result; |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
public function findOneBy(array $criteria, ?array $orderBy = null): ?TemplateEntityInterface |
|
42
|
|
|
{ |
|
43
|
|
|
$result = parent::findOneBy($criteria, $orderBy); |
|
44
|
|
|
if ($result === null || $result instanceof TemplateEntityInterface) { |
|
45
|
|
|
return $result; |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
|
|
throw new \RuntimeException('Unknown entity type of ' . \get_class($result) . ' returned'); |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
/** |
|
52
|
|
|
* @param array $criteria |
|
53
|
|
|
* @param array|null $orderBy |
|
54
|
|
|
* @param int|null $limit |
|
55
|
|
|
* @param int|null $offset |
|
56
|
|
|
* |
|
57
|
|
|
* @return TemplateEntityInterface[]|array|EntityInterface[] |
|
58
|
|
|
*/ |
|
59
|
|
|
public function findBy(array $criteria, ?array $orderBy = null, ?int $limit = null, ?int $offset = null): array |
|
60
|
|
|
{ |
|
61
|
|
|
return parent::findBy($criteria, $orderBy, $limit, $offset); |
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
|
|
/** |
|
65
|
|
|
* @return TemplateEntityInterface[]|array|EntityInterface[] |
|
66
|
|
|
*/ |
|
67
|
|
|
public function findAll(): array |
|
68
|
|
|
{ |
|
69
|
|
|
return parent::findAll(); |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
|
|
|
|
73
|
|
|
|
|
74
|
|
|
|
|
75
|
|
|
public function getRandomOneBy(array $criteria): ?TemplateEntityInterface |
|
76
|
|
|
{ |
|
77
|
|
|
$result = parent::getRandomOneBy($criteria); |
|
78
|
|
|
if ($result === null || $result instanceof TemplateEntityInterface) { |
|
79
|
|
|
return $result; |
|
80
|
|
|
} |
|
81
|
|
|
throw new \RuntimeException('Unknown entity type of ' . \get_class($result) . ' returned'); |
|
82
|
|
|
} |
|
83
|
|
|
|
|
84
|
|
|
/** |
|
85
|
|
|
* @param array $criteria |
|
86
|
|
|
* @param int $numToGet |
|
87
|
|
|
* |
|
88
|
|
|
* @return TemplateEntityInterface[]|array|EntityInterface[] |
|
89
|
|
|
*/ |
|
90
|
|
|
public function getRandomBy(array $criteria, int $numToGet = 1): array |
|
91
|
|
|
{ |
|
92
|
|
|
return parent::getRandomBy($criteria, $numToGet); |
|
93
|
|
|
} |
|
94
|
|
|
|
|
95
|
|
|
/** |
|
96
|
|
|
* @param EntityInterface|TemplateEntityInterface $entity |
|
97
|
|
|
* |
|
98
|
|
|
* @return TemplateEntityInterface |
|
99
|
|
|
*/ |
|
100
|
|
|
public function initialiseEntity(EntityInterface $entity): TemplateEntityInterface |
|
101
|
|
|
{ |
|
102
|
|
|
return parent::initialiseEntity($entity); |
|
|
|
|
|
|
103
|
|
|
} |
|
104
|
|
|
|
|
105
|
|
|
|
|
106
|
|
|
} |
|
107
|
|
|
|
This check looks for function or method calls that always return null and whose return value is assigned to a variable.
The method
getObject()can return nothing but null, so it makes no sense to assign that value to a variable.The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.