Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 29 |
|
0.00% |
0 / 22 |
CRAP | |
0.00% |
0 / 1 |
TerminLabel | |
0.00% |
0 / 29 |
|
0.00% |
0 / 22 |
702 | |
0.00% |
0 / 1 |
__construct | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
getId | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
setId | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getIdent | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
setIdent | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getName | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
setName | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getDetails | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
setDetails | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getIcon | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
setIcon | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getPosition | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
setPosition | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getEntityNameForStorage | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getEntityIdForStorage | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getPositionFieldName | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
12 | |||
getPositionForEntityField | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
12 | |||
getIdFieldNameForSearch | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getIdForSearch | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getTitleForSearch | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getCriteriaForFilter | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getCriteriaForQuery | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
2 |
1 | <?php |
2 | |
3 | namespace Olz\Entity\Termine; |
4 | |
5 | use Doctrine\Common\Collections\ArrayCollection; |
6 | use Doctrine\Common\Collections\Collection; |
7 | use Doctrine\Common\Collections\Criteria; |
8 | use Doctrine\Common\Collections\Expr\Expression; |
9 | use Doctrine\ORM\Mapping as ORM; |
10 | use Olz\Entity\Common\DataStorageInterface; |
11 | use Olz\Entity\Common\DataStorageTrait; |
12 | use Olz\Entity\Common\OlzEntity; |
13 | use Olz\Entity\Common\PositionableInterface; |
14 | use Olz\Entity\Common\SearchableInterface; |
15 | use Olz\Repository\Termine\TerminLabelRepository; |
16 | |
17 | #[ORM\Table(name: 'termin_labels')] |
18 | #[ORM\Index(name: 'ident_index', columns: ['on_off', 'ident'])] |
19 | #[ORM\Index(name: 'name_index', columns: ['name'])] |
20 | #[ORM\Index(name: 'position_index', columns: ['on_off', 'position'])] |
21 | #[ORM\Entity(repositoryClass: TerminLabelRepository::class)] |
22 | class TerminLabel extends OlzEntity implements DataStorageInterface, PositionableInterface, SearchableInterface { |
23 | use DataStorageTrait; |
24 | |
25 | #[ORM\Id] |
26 | #[ORM\Column(type: 'integer', nullable: false)] |
27 | #[ORM\GeneratedValue] |
28 | private int $id; |
29 | |
30 | #[ORM\Column(type: 'string', length: 31, nullable: false)] |
31 | private string $ident; |
32 | |
33 | #[ORM\Column(type: 'string', length: 127, nullable: false)] |
34 | private string $name; |
35 | |
36 | #[ORM\Column(type: 'text', nullable: true)] |
37 | private ?string $details; |
38 | |
39 | #[ORM\Column(type: 'text', nullable: true)] |
40 | private ?string $icon; |
41 | |
42 | #[ORM\Column(type: 'smallfloat', nullable: false)] |
43 | private float $position; |
44 | |
45 | /** @var Collection<int|string, Termin>&iterable<Termin> */ |
46 | #[ORM\ManyToMany(targetEntity: Termin::class, mappedBy: 'labels')] |
47 | private Collection $termine; |
48 | |
49 | /** @var Collection<int|string, TerminTemplate>&iterable<TerminTemplate> */ |
50 | #[ORM\ManyToMany(targetEntity: TerminTemplate::class, mappedBy: 'labels')] |
51 | private Collection $termin_templates; |
52 | |
53 | public function __construct() { |
54 | $this->termine = new ArrayCollection(); |
55 | $this->termin_templates = new ArrayCollection(); |
56 | } |
57 | |
58 | public function getId(): ?int { |
59 | return $this->id ?? null; |
60 | } |
61 | |
62 | public function setId(int $new_value): void { |
63 | $this->id = $new_value; |
64 | } |
65 | |
66 | public function getIdent(): string { |
67 | return $this->ident; |
68 | } |
69 | |
70 | public function setIdent(string $new_value): void { |
71 | $this->ident = $new_value; |
72 | } |
73 | |
74 | public function getName(): string { |
75 | return $this->name; |
76 | } |
77 | |
78 | public function setName(string $new_value): void { |
79 | $this->name = $new_value; |
80 | } |
81 | |
82 | public function getDetails(): ?string { |
83 | return $this->details; |
84 | } |
85 | |
86 | public function setDetails(?string $new_value): void { |
87 | $this->details = $new_value; |
88 | } |
89 | |
90 | public function getIcon(): ?string { |
91 | return $this->icon; |
92 | } |
93 | |
94 | public function setIcon(?string $new_value): void { |
95 | $this->icon = $new_value; |
96 | } |
97 | |
98 | public function getPosition(): float { |
99 | return $this->position; |
100 | } |
101 | |
102 | public function setPosition(float $new_value): void { |
103 | $this->position = $new_value; |
104 | } |
105 | |
106 | // --- |
107 | |
108 | public static function getEntityNameForStorage(): string { |
109 | return 'termin_labels'; |
110 | } |
111 | |
112 | public function getEntityIdForStorage(): string { |
113 | return "{$this->getId()}"; |
114 | } |
115 | |
116 | public static function getPositionFieldName(string $field): string { |
117 | switch ($field) { |
118 | case 'position': |
119 | return 'position'; |
120 | default: throw new \Exception("No such position field: {$field}"); |
121 | } |
122 | } |
123 | |
124 | public function getPositionForEntityField(string $field): ?float { |
125 | switch ($field) { |
126 | case 'position': |
127 | return $this->getPosition(); |
128 | default: throw new \Exception("No such position field: {$field}"); |
129 | } |
130 | } |
131 | |
132 | public static function getIdFieldNameForSearch(): string { |
133 | return 'id'; |
134 | } |
135 | |
136 | public function getIdForSearch(): int { |
137 | return $this->getId() ?? 0; |
138 | } |
139 | |
140 | public function getTitleForSearch(): string { |
141 | return $this->getName(); |
142 | } |
143 | |
144 | public static function getCriteriaForFilter(string $key, string $value): Expression { |
145 | throw new \Exception("No such TerminLabel filter: {$key}"); |
146 | } |
147 | |
148 | public static function getCriteriaForQuery(string $query): Expression { |
149 | return Criteria::expr()->orX( |
150 | Criteria::expr()->contains('name', $query), |
151 | ); |
152 | } |
153 | } |