mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-29 11:03:50 +00:00
Apply rector rules: add annotation for doctrine mapping
This commit is contained in:
@@ -23,70 +23,45 @@ use Symfony\Component\Validator\Constraints as Assert;
|
||||
|
||||
/**
|
||||
* AbstractTask.
|
||||
*
|
||||
* @ORM\MappedSuperclass
|
||||
*/
|
||||
#[Serializer\DiscriminatorMap(typeProperty: 'type', mapping: ['single_task' => SingleTask::class])]
|
||||
#[ORM\MappedSuperclass]
|
||||
abstract class AbstractTask implements HasCenterInterface, HasScopeInterface
|
||||
{
|
||||
/**
|
||||
* @ORM\ManyToOne(
|
||||
* targetEntity="\Chill\MainBundle\Entity\User"
|
||||
* )
|
||||
*/
|
||||
#[Serializer\Groups(['read'])]
|
||||
#[ORM\ManyToOne(targetEntity: User::class)]
|
||||
private ?User $assignee = null;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(
|
||||
* targetEntity="\Chill\MainBundle\Entity\Scope"
|
||||
* )
|
||||
*/
|
||||
#[ORM\ManyToOne(targetEntity: Scope::class)]
|
||||
private ?Scope $circle = null;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="closed", type="boolean", options={ "default": false })
|
||||
*/
|
||||
#[Serializer\Groups(['read'])]
|
||||
#[ORM\Column(name: 'closed', type: \Doctrine\DBAL\Types\Types::BOOLEAN, options: ['default' => false])]
|
||||
private bool $closed = false;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="\Chill\PersonBundle\Entity\AccompanyingPeriod")
|
||||
*/
|
||||
#[Serializer\Groups(['read'])]
|
||||
#[ORM\ManyToOne(targetEntity: AccompanyingPeriod::class)]
|
||||
private ?AccompanyingPeriod $course = null;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="current_states", type="json", options={"jsonb"=true, "default"="[]"})
|
||||
*/
|
||||
#[Serializer\Groups(['read'])]
|
||||
#[ORM\Column(name: 'current_states', type: \Doctrine\DBAL\Types\Types::JSON, options: ['jsonb' => true, 'default' => '[]'])]
|
||||
private array $currentStates = [];
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="description", type="text")
|
||||
*/
|
||||
#[Serializer\Groups(['read'])]
|
||||
#[ORM\Column(name: 'description', type: \Doctrine\DBAL\Types\Types::TEXT)]
|
||||
private string $description = '';
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(
|
||||
* targetEntity="\Chill\PersonBundle\Entity\Person"
|
||||
* )
|
||||
*/
|
||||
#[Serializer\Groups(['read'])]
|
||||
#[ORM\ManyToOne(targetEntity: Person::class)]
|
||||
private ?Person $person = null;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="title", type="text")
|
||||
*/
|
||||
#[Assert\NotBlank]
|
||||
#[Serializer\Groups(['read'])]
|
||||
#[ORM\Column(name: 'title', type: \Doctrine\DBAL\Types\Types::TEXT)]
|
||||
private string $title = '';
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="type", type="string", length=255)
|
||||
*/
|
||||
#[Serializer\Groups(['read'])]
|
||||
#[ORM\Column(name: 'type', type: \Doctrine\DBAL\Types\Types::STRING, length: 255)]
|
||||
private ?string $type = null;
|
||||
|
||||
public function getAssignee(): ?User
|
||||
@@ -101,8 +76,6 @@ abstract class AbstractTask implements HasCenterInterface, HasScopeInterface
|
||||
}
|
||||
|
||||
return $this->getCourse()->getCenter();
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public function getCircle(): ?Scope
|
||||
|
@@ -18,54 +18,37 @@ use Doctrine\ORM\Mapping as ORM;
|
||||
/**
|
||||
* RecurringTask.
|
||||
*
|
||||
* @ORM\Table(name="chill_task.recurring_task")
|
||||
*
|
||||
* @ORM\Entity(repositoryClass="Chill\TaskBundle\Repository\RecurringTaskRepository")
|
||||
*/
|
||||
#[ORM\Entity(repositoryClass: \Chill\TaskBundle\Repository\RecurringTaskRepository::class)]
|
||||
#[ORM\Table(name: 'chill_task.recurring_task')]
|
||||
class RecurringTask extends AbstractTask
|
||||
{
|
||||
/**
|
||||
* @ORM\Column(name="first_occurence_end_date", type="date")
|
||||
*/
|
||||
#[ORM\Column(name: 'first_occurence_end_date', type: \Doctrine\DBAL\Types\Types::DATE_MUTABLE)]
|
||||
private ?\DateTime $firstOccurenceEndDate = null;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="id", type="integer")
|
||||
*
|
||||
* @ORM\Id
|
||||
*
|
||||
* @ORM\GeneratedValue(strategy="AUTO")
|
||||
*/
|
||||
|
||||
#[ORM\Column(name: 'id', type: \Doctrine\DBAL\Types\Types::INTEGER)]
|
||||
#[ORM\Id]
|
||||
#[ORM\GeneratedValue(strategy: 'AUTO')]
|
||||
private ?int $id = null;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="last_occurence_end_date", type="date")
|
||||
*/
|
||||
#[ORM\Column(name: 'last_occurence_end_date', type: \Doctrine\DBAL\Types\Types::DATE_MUTABLE)]
|
||||
private ?\DateTime $lastOccurenceEndDate = null;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="occurence_frequency", type="string", length=255)
|
||||
*/
|
||||
#[ORM\Column(name: 'occurence_frequency', type: \Doctrine\DBAL\Types\Types::STRING, length: 255)]
|
||||
private ?string $occurenceFrequency = null;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="occurence_start_date", type="dateinterval")
|
||||
*/
|
||||
#[ORM\Column(name: 'occurence_start_date', type: \Doctrine\DBAL\Types\Types::DATEINTERVAL)]
|
||||
private $occurenceStartDate;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="occurence_warning_interval", type="dateinterval", nullable=true)
|
||||
*/
|
||||
#[ORM\Column(name: 'occurence_warning_interval', type: \Doctrine\DBAL\Types\Types::DATEINTERVAL, nullable: true)]
|
||||
private $occurenceWarningInterval;
|
||||
|
||||
/**
|
||||
* @var Collection<SingleTask>
|
||||
*
|
||||
* @ORM\OneToMany(
|
||||
* targetEntity="SingleTask",
|
||||
* mappedBy="recurringTask"
|
||||
* )
|
||||
*/
|
||||
#[ORM\OneToMany(targetEntity: \SingleTask::class, mappedBy: 'recurringTask')]
|
||||
private Collection $singleTasks;
|
||||
|
||||
public function __construct()
|
||||
|
@@ -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()
|
||||
|
@@ -16,33 +16,23 @@ use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
/**
|
||||
* AbstractTaskPlaceEvent.
|
||||
*
|
||||
* @ORM\MappedSuperclass
|
||||
*/
|
||||
#[ORM\MappedSuperclass]
|
||||
class AbstractTaskPlaceEvent
|
||||
{
|
||||
/**
|
||||
* @ORM\ManyToOne(
|
||||
* targetEntity="\Chill\MainBundle\Entity\User"
|
||||
* )
|
||||
*/
|
||||
#[ORM\ManyToOne(targetEntity: User::class)]
|
||||
private ?User $author = null;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="data", type="json")
|
||||
*/
|
||||
#[ORM\Column(name: 'data', type: \Doctrine\DBAL\Types\Types::JSON)]
|
||||
private array $data = [];
|
||||
|
||||
/**
|
||||
* @var datetime_immutable
|
||||
*
|
||||
* @ORM\Column(name="datetime", type="datetime_immutable")
|
||||
* @var \DateTimeImmutable
|
||||
*/
|
||||
#[ORM\Column(name: 'datetime', type: \Doctrine\DBAL\Types\Types::DATETIME_IMMUTABLE)]
|
||||
private $datetime;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="transition", type="string", length=255)
|
||||
*/
|
||||
#[ORM\Column(name: 'transition', type: \Doctrine\DBAL\Types\Types::STRING, length: 255)]
|
||||
private string $transition = '';
|
||||
|
||||
public function __construct()
|
||||
|
@@ -14,40 +14,20 @@ namespace Chill\TaskBundle\Entity\Task;
|
||||
use Chill\TaskBundle\Entity\SingleTask;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
/**
|
||||
* @ORM\Table(
|
||||
* name="chill_task.single_task_place_event",
|
||||
* indexes={
|
||||
*
|
||||
* @ORM\Index(
|
||||
* name="transition_task_date",
|
||||
* columns={"task_id", "transition", "datetime"}
|
||||
* ),
|
||||
* @ORM\Index(
|
||||
* name="transition_task",
|
||||
* columns={"task_id", "transition"}
|
||||
* )
|
||||
* })
|
||||
*
|
||||
* @ORM\Entity
|
||||
*/
|
||||
|
||||
#[ORM\Entity]
|
||||
#[ORM\Table(name: 'chill_task.single_task_place_event')]
|
||||
#[ORM\Index(name: 'transition_task_date', columns: ['task_id', 'transition', 'datetime'])]
|
||||
#[ORM\Index(name: 'transition_task', columns: ['task_id', 'transition'])]
|
||||
class SingleTaskPlaceEvent extends AbstractTaskPlaceEvent
|
||||
{
|
||||
/**
|
||||
* @ORM\Column(name="id", type="integer")
|
||||
*
|
||||
* @ORM\Id
|
||||
*
|
||||
* @ORM\GeneratedValue(strategy="AUTO")
|
||||
*/
|
||||
|
||||
#[ORM\Column(name: 'id', type: \Doctrine\DBAL\Types\Types::INTEGER)]
|
||||
#[ORM\Id]
|
||||
#[ORM\GeneratedValue(strategy: 'AUTO')]
|
||||
private ?int $id = null;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(
|
||||
* targetEntity="\Chill\TaskBundle\Entity\SingleTask",
|
||||
* inversedBy="taskPlaceEvents"
|
||||
* )
|
||||
*/
|
||||
#[ORM\ManyToOne(targetEntity: SingleTask::class, inversedBy: 'taskPlaceEvents')]
|
||||
protected ?SingleTask $task = null;
|
||||
|
||||
public function getTask(): SingleTask
|
||||
|
Reference in New Issue
Block a user