ControleOnline /
api-platform-contract
| 1 | <?php |
||
| 2 | |||
| 3 | namespace ControleOnline\Entity; |
||
| 4 | |||
| 5 | use Symfony\Component\Serializer\Attribute\Groups; |
||
|
0 ignored issues
–
show
|
|||
| 6 | |||
| 7 | use ApiPlatform\Metadata\ApiResource; |
||
|
0 ignored issues
–
show
The type
ApiPlatform\Metadata\ApiResource was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths Loading history...
|
|||
| 8 | use ApiPlatform\Metadata\ApiFilter; |
||
|
0 ignored issues
–
show
The type
ApiPlatform\Metadata\ApiFilter was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths Loading history...
|
|||
| 9 | use ApiPlatform\Metadata\Get; |
||
|
0 ignored issues
–
show
The type
ApiPlatform\Metadata\Get was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths Loading history...
|
|||
| 10 | use ApiPlatform\Metadata\GetCollection; |
||
|
0 ignored issues
–
show
The type
ApiPlatform\Metadata\GetCollection was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths Loading history...
|
|||
| 11 | use ApiPlatform\Metadata\Post; |
||
|
0 ignored issues
–
show
The type
ApiPlatform\Metadata\Post was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths Loading history...
|
|||
| 12 | use ApiPlatform\Metadata\Put; |
||
|
0 ignored issues
–
show
The type
ApiPlatform\Metadata\Put was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths Loading history...
|
|||
| 13 | use ApiPlatform\Doctrine\Orm\Filter\SearchFilter; |
||
|
0 ignored issues
–
show
The type
ApiPlatform\Doctrine\Orm\Filter\SearchFilter was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths Loading history...
|
|||
| 14 | use Doctrine\ORM\Mapping as ORM; |
||
|
0 ignored issues
–
show
The type
Doctrine\ORM\Mapping was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths Loading history...
|
|||
| 15 | use Doctrine\Common\Collections\ArrayCollection; |
||
|
0 ignored issues
–
show
The type
Doctrine\Common\Collections\ArrayCollection was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths Loading history...
|
|||
| 16 | use Doctrine\Common\Collections\Collection; |
||
|
0 ignored issues
–
show
The type
Doctrine\Common\Collections\Collection was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths Loading history...
|
|||
| 17 | use ControleOnline\Entity\Model; |
||
|
0 ignored issues
–
show
The type
ControleOnline\Entity\Model was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths Loading history...
|
|||
| 18 | use ControleOnline\Entity\Status; |
||
|
0 ignored issues
–
show
The type
ControleOnline\Entity\Status was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths Loading history...
|
|||
| 19 | use ControleOnline\Entity\File; |
||
|
0 ignored issues
–
show
The type
ControleOnline\Entity\File was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths Loading history...
|
|||
| 20 | use ControleOnline\Entity\People; |
||
|
0 ignored issues
–
show
The type
ControleOnline\Entity\People was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths Loading history...
|
|||
| 21 | use ControleOnline\Entity\ContractPeople; |
||
| 22 | use ControleOnline\Repository\ContractRepository; |
||
| 23 | use ControleOnline\Listener\LogListener; |
||
|
0 ignored issues
–
show
The type
ControleOnline\Listener\LogListener was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths Loading history...
|
|||
| 24 | use ControleOnline\Controller\GenerateContractController; |
||
| 25 | use ControleOnline\Controller\SignContractController; |
||
| 26 | use DateTime; |
||
| 27 | |||
| 28 | #[ORM\EntityListeners([LogListener::class])] |
||
| 29 | #[ORM\Entity(repositoryClass: ContractRepository::class)] |
||
| 30 | #[ApiResource( |
||
| 31 | formats: ['jsonld', 'json', 'html', 'jsonhal', 'csv' => ['text/csv']], |
||
| 32 | normalizationContext: ['groups' => ['contract:read']], |
||
| 33 | denormalizationContext: ['groups' => ['contract:write']], |
||
| 34 | operations: [ |
||
| 35 | new GetCollection(security: "is_granted('ROLE_CLIENT')"), |
||
| 36 | new Get(security: "is_granted('ROLE_CLIENT')"), |
||
| 37 | new Post( |
||
| 38 | security: "is_granted('ROLE_ADMIN') or is_granted('ROLE_CLIENT')" |
||
| 39 | ), |
||
| 40 | new Put(security: "is_granted('ROLE_CLIENT')"), |
||
| 41 | new Post( |
||
| 42 | security: "is_granted('ROLE_ADMIN') or is_granted('ROLE_CLIENT')", |
||
| 43 | uriTemplate: '/contracts/{id}/generate', |
||
| 44 | controller: GenerateContractController::class |
||
| 45 | ), |
||
| 46 | new Post( |
||
| 47 | security: "is_granted('ROLE_ADMIN') or is_granted('ROLE_CLIENT')", |
||
| 48 | uriTemplate: '/contracts/{id}/sign', |
||
| 49 | controller: SignContractController::class |
||
| 50 | ) |
||
| 51 | ] |
||
| 52 | )] |
||
| 53 | #[ApiFilter(SearchFilter::class, properties: [ |
||
| 54 | 'contractModel' => 'exact', |
||
| 55 | 'status' => 'exact', |
||
| 56 | 'beneficiary' => 'exact', |
||
| 57 | 'peoples.people.name' => 'partial' |
||
| 58 | ])] |
||
| 59 | class Contract |
||
| 60 | { |
||
| 61 | #[ORM\Column(type: 'integer', nullable: false)] |
||
| 62 | #[ORM\Id] |
||
| 63 | #[ORM\GeneratedValue(strategy: 'IDENTITY')] |
||
| 64 | #[Groups(['contract:read'])] |
||
| 65 | private $id; |
||
| 66 | |||
| 67 | #[ORM\ManyToOne(targetEntity: Model::class)] |
||
| 68 | #[ORM\JoinColumn(referencedColumnName: 'id', nullable: false)] |
||
| 69 | #[Groups(['contract:read', 'contract:write'])] |
||
| 70 | private $contractModel; |
||
| 71 | |||
| 72 | #[ORM\ManyToOne(targetEntity: Status::class)] |
||
| 73 | #[ORM\JoinColumn(name: 'status_id', referencedColumnName: 'id')] |
||
| 74 | #[Groups(['contract:read', 'contract:write'])] |
||
| 75 | private $status; |
||
| 76 | |||
| 77 | #[ORM\Column(name: 'doc_key', type: 'string')] |
||
| 78 | #[Groups(['contract:read', 'contract:write'])] |
||
| 79 | private $docKey; |
||
| 80 | |||
| 81 | #[ORM\Column(name: 'start_date', type: 'datetime', nullable: false)] |
||
| 82 | #[Groups(['contract:read', 'contract:write'])] |
||
| 83 | private $startDate; |
||
| 84 | |||
| 85 | #[ORM\Column(name: 'end_date', type: 'datetime', nullable: true)] |
||
| 86 | #[Groups(['contract:read', 'contract:write'])] |
||
| 87 | private $endDate; |
||
| 88 | |||
| 89 | #[ORM\Column(name: 'creation_date', type: 'datetime', nullable: false)] |
||
| 90 | #[Groups(['contract:read', 'contract:write'])] |
||
| 91 | private $creationDate; |
||
| 92 | |||
| 93 | #[ORM\Column(name: 'alter_date', type: 'datetime', nullable: false)] |
||
| 94 | #[Groups(['contract:read', 'contract:write'])] |
||
| 95 | private $alterDate; |
||
| 96 | |||
| 97 | #[ORM\ManyToOne(targetEntity: File::class)] |
||
| 98 | #[ORM\JoinColumn(referencedColumnName: 'id', nullable: true)] |
||
| 99 | #[Groups(['contract:read', 'contract:write'])] |
||
| 100 | private $contractFile; |
||
| 101 | |||
| 102 | #[ORM\ManyToOne(targetEntity: People::class)] |
||
| 103 | #[ORM\JoinColumn(name: 'beneficiary_id', referencedColumnName: 'id')] |
||
| 104 | #[Groups(['contract:read', 'contract:write'])] |
||
| 105 | private $beneficiary; |
||
| 106 | |||
| 107 | #[ORM\OneToMany(targetEntity: ContractPeople::class, mappedBy: 'contract')] |
||
| 108 | #[Groups(['contract:read', 'contract:write'])] |
||
| 109 | private $peoples; |
||
| 110 | |||
| 111 | public function __construct() |
||
| 112 | { |
||
| 113 | $this->startDate = new DateTime('now'); |
||
| 114 | $this->endDate = new DateTime('now'); |
||
| 115 | $this->creationDate = new DateTime('now'); |
||
| 116 | $this->alterDate = new DateTime('now'); |
||
| 117 | $this->peoples = new ArrayCollection(); |
||
| 118 | } |
||
| 119 | |||
| 120 | public function getId() |
||
| 121 | { |
||
| 122 | return $this->id; |
||
| 123 | } |
||
| 124 | |||
| 125 | public function setStatus(Status $status = null) |
||
| 126 | { |
||
| 127 | $this->status = $status; |
||
| 128 | return $this; |
||
| 129 | } |
||
| 130 | |||
| 131 | public function getStatus() |
||
| 132 | { |
||
| 133 | return $this->status; |
||
| 134 | } |
||
| 135 | |||
| 136 | public function getStartDate(): DateTime |
||
| 137 | { |
||
| 138 | return $this->startDate; |
||
| 139 | } |
||
| 140 | |||
| 141 | public function setStartDate(DateTime $start_date): self |
||
| 142 | { |
||
| 143 | $this->startDate = $start_date; |
||
| 144 | return $this; |
||
| 145 | } |
||
| 146 | |||
| 147 | public function getEndDate(): ?DateTime |
||
| 148 | { |
||
| 149 | return $this->endDate; |
||
| 150 | } |
||
| 151 | |||
| 152 | public function setEndDate(?DateTime $end_date): self |
||
| 153 | { |
||
| 154 | $this->endDate = $end_date; |
||
| 155 | return $this; |
||
| 156 | } |
||
| 157 | |||
| 158 | public function getCreationDate(): DateTime |
||
| 159 | { |
||
| 160 | return $this->creationDate; |
||
| 161 | } |
||
| 162 | |||
| 163 | public function setCreationDate(DateTime $creation_date): self |
||
| 164 | { |
||
| 165 | $this->creationDate = $creation_date; |
||
| 166 | return $this; |
||
| 167 | } |
||
| 168 | |||
| 169 | public function getAlterDate(): DateTime |
||
| 170 | { |
||
| 171 | return $this->alterDate; |
||
| 172 | } |
||
| 173 | |||
| 174 | public function setAlterDate(DateTime $alter_date): self |
||
| 175 | { |
||
| 176 | $this->alterDate = $alter_date; |
||
| 177 | return $this; |
||
| 178 | } |
||
| 179 | |||
| 180 | public function getContractFile() |
||
| 181 | { |
||
| 182 | return $this->contractFile; |
||
| 183 | } |
||
| 184 | |||
| 185 | public function setContractFile($contractFile): self |
||
| 186 | { |
||
| 187 | $this->contractFile = $contractFile; |
||
| 188 | return $this; |
||
| 189 | } |
||
| 190 | |||
| 191 | public function getBeneficiary() |
||
| 192 | { |
||
| 193 | return $this->beneficiary; |
||
| 194 | } |
||
| 195 | |||
| 196 | public function setBeneficiary($beneficiary): self |
||
| 197 | { |
||
| 198 | $this->beneficiary = $beneficiary; |
||
| 199 | return $this; |
||
| 200 | } |
||
| 201 | |||
| 202 | public function getContractModel() |
||
| 203 | { |
||
| 204 | return $this->contractModel; |
||
| 205 | } |
||
| 206 | |||
| 207 | public function setContractModel($contractModel): self |
||
| 208 | { |
||
| 209 | $this->contractModel = $contractModel; |
||
| 210 | return $this; |
||
| 211 | } |
||
| 212 | |||
| 213 | public function addPeoples(ContractPeople $peoples) |
||
| 214 | { |
||
| 215 | $this->peoples[] = $peoples; |
||
| 216 | return $this; |
||
| 217 | } |
||
| 218 | |||
| 219 | public function removePeoples(ContractPeople $peoples) |
||
| 220 | { |
||
| 221 | $this->peoples->removeElement($peoples); |
||
| 222 | } |
||
| 223 | |||
| 224 | public function getPeoples() |
||
| 225 | { |
||
| 226 | return $this->peoples; |
||
| 227 | } |
||
| 228 | |||
| 229 | public function getDocKey() |
||
| 230 | { |
||
| 231 | return $this->docKey; |
||
| 232 | } |
||
| 233 | |||
| 234 | public function setDocKey($docKey): self |
||
| 235 | { |
||
| 236 | $this->docKey = $docKey; |
||
| 237 | return $this; |
||
| 238 | } |
||
| 239 | } |
||
| 240 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths