Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 109 |
|
0.00% |
0 / 56 |
CRAP | |
0.00% |
0 / 1 |
| Benutzer | |
0.00% |
0 / 109 |
|
0.00% |
0 / 56 |
4830 | |
0.00% |
0 / 1 |
| __construct | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
| __toString | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getUserIdentifier | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getAbteilung | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| setAbteilung | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
| getFilter | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| isAktiv | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| setAktiv | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
| getEmail | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| setEmail | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
| getFax | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| setFax | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
| getKuerzel | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
| setKuerzel | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
| getLfdnr | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getLogin | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| setLogin | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
6 | |||
| getLoginversuche | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| setLoginversuche | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
| getLogout | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| setLogout | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
6 | |||
| getMitarbeiter | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| setMitarbeiter | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
| getName | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| setName | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
| getPassword | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getPasswort | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| setPasswort | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
| getPassworthash | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| setPassworthash | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
| getMobilpinhash | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| setMobilpinhash | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
| getPrivat | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| isPrivat | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
| getProgramm | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| setProgramm | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
| isProtokoll | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| setProtokoll | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
| getRoles | |
0.00% |
0 / 5 |
|
0.00% |
0 / 1 |
6 | |||
| getSalt | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| eraseCredentials | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getTelefon | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| setTelefon | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
| getUsername | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getVorname | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| setVorname | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
| getVornameName | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| isAdmin | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| setAdmin | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
| getBenutzergruppen | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
6 | |||
| addBenutzergruppe | |
0.00% |
0 / 5 |
|
0.00% |
0 / 1 |
12 | |||
| removeBenutzergruppe | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
12 | |||
| removeBenutzerBenutzergruppe | |
0.00% |
0 / 7 |
|
0.00% |
0 / 1 |
6 | |||
| addBenutzerBenutzergruppe | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
6 | |||
| addFilter | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
6 | |||
| removeFilter | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
12 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace Satag\AmicronEntityBundle\Entity; |
| 6 | |
| 7 | use Doctrine\Common\Collections\ArrayCollection; |
| 8 | use Doctrine\Common\Collections\Collection; |
| 9 | use Doctrine\DBAL\Types\Types; |
| 10 | use Doctrine\ORM\Mapping as ORM; |
| 11 | use Satag\AmicronEntityBundle\Traits\BlameableEntity; |
| 12 | use Satag\AmicronEntityBundle\Traits\BlameableEntityInterface; |
| 13 | use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity; |
| 14 | use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface; |
| 15 | use Symfony\Component\Security\Core\User\UserInterface; |
| 16 | use Symfony\Component\Validator\Constraints as Assert; |
| 17 | |
| 18 | /** |
| 19 | * @see \Satag\AmicronEntityBundle\Tests\Entity\BenutzerTest |
| 20 | */ |
| 21 | #[ORM\Entity] |
| 22 | #[UniqueEntity('kuerzel')] |
| 23 | #[UniqueEntity(fields: 'email', message: 'E-Mail muss einzigartig sein')] |
| 24 | #[ORM\Table(name: 'BENUTZER')] |
| 25 | #[ORM\Index(columns: ['aktiv'], name: 'BENUTZER_AKTIV_IDX')] |
| 26 | #[ORM\Index(columns: ['kuerzel'], name: 'BENUTZER_KUERZEL_IDX')] |
| 27 | #[ORM\Index(columns: ['mitarbeiterlfdnr'], name: 'BENUTZER_MALFDNR_FK')] |
| 28 | #[ORM\UniqueConstraint(name: 'BENUTZER_UK', columns: ['kuerzel'])] |
| 29 | class Benutzer implements BlameableEntityInterface, UserInterface, PasswordAuthenticatedUserInterface, \Stringable |
| 30 | { |
| 31 | use BlameableEntity; |
| 32 | |
| 33 | final public const float LEERES_PASSWORT = 47_367_469_124_844_348_185_793_760_000_000_000.0; |
| 34 | final public const string PROGRAMM_FAKTURA = '1'; |
| 35 | final public const string PROGRAMM_FAKTURA_MAILOFFICE = '17'; |
| 36 | final public const string PROGRAMM_MAILOFFICE = '16'; |
| 37 | |
| 38 | #[ORM\Column(name: 'abteilung', type: Types::STRING, length: 60, nullable: true)] |
| 39 | private ?string $abteilung = null; |
| 40 | |
| 41 | #[ORM\Column(name: 'isadmin', type: Types::BOOLEAN, length: 1, nullable: true)] |
| 42 | private ?bool $admin = null; |
| 43 | |
| 44 | #[ORM\Column(name: 'aktiv', type: Types::BOOLEAN, length: 1, nullable: true)] |
| 45 | private ?bool $aktiv = null; |
| 46 | |
| 47 | #[ORM\Column(name: 'email', type: Types::STRING, length: 60, nullable: true)] |
| 48 | private ?string $email = null; |
| 49 | |
| 50 | #[ORM\Column(name: 'fax', type: Types::STRING, length: 30, nullable: true)] |
| 51 | private ?string $fax = null; |
| 52 | |
| 53 | /** |
| 54 | * @var string Kürzel |
| 55 | */ |
| 56 | #[ORM\Column(name: 'kuerzel', type: Types::STRING, length: 3, unique: true, nullable: false)] |
| 57 | #[Assert\Length(min: 1, max: 3, minMessage: 'Kürzel muss mindestens ein Zeichen lang sein', maxMessage: 'Kürzel darf maximal 3 Zeichen lang sein')] |
| 58 | #[Assert\Regex(pattern: '/^[A-Za-z0-9ÖÄÜöüäß]+$/', message: 'Das Kürzel darf nur Zahlen und Buchstaben enthalten')] |
| 59 | private string $kuerzel; |
| 60 | |
| 61 | #[ORM\Column(name: 'lfdnr', type: Types::INTEGER, nullable: false)] |
| 62 | #[ORM\Id] |
| 63 | #[ORM\GeneratedValue(strategy: 'SEQUENCE')] |
| 64 | #[ORM\SequenceGenerator(sequenceName: 'GEN_LFDNR', allocationSize: 1, initialValue: 1)] |
| 65 | public private(set) ?int $lfdnr = null; |
| 66 | |
| 67 | #[ORM\Column(name: 'login', type: Types::DATETIME_IMMUTABLE, nullable: true)] |
| 68 | private ?\DateTimeImmutable $login = null; |
| 69 | |
| 70 | #[ORM\Column(name: 'loginversuche', type: Types::INTEGER, nullable: true)] |
| 71 | private ?int $loginversuche = 0; |
| 72 | |
| 73 | #[ORM\Column(name: 'logout', type: Types::DATETIME_IMMUTABLE, nullable: true)] |
| 74 | private ?\DateTimeImmutable $logout = null; |
| 75 | |
| 76 | #[ORM\ManyToOne(targetEntity: Mitarbeiter::class)] |
| 77 | #[ORM\JoinColumn(name: 'mitarbeiterlfdnr', referencedColumnName: 'lfdnr')] |
| 78 | private ?Mitarbeiter $mitarbeiter = null; |
| 79 | |
| 80 | #[ORM\Column(name: 'name', type: Types::STRING, length: 30, nullable: false)] |
| 81 | private string $name; |
| 82 | |
| 83 | #[ORM\Column(name: 'passwort', type: Types::STRING, length: 35, nullable: true)] |
| 84 | private ?string $passwort = null; |
| 85 | |
| 86 | #[ORM\Column(name: 'mobilpinhash', type: Types::STRING, length: 128, nullable: true)] |
| 87 | private ?string $mobilpinhash = null; |
| 88 | |
| 89 | #[ORM\Column(name: 'passworthash', type: Types::STRING, length: 64, nullable: true)] |
| 90 | private ?string $passworthash = null; |
| 91 | |
| 92 | #[ORM\Column(name: 'privat', type: Types::BOOLEAN, length: 1, nullable: true)] |
| 93 | private ?bool $privat = null; |
| 94 | |
| 95 | #[ORM\Column(name: 'programm', type: Types::INTEGER, nullable: true)] |
| 96 | private ?int $programm = null; |
| 97 | |
| 98 | #[ORM\Column(name: 'protokoll', type: Types::BOOLEAN, length: 1, nullable: true)] |
| 99 | private ?bool $protokoll = null; |
| 100 | |
| 101 | #[ORM\Column(name: 'telefon', type: Types::STRING, length: 30, nullable: true)] |
| 102 | private ?string $telefon = null; |
| 103 | |
| 104 | #[ORM\Column(name: 'vorname', type: Types::STRING, length: 30, nullable: true)] |
| 105 | private ?string $vorname = null; |
| 106 | |
| 107 | /** |
| 108 | * @var Collection<int, BenutzerBenutzergruppen> |
| 109 | */ |
| 110 | #[ORM\OneToMany(mappedBy: 'benutzer', targetEntity: BenutzerBenutzergruppen::class, cascade: ['persist'], orphanRemoval: true)] |
| 111 | private Collection $benutzerBenutzergruppen; |
| 112 | |
| 113 | /** |
| 114 | * @var Collection<int, Filter> |
| 115 | */ |
| 116 | #[ORM\OneToMany(mappedBy: 'benutzer', targetEntity: Filter::class, cascade: ['persist'], orphanRemoval: true)] |
| 117 | #[ORM\OrderBy(['bezeichnung' => 'ASC'])] |
| 118 | private Collection $filter; |
| 119 | |
| 120 | public function __construct() |
| 121 | { |
| 122 | $this->benutzerBenutzergruppen = new ArrayCollection(); |
| 123 | $this->filter = new ArrayCollection(); |
| 124 | } |
| 125 | |
| 126 | public function __toString(): string |
| 127 | { |
| 128 | return $this->kuerzel; |
| 129 | } |
| 130 | |
| 131 | /** |
| 132 | * Wegen UserInterface. |
| 133 | * |
| 134 | * @return non-empty-string |
| 135 | */ |
| 136 | public function getUserIdentifier(): string |
| 137 | { |
| 138 | return $this->getKuerzel(); |
| 139 | } |
| 140 | |
| 141 | public function getAbteilung(): ?string |
| 142 | { |
| 143 | return $this->abteilung; |
| 144 | } |
| 145 | |
| 146 | public function setAbteilung(?string $abteilung): self |
| 147 | { |
| 148 | $this->abteilung = $abteilung; |
| 149 | |
| 150 | return $this; |
| 151 | } |
| 152 | |
| 153 | /** |
| 154 | * @return Collection<int, Filter> |
| 155 | */ |
| 156 | public function getFilter(): Collection |
| 157 | { |
| 158 | return $this->filter; |
| 159 | } |
| 160 | |
| 161 | public function isAktiv(): bool |
| 162 | { |
| 163 | return (bool) $this->aktiv; |
| 164 | } |
| 165 | |
| 166 | public function setAktiv(bool $aktiv): self |
| 167 | { |
| 168 | $this->aktiv = $aktiv; |
| 169 | |
| 170 | return $this; |
| 171 | } |
| 172 | |
| 173 | public function getEmail(): ?string |
| 174 | { |
| 175 | return $this->email; |
| 176 | } |
| 177 | |
| 178 | public function setEmail(?string $email): self |
| 179 | { |
| 180 | $this->email = $email; |
| 181 | |
| 182 | return $this; |
| 183 | } |
| 184 | |
| 185 | public function getFax(): ?string |
| 186 | { |
| 187 | return $this->fax; |
| 188 | } |
| 189 | |
| 190 | public function setFax(?string $fax): self |
| 191 | { |
| 192 | $this->fax = $fax; |
| 193 | |
| 194 | return $this; |
| 195 | } |
| 196 | |
| 197 | /** |
| 198 | * @return non-empty-string |
| 199 | */ |
| 200 | public function getKuerzel(): string |
| 201 | { |
| 202 | \assert($this->kuerzel !== '', 'Kürzel must not be empty'); |
| 203 | |
| 204 | return $this->kuerzel; |
| 205 | } |
| 206 | |
| 207 | public function setKuerzel(string $kuerzel): self |
| 208 | { |
| 209 | $this->kuerzel = $kuerzel; |
| 210 | |
| 211 | return $this; |
| 212 | } |
| 213 | |
| 214 | public function getLfdnr(): ?int |
| 215 | { |
| 216 | return $this->lfdnr; |
| 217 | } |
| 218 | |
| 219 | public function getLogin(): ?\DateTimeImmutable |
| 220 | { |
| 221 | return $this->login; |
| 222 | } |
| 223 | |
| 224 | public function setLogin(\DateTimeImmutable|\DateTime|null $login): self |
| 225 | { |
| 226 | $this->login = $login instanceof \DateTime |
| 227 | ? \DateTimeImmutable::createFromMutable($login) |
| 228 | : $login; |
| 229 | |
| 230 | return $this; |
| 231 | } |
| 232 | |
| 233 | public function getLoginversuche(): ?int |
| 234 | { |
| 235 | return $this->loginversuche; |
| 236 | } |
| 237 | |
| 238 | public function setLoginversuche(?int $loginversuche): self |
| 239 | { |
| 240 | $this->loginversuche = $loginversuche; |
| 241 | |
| 242 | return $this; |
| 243 | } |
| 244 | |
| 245 | public function getLogout(): ?\DateTimeImmutable |
| 246 | { |
| 247 | return $this->logout; |
| 248 | } |
| 249 | |
| 250 | public function setLogout(\DateTimeImmutable|\DateTime|null $logout): self |
| 251 | { |
| 252 | $this->logout = $logout instanceof \DateTime |
| 253 | ? \DateTimeImmutable::createFromMutable($logout) |
| 254 | : $logout; |
| 255 | |
| 256 | return $this; |
| 257 | } |
| 258 | |
| 259 | public function getMitarbeiter(): ?Mitarbeiter |
| 260 | { |
| 261 | return $this->mitarbeiter; |
| 262 | } |
| 263 | |
| 264 | public function setMitarbeiter(?Mitarbeiter $mitarbeiter): self |
| 265 | { |
| 266 | $this->mitarbeiter = $mitarbeiter; |
| 267 | |
| 268 | return $this; |
| 269 | } |
| 270 | |
| 271 | public function getName(): string |
| 272 | { |
| 273 | return $this->name; |
| 274 | } |
| 275 | |
| 276 | public function setName(string $name): self |
| 277 | { |
| 278 | $this->name = $name; |
| 279 | |
| 280 | return $this; |
| 281 | } |
| 282 | |
| 283 | public function getPassword(): ?string |
| 284 | { |
| 285 | return $this->getPassworthash(); |
| 286 | } |
| 287 | |
| 288 | public function getPasswort(): ?string |
| 289 | { |
| 290 | return $this->passwort; |
| 291 | } |
| 292 | |
| 293 | public function setPasswort(?string $passwort): self |
| 294 | { |
| 295 | $this->passwort = $passwort; |
| 296 | |
| 297 | return $this; |
| 298 | } |
| 299 | |
| 300 | public function getPassworthash(): ?string |
| 301 | { |
| 302 | return $this->passworthash; |
| 303 | } |
| 304 | |
| 305 | public function setPassworthash(?string $passworthash): ?self |
| 306 | { |
| 307 | $this->passworthash = $passworthash; |
| 308 | |
| 309 | return $this; |
| 310 | } |
| 311 | |
| 312 | public function getMobilpinhash(): ?string |
| 313 | { |
| 314 | return $this->mobilpinhash; |
| 315 | } |
| 316 | |
| 317 | public function setMobilpinhash(?string $mobilpinhash): ?self |
| 318 | { |
| 319 | $this->mobilpinhash = $mobilpinhash; |
| 320 | |
| 321 | return $this; |
| 322 | } |
| 323 | |
| 324 | public function getPrivat(): bool |
| 325 | { |
| 326 | return (bool) $this->privat; |
| 327 | } |
| 328 | |
| 329 | public function isPrivat(bool $privat): self |
| 330 | { |
| 331 | $this->privat = $privat; |
| 332 | |
| 333 | return $this; |
| 334 | } |
| 335 | |
| 336 | public function getProgramm(): ?int |
| 337 | { |
| 338 | return $this->programm; |
| 339 | } |
| 340 | |
| 341 | public function setProgramm(?int $programm): self |
| 342 | { |
| 343 | $this->programm = $programm; |
| 344 | |
| 345 | return $this; |
| 346 | } |
| 347 | |
| 348 | public function isProtokoll(): bool |
| 349 | { |
| 350 | return (bool) $this->protokoll; |
| 351 | } |
| 352 | |
| 353 | public function setProtokoll(bool $protokoll): self |
| 354 | { |
| 355 | $this->protokoll = $protokoll; |
| 356 | |
| 357 | return $this; |
| 358 | } |
| 359 | |
| 360 | /** |
| 361 | * UserInterface. |
| 362 | * |
| 363 | * @return array|string[] |
| 364 | */ |
| 365 | public function getRoles(): array |
| 366 | { |
| 367 | // TODO: Implement getRoles() method. |
| 368 | $roles = []; |
| 369 | if ($this->isAdmin()) { |
| 370 | $roles[] = 'ROLE_ADMIN'; |
| 371 | } |
| 372 | $roles[] = 'ROLE_USER'; |
| 373 | |
| 374 | return array_unique($roles); |
| 375 | } |
| 376 | |
| 377 | public function getSalt(): ?string |
| 378 | { |
| 379 | return null; |
| 380 | } |
| 381 | |
| 382 | /** |
| 383 | * Removes sensitive data from the user. |
| 384 | * |
| 385 | * Required by UserInterface (abstract in Symfony 7.0+). |
| 386 | * This entity does not store any plain-text credentials that need to be erased. |
| 387 | */ |
| 388 | public function eraseCredentials(): void |
| 389 | { |
| 390 | // This entity stores password hashes only, no plain-text credentials to erase |
| 391 | } |
| 392 | |
| 393 | public function getTelefon(): ?string |
| 394 | { |
| 395 | return $this->telefon; |
| 396 | } |
| 397 | |
| 398 | public function setTelefon(?string $telefon): self |
| 399 | { |
| 400 | $this->telefon = $telefon; |
| 401 | |
| 402 | return $this; |
| 403 | } |
| 404 | |
| 405 | /** |
| 406 | * Wegen UserInterface. |
| 407 | */ |
| 408 | public function getUsername(): string |
| 409 | { |
| 410 | return $this->getKuerzel(); |
| 411 | } |
| 412 | |
| 413 | public function getVorname(): ?string |
| 414 | { |
| 415 | return $this->vorname; |
| 416 | } |
| 417 | |
| 418 | public function setVorname(?string $vorname): self |
| 419 | { |
| 420 | $this->vorname = $vorname; |
| 421 | |
| 422 | return $this; |
| 423 | } |
| 424 | |
| 425 | public function getVornameName(): string |
| 426 | { |
| 427 | return trim(\sprintf('%s %s', $this->vorname, $this->name)); |
| 428 | } |
| 429 | |
| 430 | public function isAdmin(): bool |
| 431 | { |
| 432 | return (bool) $this->admin; |
| 433 | } |
| 434 | |
| 435 | public function setAdmin(bool $admin): self |
| 436 | { |
| 437 | $this->admin = $admin; |
| 438 | |
| 439 | return $this; |
| 440 | } |
| 441 | |
| 442 | /** |
| 443 | * @return Collection<int, Benutzergruppe> |
| 444 | */ |
| 445 | public function getBenutzergruppen(): Collection |
| 446 | { |
| 447 | $benutzergruppen = new ArrayCollection(); |
| 448 | foreach ($this->benutzerBenutzergruppen as $benutzerBenutzergruppen) { |
| 449 | $benutzergruppen->add($benutzerBenutzergruppen->getBenutzergruppe()); |
| 450 | } |
| 451 | |
| 452 | return $benutzergruppen; |
| 453 | } |
| 454 | |
| 455 | public function addBenutzergruppe(Benutzergruppe $benutzergruppe): void |
| 456 | { |
| 457 | foreach ($this->benutzerBenutzergruppen as $benutzerBenutzergruppen) { |
| 458 | if ($benutzerBenutzergruppen->getBenutzergruppe() === $benutzergruppe) { |
| 459 | return; |
| 460 | } |
| 461 | } |
| 462 | |
| 463 | $benutzerBenutzergruppen = new BenutzerBenutzergruppen($this, $benutzergruppe); |
| 464 | $this->addBenutzerBenutzergruppe($benutzerBenutzergruppen); |
| 465 | } |
| 466 | |
| 467 | public function removeBenutzergruppe(Benutzergruppe $benutzergruppe): void |
| 468 | { |
| 469 | foreach ($this->benutzerBenutzergruppen as $benutzerBenutzergruppe) { |
| 470 | if ($benutzerBenutzergruppe->getBenutzergruppe() === $benutzergruppe) { |
| 471 | $this->removeBenutzerBenutzergruppe($benutzerBenutzergruppe); |
| 472 | |
| 473 | return; |
| 474 | } |
| 475 | } |
| 476 | } |
| 477 | |
| 478 | public function removeBenutzerBenutzergruppe(BenutzerBenutzergruppen $benutzerBenutzergruppe): void |
| 479 | { |
| 480 | if (!$this->benutzerBenutzergruppen->contains($benutzerBenutzergruppe)) { |
| 481 | return; |
| 482 | } |
| 483 | |
| 484 | $this->benutzerBenutzergruppen->removeElement($benutzerBenutzergruppe); |
| 485 | |
| 486 | // update the owning side(s) |
| 487 | $benutzerBenutzergruppe->getBenutzergruppe()?->removeBenutzerBenutzergruppe( |
| 488 | $benutzerBenutzergruppe |
| 489 | ); |
| 490 | $benutzerBenutzergruppe->setBenutzer(null); |
| 491 | } |
| 492 | |
| 493 | public function addBenutzerBenutzergruppe(BenutzerBenutzergruppen $benutzerBenutzergruppen): void |
| 494 | { |
| 495 | if ($this->benutzerBenutzergruppen->contains($benutzerBenutzergruppen)) { |
| 496 | return; |
| 497 | } |
| 498 | |
| 499 | $this->benutzerBenutzergruppen->add($benutzerBenutzergruppen); |
| 500 | $benutzerBenutzergruppen->getBenutzergruppe()?->addBenutzerBenutzergruppe($benutzerBenutzergruppen); |
| 501 | } |
| 502 | |
| 503 | public function addFilter(Filter $filter): void |
| 504 | { |
| 505 | if (!$this->filter->contains($filter)) { |
| 506 | $filter->setBenutzer($this); |
| 507 | $this->filter->add($filter); |
| 508 | } |
| 509 | } |
| 510 | |
| 511 | public function removeFilter(Filter $filter): void |
| 512 | { |
| 513 | if ($this->filter->contains($filter)) { |
| 514 | $this->filter->removeElement($filter); |
| 515 | if ($filter->getBenutzer() === $this) { |
| 516 | $filter->setBenutzer(null); |
| 517 | } |
| 518 | } |
| 519 | } |
| 520 | } |