mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-29 19:13:49 +00:00
Apply rector rules: add annotation for doctrine mapping
This commit is contained in:
@@ -12,6 +12,7 @@ declare(strict_types=1);
|
||||
namespace Chill\TaskBundle\Entity;
|
||||
|
||||
use Chill\TaskBundle\Entity\Task\SingleTaskPlaceEvent;
|
||||
use Chill\TaskBundle\Repository\SingleTaskRepository;
|
||||
use DateInterval;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
@@ -22,79 +23,50 @@ use Symfony\Component\Validator\Constraints as Assert;
|
||||
/**
|
||||
* SingleTask.
|
||||
*
|
||||
* @ORM\Table(
|
||||
* name="chill_task.single_task",
|
||||
* indexes={
|
||||
*
|
||||
* @ORM\Index(
|
||||
* name="by_type",
|
||||
* columns={ "type" }
|
||||
* ),
|
||||
* @ORM\Index(
|
||||
* name="by_current_state",
|
||||
* columns={ "current_states" }
|
||||
* ),
|
||||
* @ORM\Index(
|
||||
* name="by_end_date",
|
||||
* columns={ "end_date" }
|
||||
* )
|
||||
* }
|
||||
* )
|
||||
*
|
||||
* @ORM\Entity(repositoryClass="Chill\TaskBundle\Repository\SingleTaskRepository")
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
#[ORM\Entity(repositoryClass: SingleTaskRepository::class)]
|
||||
#[ORM\Table(name: 'chill_task.single_task')]
|
||||
#[ORM\Index(name: 'by_type', columns: ['type'])]
|
||||
#[ORM\Index(name: 'by_current_state', columns: ['current_states'])]
|
||||
#[ORM\Index(name: 'by_end_date', columns: ['end_date'])]
|
||||
class SingleTask extends AbstractTask
|
||||
{
|
||||
/**
|
||||
* @ORM\Column(name="end_date", type="date", nullable=true)
|
||||
*/
|
||||
#[Assert\Date]
|
||||
#[Serializer\Groups(['read'])]
|
||||
#[ORM\Column(name: 'end_date', type: \Doctrine\DBAL\Types\Types::DATE_MUTABLE, nullable: true)]
|
||||
private ?\DateTime $endDate = null;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="id", type="integer")
|
||||
*
|
||||
* @ORM\Id
|
||||
*
|
||||
* @ORM\GeneratedValue(strategy="AUTO")
|
||||
*/
|
||||
|
||||
#[Serializer\Groups(['read'])]
|
||||
#[ORM\Column(name: 'id', type: \Doctrine\DBAL\Types\Types::INTEGER)]
|
||||
#[ORM\Id]
|
||||
#[ORM\GeneratedValue(strategy: 'AUTO')]
|
||||
private ?int $id = null;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(
|
||||
* targetEntity="RecurringTask",
|
||||
* inversedBy="singleTasks"
|
||||
* )
|
||||
*/
|
||||
#[ORM\ManyToOne(targetEntity: RecurringTask::class, inversedBy: 'singleTasks')]
|
||||
private ?RecurringTask $recurringTask = null;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="start_date", type="date", nullable=true)
|
||||
*/
|
||||
#[Serializer\Groups(['read'])]
|
||||
#[Assert\Date]
|
||||
#[Assert\Expression('value === null or this.getEndDate() === null or value < this.getEndDate()', message: 'The start date must be before the end date')]
|
||||
#[Assert\Expression('value === null or this.getWarningDate() === null or this.getWarningDate() > this.getStartDate()', message: 'The start date must be before warning date')]
|
||||
#[ORM\Column(name: 'start_date', type: \Doctrine\DBAL\Types\Types::DATE_MUTABLE, nullable: true)]
|
||||
private ?\DateTime $startDate = null;
|
||||
|
||||
/**
|
||||
* @var Collection<SingleTaskPlaceEvent>
|
||||
*
|
||||
* @ORM\OneToMany(
|
||||
* targetEntity="\Chill\TaskBundle\Entity\Task\SingleTaskPlaceEvent",
|
||||
* mappedBy="task",
|
||||
* cascade={ "remove" }
|
||||
* )
|
||||
*/
|
||||
#[ORM\OneToMany(targetEntity: SingleTaskPlaceEvent::class, mappedBy: 'task', cascade: ['remove'])]
|
||||
private Collection $taskPlaceEvents;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="warning_interval", type="dateinterval", nullable=true)
|
||||
*/
|
||||
#[Serializer\Groups(['read'])]
|
||||
#[Assert\Expression('!(value != null and this.getEndDate() == null)', message: 'An end date is required if a warning interval is set')]
|
||||
#[ORM\Column(name: 'warning_interval', type: \Doctrine\DBAL\Types\Types::DATEINTERVAL, nullable: true)]
|
||||
private ?\DateInterval $warningInterval = null;
|
||||
|
||||
public function __construct()
|
||||
|
Reference in New Issue
Block a user