src/Entity/Item.php line 92
<?phpdeclare(strict_types=1);namespace App\Entity;use ApiPlatform\Core\Annotation\ApiResource;use ApiPlatform\Core\Annotation\ApiSubresource;use App\Controller\Api\Action\Item\ItemDeleteAction;use App\Controller\Api\Action\Item\ItemDuplicateAction;use App\Controller\Api\Action\Item\ItemToChildAction;use App\Controller\Api\Action\Item\ItemToParentAction;use App\Controller\Api\Action\Item\ItemChildrenBudgetAction;use App\Repository\ItemRepository;use App\Validator\Constraint as CustomValidator;use DateTime;use Doctrine\Common\Collections\ArrayCollection;use Doctrine\ORM\Mapping as ORM;use Symfony\Component\Validator\Constraints as Assert;#[ORM\Entity(repositoryClass: ItemRepository::class)]#[ORM\Table(name: 'item')]#[ApiResource(collectionOperations: ['post' => ['validation_groups' => ['create']]],itemOperations: ['get','put' => ['validation_groups' => ['create']],'delete' => ['access_control' => 'is_granted("ROLE_USER")','controller' => ItemDeleteAction::class],'duplicate' => ['access_control' => 'is_granted("ROLE_USER")','controller' => ItemDuplicateAction::class,'method' => 'POST','path' => '/items/duplicate/{id}'],'to_child' => ['access_control' => 'is_granted("ROLE_USER")','controller' => ItemToChildAction::class,'method' => 'POST','path' => '/items/to-child/{id}'],'to_parent' => ['access_control' => 'is_granted("ROLE_USER")','controller' => ItemToParentAction::class,'method' => 'PUT','path' => '/items/to-parent/{id}'],'children_budget' => ['access_control' => 'is_granted("ROLE_USER")','controller' => ItemChildrenBudgetAction::class,'method' => 'GET','path' => '/items/budget/{id}']])]#[CustomValidator\ItemPlannedStartDate(message: 'item.plannedStartDate',fields: ['plannedStartDate'],groups: ['create'])]#[CustomValidator\ItemPlannedEndDate(message: 'item.plannedEndDate',fields: ['plannedEndDate'],groups: ['create'])]#[CustomValidator\ItemRealizedStartDate(message: 'item.realizedStartDate',fields: ['realizedStartDate'],groups: ['create'])]#[CustomValidator\ItemRealizedEndDate(message: 'item.realizedEndDate',fields: ['realizedEndDate'],groups: ['create'])]class Item implements CollectionItemInterface{#[ORM\Id]#[ORM\GeneratedValue]#[ORM\Column(type: 'integer')]private ?int $id = null;#[ORM\Column(name: 'date_created',type: 'datetime',nullable: true)]private ?DateTime $dateCreated = null;#[ORM\Column(name: 'date_changed',type: 'datetime',nullable: true)]private ?DateTime $dateChanged = null;#[ORM\ManyToOne(targetEntity: User::class,cascade: ['persist'])]#[ORM\JoinColumn(name: 'user_created')]private ?User $userCreated = null;#[ORM\ManyToOne(targetEntity: User::class,cascade: ['persist'])]#[ORM\JoinColumn(name: 'user_changed')]private ?User $userChanged = null;#[ORM\Column(name: 'active',type: 'boolean',options: ['default' => true])]private bool $active = true;#[ORM\Column(name: 'visible_in_the_calendar',type: 'boolean',options: ['default' => true])]private bool $visibleInTheCalendar = true;#[ORM\Column(name: 'name',type: 'string',length: 181,nullable: true)]#[Assert\NotBlank(groups: ['create'])]private ?string $name = null;#[ORM\Column(name: 'sequence',type: 'integer',nullable: true)]private ?int $sequence = null;#[ORM\Column(name: 'description',type: 'text',nullable: true)]private ?string $description = null;#[ORM\Column(name: 'planned_start_date',type: 'datetime',nullable: true)]#[Assert\NotBlank(groups: ['create'])]private ?DateTime $plannedStartDate = null;#[ORM\Column(name: 'planned_end_date',type: 'datetime',nullable: true)]#[Assert\NotBlank(groups: ['create'])]#[Assert\GreaterThanOrEqual(propertyPath: 'plannedStartDate',message: 'item.plannedEndDateLessThanStartDate',groups: ['create'])]private ?DateTime $plannedEndDate = null;#[ORM\Column(name: 'realized_start_date',type: 'datetime',nullable: true)]private ?DateTime $realizedStartDate = null;#[ORM\Column(name: 'realized_end_date',type: 'datetime',nullable: true)]#[Assert\GreaterThanOrEqual(propertyPath: 'realizedStartDate',message: 'item.realizedEndDateLessThanStartDate',groups: ['create'])]private ?DateTime $realizedEndDate = null;#[ORM\Column(name: 'budget',type: 'decimal',precision: 20,scale: 2,nullable: true)]#[Assert\NotBlank(groups: ['create'])]#[CustomValidator\PriceFormat(groups: ['create'],message: 'item.invalidFormat')]private ?string $budget = null;#[ORM\Column(name: 'external_budget',type: 'decimal',precision: 20,scale: 2,nullable: true)]#[Assert\NotBlank(groups: ['create'])]#[CustomValidator\PriceFormat(groups: ['create'],message: 'item.invalidFormat')]private ?string $externalBudget = null;#[ORM\ManyToOne(targetEntity: Project::class,cascade: ['persist'],inversedBy: 'items')]#[ORM\JoinColumn(name: 'project',nullable: true,onDelete: 'CASCADE')]#[ApiSubresource]private ?Project $project = null;#[ORM\ManyToOne(targetEntity: Item::class,cascade: ['persist'],inversedBy: 'children')]#[ORM\JoinColumn(name: 'parent',nullable: true,onDelete: 'CASCADE')]#[ApiSubresource]private ?Item $parent = null;#[ORM\OneToMany(mappedBy: 'item',targetEntity: ItemUser::class,cascade: ['persist', 'remove'],fetch: 'EXTRA_LAZY',orphanRemoval: true)]private ?iterable $users;#[ORM\OneToMany(mappedBy: 'item',targetEntity: ItemDocument::class,cascade: ['persist', 'remove'],fetch: 'EXTRA_LAZY',orphanRemoval: true)]private ?iterable $document;#[ORM\OneToMany(mappedBy: 'item',targetEntity: ItemLabel::class,cascade: ['persist', 'remove'],fetch: 'EXTRA_LAZY',orphanRemoval: true)]private ?iterable $label;#[ORM\OneToMany(mappedBy: 'item',targetEntity: ItemIndicator::class,cascade: ['persist'],fetch: 'EXTRA_LAZY',orphanRemoval: true)]private ?iterable $indicators;#[ORM\OneToMany(mappedBy: 'parent',targetEntity: Item::class,cascade: ['persist', 'remove'],fetch: 'EXTRA_LAZY',orphanRemoval: true)]private ?iterable $children;public function __construct(){$this->users = new ArrayCollection();$this->document = new ArrayCollection();$this->label = new ArrayCollection();$this->indicators = new ArrayCollection();$this->children = new ArrayCollection();}public function getId(): ?int{return $this->id;}public function setId($id): self{$this->id = $id;return $this;}public function getDateCreated(): ?DateTime{return $this->dateCreated;}public function setDateCreated(?DateTime $dateCreated): self{$this->dateCreated = $dateCreated;return $this;}public function getDateChanged(): ?DateTime{return $this->dateChanged;}public function setDateChanged(?DateTime $dateChanged): self{$this->dateChanged = $dateChanged;return $this;}public function getUserCreated(): ?User{return $this->userCreated;}public function setUserCreated(?User $userCreated): self{$this->userCreated = $userCreated;return $this;}public function getUserChanged(): ?User{return $this->userChanged;}public function setUserChanged(?User $userChanged): self{$this->userChanged = $userChanged;return $this;}public function isActive(): bool{return $this->active;}public function setActive(bool $active): void{$this->active = $active;}public function isVisibleInTheCalendar(): bool{return $this->visibleInTheCalendar;}public function setVisibleInTheCalendar(bool $visibleInTheCalendar): void{$this->visibleInTheCalendar = $visibleInTheCalendar;}public function getName(): ?string{return $this->name;}public function setName(?string $name): self{$this->name = $name;return $this;}public function getSequence(): ?int{return $this->sequence;}public function setSequence(?int $sequence): self{$this->sequence = $sequence;return $this;}public function getDescription(): ?string{return $this->description;}public function setDescription(?string $description): self{$this->description = $description;return $this;}public function getPlannedStartDate(): ?DateTime{return $this->plannedStartDate;}public function setPlannedStartDate(?DateTime $plannedStartDate): self{$this->plannedStartDate = $plannedStartDate;return $this;}public function getPlannedEndDate(): ?DateTime{return $this->plannedEndDate;}public function setPlannedEndDate(?DateTime $plannedEndDate): self{$this->plannedEndDate = $plannedEndDate;return $this;}public function getRealizedStartDate(): ?DateTime{return $this->realizedStartDate;}public function setRealizedStartDate(?DateTime $realizedStartDate): self{$this->realizedStartDate = $realizedStartDate;return $this;}public function getRealizedEndDate(): ?DateTime{return $this->realizedEndDate;}public function setRealizedEndDate(?DateTime $realizedEndDate): self{$this->realizedEndDate = $realizedEndDate;return $this;}public function getBudget(): ?string{if ($this->budget&&str_contains($this->budget, ',')) {return $this->budget;}return $this->budget ? number_format((float) $this->budget, 2, ',', '.') : null;}public function getRealBudget(): ?string{return $this->budget;}public function setBudget(?string $budget): self{$this->budget = $budget;return $this;}public function getExternalBudget(): ?string{if ($this->externalBudget&&str_contains($this->externalBudget, ',')) {return $this->externalBudget;}return $this->externalBudget ? number_format((float) $this->externalBudget, 2, ',', '.') : null;}public function getRealExternalBudget(): ?string{return $this->externalBudget;}public function setExternalBudget(?string $externalBudget): self{$this->externalBudget = $externalBudget;return $this;}public function getProject(): ?Project{return $this->project;}public function setProject(?Project $project): self{$this->project = $project;return $this;}public function getParent(): ?Item{return $this->parent;}public function setParent(?Item $parent): self{$this->parent = $parent;return $this;}public function getChildren(): ?iterable{return $this->children;}public function getUsers(): iterable{return $this->users;}public function addUser(ItemUser $itemUser): void{if ($this->users->contains($itemUser)) {return;}$this->users[] = $itemUser;$itemUser->setItem($this);}public function cloneUser(ItemUser $itemUser): void{if ($this->users->contains($itemUser)) {return;}$clonedUser = clone $itemUser;$this->users[] = $clonedUser;$clonedUser->setItem($this);}public function removeUser(ItemUser $itemUser): void{if (!$this->users->contains($itemUser)) {return;}$this->users->removeElement($itemUser);$itemUser->setItem(null);}public function getDocument(): iterable{return $this->document;}public function addDocument(ItemDocument $itemDocument): void{if ($this->document->contains($itemDocument)) {return;}$this->document[] = $itemDocument;$itemDocument->setItem($this);}public function cloneDocument(ItemDocument $itemDocument): void{if ($this->document->contains($itemDocument)) {return;}$clonedDocument = clone $itemDocument;$this->document[] = $clonedDocument;$clonedDocument->setItem($this);}public function removeDocument(ItemDocument $itemDocument): void{if (!$this->document->contains($itemDocument)) {return;}$this->document->removeElement($itemDocument);$itemDocument->setItem(null);}public function getLabel(): iterable{return $this->label;}public function addLabel(ItemLabel $itemLabel): void{if ($this->label->contains($itemLabel)) {return;}$this->label[] = $itemLabel;$itemLabel->setItem($this);}public function cloneLabel(ItemLabel $itemLabel): void{if ($this->label->contains($itemLabel)) {return;}$clonedLabel = clone $itemLabel;$this->label[] = $clonedLabel;$clonedLabel->setItem($this);}public function removeLabel(ItemLabel $itemLabel): void{if (!$this->label->contains($itemLabel)) {return;}$this->label->removeElement($itemLabel);$itemLabel->setItem(null);}public function getIndicators(): iterable{return $this->indicators;}public function addIndicator(ItemIndicator $itemIndicator): void{if ($this->indicators->contains($itemIndicator)) {return;}$this->indicators[] = $itemIndicator;$itemIndicator->setItem($this);}public function cloneIndicator(ItemIndicator $itemIndicator): void{if ($this->indicators->contains($itemIndicator)) {return;}$clonedIndicator = clone $itemIndicator;$this->indicators[] = $clonedIndicator;$clonedIndicator->setItem($this);}public function removeIndicator(ItemIndicator $itemIndicator): void{if (!$this->indicators->contains($itemIndicator)) {return;}$this->indicators->removeElement($itemIndicator);$itemIndicator->setItem(null);}}