-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathAuthorization.php
116 lines (89 loc) · 2.97 KB
/
Authorization.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
<?php
// This file is part of Bileto.
// Copyright 2022-2025 Probesys
// SPDX-License-Identifier: AGPL-3.0-or-later
namespace App\Entity;
use App\ActivityMonitor\MonitorableEntityInterface;
use App\ActivityMonitor\MonitorableEntityTrait;
use App\Repository\AuthorizationRepository;
use App\Uid\UidEntityInterface;
use App\Uid\UidEntityTrait;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: AuthorizationRepository::class)]
#[ORM\Table(name: '`authorizations`')]
class Authorization implements EntityInterface, MonitorableEntityInterface, UidEntityInterface
{
use MonitorableEntityTrait;
use UidEntityTrait;
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\Column(length: 20, unique: true)]
private ?string $uid = null;
#[ORM\Column(type: Types::DATETIMETZ_IMMUTABLE)]
private ?\DateTimeImmutable $createdAt = null;
#[ORM\ManyToOne]
private ?User $createdBy = null;
#[ORM\Column(type: Types::DATETIMETZ_IMMUTABLE)]
private ?\DateTimeImmutable $updatedAt = null;
#[ORM\ManyToOne]
private ?User $updatedBy = null;
#[ORM\ManyToOne(inversedBy: 'authorizations')]
#[ORM\JoinColumn(nullable: false)]
private ?Role $role = null;
#[ORM\ManyToOne(inversedBy: 'authorizations')]
#[ORM\JoinColumn(nullable: false)]
private ?User $holder = null;
#[ORM\ManyToOne(inversedBy: 'authorizations')]
#[ORM\JoinColumn(onDelete: 'CASCADE')]
private ?Organization $organization = null;
#[ORM\ManyToOne(inversedBy: 'authorizations')]
#[ORM\JoinColumn(onDelete: 'CASCADE')]
private ?TeamAuthorization $teamAuthorization = null;
public static function fromTeamAuthorization(TeamAuthorization $teamAuthorization): self
{
$authorization = new Authorization();
$authorization->setRole($teamAuthorization->getRole());
$authorization->setOrganization($teamAuthorization->getOrganization());
$authorization->setTeamAuthorization($teamAuthorization);
return $authorization;
}
public function getRole(): ?Role
{
return $this->role;
}
public function setRole(?Role $role): self
{
$this->role = $role;
return $this;
}
public function getHolder(): ?User
{
return $this->holder;
}
public function setHolder(?User $holder): self
{
$this->holder = $holder;
return $this;
}
public function getOrganization(): ?Organization
{
return $this->organization;
}
public function setOrganization(?Organization $organization): self
{
$this->organization = $organization;
return $this;
}
public function getTeamAuthorization(): ?TeamAuthorization
{
return $this->teamAuthorization;
}
public function setTeamAuthorization(?TeamAuthorization $teamAuthorization): static
{
$this->teamAuthorization = $teamAuthorization;
return $this;
}
}