<?php
namespace App\V4\Model\Task;
use ApiPlatform\Core\Annotation\ApiFilter;
use ApiPlatform\Core\Annotation\ApiProperty;
use ApiPlatform\Core\Annotation\ApiResource;
use App\Model\CustomerFile\CustomerFile;
use App\Model\IriNormalizableInterface;
use App\Model\NormalizeAsIRITrait;
use App\Model\SpecificFieldsAwareInterface;
use App\Model\TaskMailingStats\TaskMailingStats;
use App\Model\Traits\BlamableTrait;
use App\Model\Traits\ImportableObjectTrait;
use App\Model\Traits\TimestampableTrait;
use App\V4\Entity\ActionableEntityInterface;
use App\V4\Model\Contact\Contact;
use App\V4\Model\Prospect\Prospect;
use App\V4\Model\SpecificField\SpecificField;
use App\V4\Model\TaskQuoteExternalRef\TaskQuoteExternalRef;
use App\V4\Model\TaskSpecificField\TaskSpecificField;
use App\V4\Model\TaskType\TaskType;
use DateTime;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Symfony\Component\Serializer\Annotation\Groups;
use Symfony\Component\Validator\Constraints as Assert;
/**
* @ApiResource(
* shortName="V4/Task",
* attributes={
* "api_allow_update": true
* },
* collectionOperations={
* "get": {
* "normalization_context": {
* "groups": {"task:list"}
* },
* "security": "is_granted(constant('App\\V4\\Voters\\TaskVoter::TASK_SHOW_LIST'), 'App\V4\Voters\TaskVoter')"
* },
* "post_task": {
* "method": "POST",
* "deserialize": false,
* "write": false,
* "controller": "App\V4\Controller\Task\TaskDataPersisterAction",
* "path": "/V4/tasks",
* "input_formats": {
* "multipart": {"multipart/form-data"}
* },
* "normalization_context": {
* "groups": {"task:read"}
* },
* "denormalization_context": {
* "groups": {}
* }
* },
* "get_form": {
* "method": "GET",
* "path": "/V4/tasks/form",
* "controller": App\V4\Controller\Task\GetTaskFormAction::class
* },
* "get_search": {
* "method": "GET",
* "path": "/V4/tasks/search/form",
* "controller": App\V4\Controller\Task\GetTaskSearchFormAction::class,
* },
* "post_search": {
* "method": "POST",
* "deserialize": false,
* "path": "/V4/tasks/search/form",
* "normalization_context": {
* "groups": {"task:list"}
* },
* "controller": App\V4\Controller\Task\PostTaskSearchFormAction::class,
* },
* "post_export_request": {
* "method": "POST",
* "path": "/v4/export/task",
* "controller": App\V4\Action\Export\EntityExportRequestAction::class,
* "swagger_context": {
* "summary": "Demande de création d'export des actions",
* "description": "Demande de création d'export des actions où 'ids' sont les ids des actions et 'fields' les champs souhaités",
* "parameters": {
* {
* "in": "body",
* "name": "body",
* "schema": {
* "type": "object",
* "properties": {
* "ids": {
* "type": "array",
* "items": {"type": "string"}
* },
* "fields": {
* "type": "array",
* "items": {"type": "string"}
* }
* }
* }
* }
* },
* "responses": {
* "201": {
* "description": "Création de l'export avec succès",
* "schema": {
* "type": "object",
* "properties": {
* "message": {"type": "string", "example": "export_request_created"},
* }
* }
* },
* "400": {
* "description": "Utilisateur non trouvé ou champs 'fields' ou 'ids' manquant dans le body request",
* "schema": {
* "type": "object",
* "properties": {
* "message": {"type": "string", "example": "user_not_found or missing_fields_or_ids"},
* }
* }
* },
* "422": {
* "description": "Les champs 'fields' ou 'ids' du body request sont vides ou l'entité demandée est invalide",
* "schema": {
* "type": "object",
* "properties": {
* "message": {"type": "string", "example": "empty_fields_or_ids or entity_not_valid"},
* }
* }
* },
* },
* }
* },
* "post_export_download": {
* "method": "POST",
* "path": "/v4/export/download/task/{id}",
* "controller": App\V4\Action\Export\EntityExportDownloadAction::class,
* "swagger_context": {
* "summary": "Demande de téléchargement d'un export actions",
* "description": "Demande de téléchargement d'un export actions ou 'id' est le nom du fichier d'export",
* "requestBody": {},
* "parameters": {
* {
* "in": "path",
* "name": "id",
* "type": "string",
* "required": "true"
* }
* },
* "responses": {
* "200": {
* "description": "Téléchargement de l'export réalisé avec succès"
* },
* "401": {
* "description": "Utilisateur non trouvé ou non connecté",
* "schema": {
* "type": "object",
* "properties": {
* "message": {"type": "string", "example": "need_authenticated"},
* }
* }
* },
* "404": {
* "description": "Fichier introuvable",
* "schema": {
* "type": "object",
* "properties": {
* "message": {"type": "string", "example": "export_not_found"},
* }
* }
* },
* },
* }
* }
* },
* itemOperations={
* "get": {
* "path": "/V4/tasks/{id}"
* },
* "get_form": {
* "method": "GET",
* "path": "/V4/tasks/{id}/form",
* "controller": App\V4\Controller\Task\GetTaskFormAction::class
* },
* "put_task": {
* "method": "POST",
* "deserialize": false,
* "write": false,
* "controller": "App\V4\Controller\Task\TaskDataPersisterAction",
* "path": "/V4/tasks/{id}",
* "input_formats": {
* "multipart": {"multipart/form-data"}
* },
* "normalization_context": {
* "groups": {"task:read"}
* },
* "denormalization_context": {
* "groups": {}
* }
* },
* "renew_task": {
* "method": "POST",
* "deserialize": false,
* "write": false,
* "controller": "App\V4\Controller\Task\TaskRenewAction",
* "path": "/v4/tasks/renew/{id}",
* "swagger_context": {
* "summary": "Renouvèle une action",
* "consumes": {
* "application/json"
* },
* "parameters": {
* {
* "in": "path",
* "name": "id",
* "type": "string",
* "required": true,
* },
* {
* "in": "body",
* "name": "task",
* "schema": {
* "type": "object",
* "properties": {
* "beginAt": {"type": "string", "example": "2023-06-21T00:00"},
* },
* },
* },
* },
* },
* },
* "close_task": {
* "method": "POST",
* "deserialize": false,
* "write": false,
* "controller": "App\V4\Controller\Task\TaskCloseAction",
* "path": "/v4/tasks/close/{id}",
* "swagger_context": {
* "summary": "Clöture une action",
* },
* },
* "delete_task": {
* "method": "DELETE",
* "deserialize": false,
* "write": false,
* "controller": "App\V4\Controller\Task\TaskDataPersisterAction",
* "path": "/V4/tasks/{id}"
* },
* "get_form_move_task": {
* "method": "GET",
* "path": "/v4/move_task/form",
* "controller": "App\V4\Action\Task\MoveTaskAction",
* "swagger_context": {
* "summary": "Donne le formulaire de déplacement d'une action",
* "parameters": {},
* },
* },
* "move_task": {
* "method": "POST",
* "deserialize": false,
* "write": false,
* "path": "/v4/move_task/{id}",
* "controller": "App\V4\Action\Task\MoveTaskAction",
* "swagger_context": {
* "summary": "Déplace une action",
* "parameters": {
* {
* "in": "path",
* "name": "id",
* "type": "string",
* "required": true,
* },
* {
* "in": "body",
* "name": "task",
* "schema": {
* "type": "object",
* "properties": {
* "prospect": {"type": "string", "example": "prospect_id"},
* "contacts": {
* "type": "array",
* "items": {"type": "string"}
* },
* "quote": {"type": "string", "example": "quote_id"},
* },
* },
* },
* },
* },
* },
* }
* )
*
* @ApiFilter(App\Filters\PagingFilter::class)
*/
class Task implements IriNormalizableInterface, SpecificFieldsAwareInterface, ActionableEntityInterface
{
public const SPECIFIC_FIELD_CLASS_NAME = TaskSpecificField::class;
public const DEFAULT_REMINDER_TASK_NAME = 'default_reminder_task_name';
public const MEMO_LINE_TASK_WHEN_QUOTE_STATE_CHANGED = 'memo_line_task_when_quote_state_changed';
public const MEMO_LINE_TASK_WHEN_QUOTE_REMOVED = 'memo_line_task_when_quote_removed';
use TimestampableTrait;
use BlamableTrait;
use ImportableObjectTrait;
use NormalizeAsIRITrait;
/**
* @ApiProperty(identifier=true)
*
* @var string
*
* @Groups({
* "task:list", "task:read", "task:write", "task:update",
* })
*/
private $id;
/**
* @var string
*
* @Groups({
* "task:list", "task:read", "task:write", "task:update",
* })
*/
private $forceId;
/**
* @Assert\NotNull
*
* @var string|null
*
* @Groups({
* "task:list", "task:read", "task:write", "task:update",
* })
*/
private $name;
/**
* @var string|null
*
* @Groups({
* "task:list", "task:read", "task:write", "task:update",
* })
*/
private $externalId;
/**
* @var string|null
*
* @Groups({
* "task:list", "task:read", "task:write", "task:update",
* })
*/
private $customerId;
/**
* @var bool|null
*
* @Groups({
* "task:list", "task:read", "task:write", "task:update",
* })
*/
private $isClosed;
/**
* @var DateTime|null
*
* @Assert\DateTime(message="field_must_be_date")
* @Assert\NotBlank()
*
* @Groups({
* "task:list", "task:read", "task:write", "task:update",
* })
*/
private $beginAt;
/**
* @var DateTime|null
*
* @Assert\DateTime(message="field_must_be_date")
* @Assert\NotBlank(groups={"tasktype_is_timestamped"})
* @Assert\GreaterThanOrEqual(propertyPath="beginAt", groups={"tasktype_is_timestamped"}, message="end_date_must_be_greater")
*
* @Groups({
* "task:list", "task:read", "task:write", "task:update",
* })
*/
private $endAt;
/**
* @var string|null
*
* @Groups({
* "task:list", "task:read", "task:write", "task:update",
* })
*/
private $memo;
/**
* @var TaskType|null
* @Assert\NotBlank(
* message="Ce champ ne peut pas être vide"
* )
*
* @Groups({
* "task:list", "task:read", "task:write", "task:update",
* })
*/
private $taskType;
/**
* @var TaskMailingStats|null
*
* @Groups({
* "task:list", "task:read", "task:write", "task:update",
* })
*/
private $taskMailingStats;
/**
* @var string|null
*
* @Groups({
* "task:list", "task:read", "task:write", "task:update",
* })
*/
private $managedBy;
/**
* @var string|null
*
* @Groups({
* "task:list", "task:read", "task:write", "task:update",
* })
*/
private $description;
/**
* @var Contact[]|Collection
*
* @Groups({
* "task:list", "task:read", "task:write", "task:update",
* })
*/
private $contacts;
/**
* @var Prospect|null
*
* @Groups({
* "task:list", "task:read", "task:write", "task:update",
* })
*/
private $prospect;
/**
* @var string|null
*
* @Groups({
* "task:list", "task:read", "task:write", "task:update",
* })
*/
private $managedByRealName;
/**
* @var string|null
*
* @Groups({
* "task:list", "task:read", "task:write", "task:update",
* })
*/
private $createdByRealName;
/**
* Nom prospect.
*
* @var string|null
*
* @Groups({
* "task:list", "task:read", "task:write", "task:update",
* })
*/
private $customerName;
/**
* @var string|null
*
* @Groups({
* "task:list", "task:read", "task:write", "task:update",
* })
*/
private $updatedByRealName;
/**
* @var string|null
*
* @Groups({
* "task:list", "task:read", "task:write", "task:update",
* })
*/
private $contactsFormatted;
/**
* @var string|null
*
* @Groups({
* "task:list", "task:read", "task:write", "task:update",
* })
*/
private $report;
/**
* @var CustomerFile[]|Collection
*
* @Groups({
* "task:list", "task:read", "task:write", "task:update",
* })
*/
private $customerFiles;
/**
* @var string|null
*
* @Groups({
* "task:list", "task:read", "task:write", "task:update",
* })
*/
private $sectionName;
/**
* @var bool|null
*
* @Groups({
* "task:list", "task:read", "task:write", "task:update",
* })
*/
private $isLocked;
/**
* @var TaskSpecificField|Collection
*
* @Groups({
* "task:list", "task:read", "task:write", "task:update",
* })
*/
private $specificFields;
/**
* @var TaskQuoteExternalRef[]|Collection
*
* @Groups({
* "task:list", "task:read", "task:write", "task:update",
* })
*/
private $quotes;
/**
* @var bool
*
* @Groups({
* "task:list", "task:read", "task:write", "task:update",
* })
*/
private $isDraft = false;
public function __construct()
{
$this->contacts = new ArrayCollection();
$this->specificFields = new ArrayCollection();
$this->quotes = new ArrayCollection();
}
/**
* @return bool
*/
public function isMailing(): bool
{
if (!$this->taskType instanceof TaskType) {
return false;
}
return $this->taskType->isMailing();
}
/**
* @return bool
*/
public function isSynchroOutlook(): bool
{
if (!$this->taskType instanceof TaskType) {
return false;
}
return $this->taskType->isSynchroOutlook();
}
/**
* @return bool
*/
public function isLate(): bool
{
if ($this->isClosed) {
return false;
}
if ($this->endAt instanceof DateTime) {
return $this->endAt < new DateTime();
}
if ($this->beginAt instanceof DateTime) {
return $this->beginAt < new DateTime();
}
return false;
}
/**
* @return bool
*/
public function isReminder(): bool
{
if (!$this->taskType instanceof TaskType) {
return false;
}
return $this->taskType->isReminder();
}
/**
* @return bool
*/
public function isUnknown(): bool
{
return $this->getProspect() instanceof Prospect && $this->getProspect()->isUnknown();
}
/**
* @param string $string
*
* @return string|null
*/
public function getBeginAtWithFormat(string $string): ?string
{
return $this->getBeginAt() instanceof DateTime ? $this->getBeginAt()->format($string) : null;
}
public function setQuotesRelationByQuotes(array $quotes)
{
$this->quotes = new ArrayCollection();
foreach ($quotes as $quote) {
$relation = (new TaskQuoteExternalRef())
->setTask($this)
->setExternalValue($quote->getId())
;
$this->addQuote($relation);
}
}
/**
* {@inheritdoc}
*/
public function getSpecificFields(): Collection
{
return $this->specificFields;
}
/**
* {@inheritdoc}
*/
public function getSpecificFieldByFieldId(string $id): ?SpecificField
{
foreach ($this->specificFields as $specificField) {
if ($specificField->getFieldId() === $id) {
return $specificField;
}
}
return null;
}
/**
* @see ImportableObjectTrait::class
*
* @param TaskSpecificField $specificField
*
* @return $this
*/
public function addTaskSpecificField(TaskSpecificField $specificField): self
{
return $this->addSpecificField($specificField);
}
/**
* {@inheritdoc}
*/
public function addSpecificField($specificField): SpecificFieldsAwareInterface
{
$this->specificFields[] = $specificField;
return $this;
}
/**
* {@inheritdoc}
*/
public function setSpecificFields(Collection $specificFields): self
{
$this->specificFields = $specificFields;
return $this;
}
/**
* @return int
*/
public function getNbRead(): int
{
return $this->getTaskMailingStats() instanceof TaskMailingStats ?
$this->getTaskMailingStats()->getNbReading() ?? 0 : 0;
}
/**
* @return int
*/
public function getNbClic(): int
{
return $this->getTaskMailingStats() instanceof TaskMailingStats ?
$this->getTaskMailingStats()->getNbClic() ?? 0 : 0;
}
/**
* @return string
*/
public function getId(): ?string
{
return $this->id;
}
/**
* @param string|null $id
*
* @return Task
*/
public function setId(?string $id): Task
{
$this->id = $id;
return $this;
}
/**
* @return string|null
*/
public function getName(): ?string
{
return $this->name;
}
/**
* @param string|null $name
*
* @return Task
*/
public function setName(?string $name): Task
{
$this->name = $name;
return $this;
}
/**
* @return string|null
*/
public function getExternalId(): ?string
{
return $this->externalId;
}
/**
* @param string|null $externalId
*
* @return Task
*/
public function setExternalId(?string $externalId): Task
{
$this->externalId = $externalId;
return $this;
}
/**
* @return string|null
*/
public function getCustomerId(): ?string
{
return $this->customerId;
}
/**
* @param string|null $customerId
*
* @return Task
*/
public function setCustomerId(?string $customerId): Task
{
$this->customerId = $customerId;
return $this;
}
/**
* @return bool|null
*/
public function getIsClosed(): ?bool
{
return $this->isClosed;
}
/**
* @param bool|null $isClosed
*
* @return Task
*/
public function setIsClosed(?bool $isClosed): Task
{
$this->isClosed = $isClosed;
return $this;
}
/**
* @return DateTime|null
*/
public function getBeginAt(): ?DateTime
{
return $this->beginAt;
}
/**
* @param DateTime|null $beginAt
*
* @return Task
*/
public function setBeginAt(?DateTime $beginAt): Task
{
$this->beginAt = $beginAt;
return $this;
}
/**
* @return DateTime|null
*/
public function getEndAt(): ?DateTime
{
return $this->endAt;
}
/**
* @param DateTime|null $endAt
*
* @return Task
*/
public function setEndAt(?DateTime $endAt): Task
{
$this->endAt = $endAt;
return $this;
}
/**
* @return string|null
*/
public function getMemo(): ?string
{
return $this->memo;
}
/**
* @param string|null $memo
*
* @return Task
*/
public function setMemo(?string $memo): Task
{
$this->memo = $memo;
return $this;
}
/**
* @return TaskType|null
*/
public function getTaskType(): ?TaskType
{
return $this->taskType;
}
/**
* @param TaskType|null $taskType
*
* @return Task
*/
public function setTaskType(TaskType $taskType): Task
{
$this->taskType = $taskType;
return $this;
}
/**
* @return Contact[]|Collection
*/
public function getContacts(): Collection
{
return $this->contacts;
}
/**
* @param Contact[]|Collection|null $contacts
*
* @return Task
*/
public function setContacts(?Collection $contacts): self
{
$this->contacts = $contacts;
return $this;
}
/**
* @param Contact $contact
*
* @return Task
*/
public function addContact(Contact $contact): self
{
if (!$this->contacts->contains($contact)) {
$this->contacts->add($contact);
}
return $this;
}
/**
* @param Contact $contact
*
* @return Task
*/
public function removeContact(Contact $contact): self
{
if ($this->contacts->contains($contact)) {
$this->contacts->removeElement($contact);
}
return $this;
}
/**
* @param string $contactId
*
* @return Task
*/
public function removeContactById(string $contactId): self
{
foreach ($this->getContacts() as $contact) {
if ($contactId === $contact->getId()) {
$this->contacts->removeElement($contact);
break;
}
}
return $this;
}
/**
* @return Prospect|null
*/
public function getProspect(): ?Prospect
{
return $this->prospect;
}
/**
* @param Prospect|null $prospect
*
* @return $this
*/
public function setProspect($prospect): self
{
$this->prospect = $prospect;
return $this;
}
/**
* @return string|null
*/
public function getManagedBy(): ?string
{
return $this->managedBy;
}
/**
* @param string|null $managedBy
*
* @return Task
*/
public function setManagedBy(?string $managedBy): Task
{
$this->managedBy = $managedBy;
return $this;
}
/**
* @return string
*/
public function getProspectId(): ?string
{
return $this->getProspect() ? $this->getProspect()->getId() : null;
}
/**
* @return string|null
*/
public function getManagedByRealName(): ?string
{
return $this->managedByRealName;
}
/**
* @param string|null $managedByRealName
*
* @return $this
*/
public function setManagedByRealName(?string $managedByRealName): self
{
$this->managedByRealName = $managedByRealName;
return $this;
}
/**
* @return string|null
*/
public function getDescription(): ?string
{
return $this->description;
}
/**
* @param string|null $description
*
* @return Task
*/
public function setDescription(?string $description): Task
{
$this->description = $description;
return $this;
}
/**
* @Groups({"list", "read", "list_task", "read_task", "list_prospect", "read_prospect", "read_post_task", "write_post_task"})
*
* @return string|null
*/
public function getCreatedBy(): ?string
{
return $this->createdBy;
}
/**
* @Groups({"list", "read", "list_task", "read_task", "list_prospect", "read_prospect", "read_post_task", "write_post_task"})
*
* @return string|null
*/
public function getUpdatedBy(): ?string
{
return $this->updatedBy;
}
/**
* @Groups({"list", "read", "list_task", "read_task", "list_prospect", "read_prospect", "read_post_task", "write_post_task"})
*
* @return DateTime|null
*/
public function getCreatedAt(): ?DateTime
{
return $this->createdAt;
}
/**
* @Groups({"list", "read", "list_task", "read_task", "list_prospect", "read_prospect", "read_post_task", "write_post_task"})
*
* @return DateTime|null
*/
public function getUpdatedAt(): ?DateTime
{
return $this->updatedAt;
}
/**
* @return string|null
*/
public function getCreatedByRealName(): ?string
{
return $this->createdByRealName;
}
/**
* @param string|null $createdByRealName
*
* @return Task
*/
public function setCreatedByRealName(?string $createdByRealName): Task
{
$this->createdByRealName = $createdByRealName;
return $this;
}
/**
* @return string|null
*/
public function getUpdatedByRealName(): ?string
{
return $this->updatedByRealName;
}
/**
* @param string|null $updatedByRealName
*
* @return Task
*/
public function setUpdatedByRealName(?string $updatedByRealName): Task
{
$this->updatedByRealName = $updatedByRealName;
return $this;
}
/**
* @return string|null
*/
public function getReport(): ?string
{
return $this->report;
}
/**
* @param string|null $report
*
* @return Task
*/
public function setReport(?string $report): Task
{
$this->report = $report;
return $this;
}
/**
* @return CustomerFile[]
*/
public function getCustomerFiles()
{
return $this->customerFiles;
}
/**
* @param CustomerFile $customerFile
*
* @return Task
*/
public function addCustomerFile(CustomerFile $customerFile): self
{
$this->customerFiles[] = $customerFile;
return $this;
}
/**
* @param CustomerFile $customerFile
*
* @return Task
*/
public function removeCustomerFile(CustomerFile $customerFile): self
{
$index = array_search($customerFile, $this->customerFiles, true);
if (false !== $index) {
unset($this->customerFiles[$index]);
}
return $this;
}
/**
* @param CustomerFile[] $customerFiles
*
* @return Task
*/
public function setCustomerFiles(array $customerFiles): self
{
$this->customerFiles = $customerFiles;
return $this;
}
/**
* @return string|null
*/
public function getForceId(): ?string
{
return $this->forceId ? $this->forceId : null;
}
/**
* @param string|null $forceId
*
* @return Task
*/
public function setForceId(?string $forceId): Task
{
$this->forceId = $forceId;
return $this;
}
/**
* @return TaskMailingStats|null
*/
public function getTaskMailingStats(): ?TaskMailingStats
{
return $this->taskMailingStats;
}
/**
* @param TaskMailingStats|null $taskMailingStats
*
* @return Task
*/
public function setTaskMailingStats(?TaskMailingStats $taskMailingStats): Task
{
$this->taskMailingStats = $taskMailingStats;
return $this;
}
/**
* @return string|null
*/
public function getContactsFormatted(): ?string
{
return $this->contactsFormatted;
}
/**
* @param string|null $contactsFormatted
*
* @return Task
*/
public function setContactsFormatted(?string $contactsFormatted): Task
{
$this->contactsFormatted = $contactsFormatted;
return $this;
}
/**
* @return string|null
*/
public function getCustomerName(): ?string
{
return $this->customerName;
}
/**
* @param string|null $customerName
*
* @return Task
*/
public function setCustomerName(?string $customerName): Task
{
$this->customerName = $customerName;
return $this;
}
/**
* @return string|null
*/
public function getSectionName(): ?string
{
return $this->sectionName;
}
/**
* @param string|null $sectionName
*
* @return Task
*/
public function setSectionName(?string $sectionName): Task
{
$this->sectionName = $sectionName;
return $this;
}
/**
* @return bool|null
*/
public function isLocked(): ?bool
{
return $this->isLocked;
}
/**
* @todo PV-942 : indispensable pour api platform
*
* @return bool|null
*/
public function getIsLocked(): ?bool
{
return $this->isLocked();
}
/**
* @param bool|null $isLocked
*
* @return Task
*/
public function setIsLocked(?bool $isLocked): self
{
$this->isLocked = $isLocked;
return $this;
}
/**
* @param string $quoteId
*
* @return bool
*/
public function hasQuote(string $quoteId): bool
{
foreach ($this->quotes as $quote) {
if ($quoteId === $quote->getExternalValue()) {
return true;
}
}
return false;
}
/**
* @return TaskQuoteExternalRef[]|Collection
*/
public function getQuotes(): Collection
{
return $this->quotes;
}
/**
* @param TaskQuoteExternalRef[]|Collection $quotes
*
* @return self
*/
public function setQuotes(Collection $quotes): self
{
$this->quotes = $quotes;
return $this;
}
/**
* @param TaskQuoteExternalRef $quote
*
* @return self
*/
public function addQuote(TaskQuoteExternalRef $quote): self
{
if (!$this->quotes->contains($quote)) {
$this->quotes->add($quote);
}
return $this;
}
/**
* Redondance avec addQuote dû au ImportableObjectTrait.
*
* @param TaskQuoteExternalRef $quote
*
* @return self
*/
public function addTaskQuoteExternalRef(TaskQuoteExternalRef $quote): self
{
return $this->addQuote($quote);
}
/**
* @param TaskQuoteExternalRef $quote
*
* @return self
*/
public function removeQuote(TaskQuoteExternalRef $quote): self
{
if ($this->quotes->contains($quote)) {
$this->quotes->remove($quote);
}
return $this;
}
public function removeTaskQuoteExternalRefByExternalValue(?string $quoteId)
{
foreach ($this->quotes as $quote) {
if ($quoteId === $quote->getExternalValue()) {
$this->removeQuote($quote);
}
}
}
public function getIsDraft(): bool
{
return $this->isDraft;
}
public function setIsDraft(bool $isDraft): self
{
$this->isDraft = $isDraft;
return $this;
}
}