Apply rector rules: add annotation for doctrine mapping

This commit is contained in:
2024-04-05 00:01:30 +02:00
parent 579bd829f8
commit 72016e1a21
124 changed files with 1724 additions and 3770 deletions

View File

@@ -37,6 +37,7 @@ use Symfony\Component\Form\Extension\Core\Type\HiddenType;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\Form\FormFactoryInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\StreamedResponse;
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
use Symfony\Component\Security\Core\Security;
@@ -110,13 +111,9 @@ final class EventController extends AbstractController
/**
* Displays a form to edit an existing Event entity.
*
* @return \Symfony\Component\HttpFoundation\Response
* @return \Symfony\Component\HttpFoundation\Response
*
* @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/event/event/{event_id}/edit", name="chill_event__event_edit")
*/
#[\Symfony\Component\Routing\Annotation\Route(path: '/{_locale}/event/event/{event_id}/edit', name: 'chill_event__event_edit')]
public function editAction($event_id)
public function editAction($event_id): Response
{
$em = $this->managerRegistry->getManager();
@@ -140,12 +137,9 @@ final class EventController extends AbstractController
* @return \Symfony\Component\HttpFoundation\Response
*
* @throws \Doctrine\ORM\NonUniqueResultException
* @throws \Doctrine\ORM\NonUniqueResultException
*
* @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/event/event/{person_id}/list", name="chill_event__list_by_person", methods={"GET"})
*/
#[\Symfony\Component\Routing\Annotation\Route(path: '/{_locale}/event/event/{person_id}/list', name: 'chill_event__list_by_person', methods: ['GET'])]
public function listByPersonAction($person_id)
public function listByPersonAction($person_id): Response
{
$em = $this->managerRegistry->getManager();
@@ -200,14 +194,9 @@ final class EventController extends AbstractController
/**
* Displays a form to create a new Event entity.
*
* @return \Symfony\Component\HttpFoundation\Response
* @return \Symfony\Component\HttpFoundation\Response
*
* @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/event/event/new", name="chill_event__event_new", methods={"GET", "POST"})
*/
#[\Symfony\Component\Routing\Annotation\Route(path: '/{_locale}/event/event/new', name: 'chill_event__event_new', methods: ['GET', 'POST'])]
public function newAction(?Center $center, Request $request)
public function newAction(?Center $center, Request $request): Response
{
$user = $this->security->getUser();
@@ -248,7 +237,7 @@ final class EventController extends AbstractController
* First step of new Event form.
*/
#[\Symfony\Component\Routing\Annotation\Route(path: '/{_locale}/event/event/new/pick-center', name: 'chill_event__event_new_pickcenter', options: [null])]
public function newPickCenterAction()
public function newPickCenterAction(): Response
{
$role = 'CHILL_EVENT_CREATE';
@@ -295,9 +284,7 @@ final class EventController extends AbstractController
* @return \Symfony\Component\HttpFoundation\Response
*
* @throws \PhpOffice\PhpSpreadsheet\Exception
* @throws \PhpOffice\PhpSpreadsheet\Exception
*
* @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/event/event/{event_id}/show", name="chill_event__event_show")
*/
#[\Symfony\Component\Routing\Annotation\Route(path: '/{_locale}/event/event/{event_id}/show', name: 'chill_event__event_show')]
public function showAction(Event $event, Request $request)
@@ -370,7 +357,7 @@ final class EventController extends AbstractController
$builder = $this
->formFactoryInterface
->createNamedBuilder(
null,
'',
FormType::class,
null,
[

View File

@@ -289,9 +289,7 @@ final class ParticipationController extends AbstractController
*
* @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException if the participation is not found
* @throws \Symfony\Component\HttpFoundation\File\Exception\AccessDeniedException if the user is not allowed to edit the participation
* @throws \Symfony\Component\HttpFoundation\File\Exception\AccessDeniedException if the user is not allowed to edit the participation
*
* @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/event/participation/{participation_id}/edit", name="chill_event_participation_edit")
*/
#[\Symfony\Component\Routing\Annotation\Route(path: '/{_locale}/event/participation/{participation_id}/edit', name: 'chill_event_participation_edit')]
public function editAction(int $participation_id): Response
@@ -323,9 +321,7 @@ final class ParticipationController extends AbstractController
* show a form to edit multiple participation for the same event.
*
* @param int $event_id
* @param int $event_id
*
* @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/event/participation/{event_id}/edit_multiple", name="chill_event_participation_edit_multiple")
*/
#[\Symfony\Component\Routing\Annotation\Route(path: '/{_locale}/event/participation/{event_id}/edit_multiple', name: 'chill_event_participation_edit_multiple')]
public function editMultipleAction($event_id): Response|\Symfony\Component\HttpFoundation\RedirectResponse

View File

@@ -32,92 +32,68 @@ use Symfony\Component\Validator\Constraints as Assert;
/**
* Class Event.
*
* @ORM\Entity(repositoryClass="Chill\EventBundle\Repository\EventRepository")
*
* @ORM\Table(name="chill_event_event")
*
* @ORM\HasLifecycleCallbacks
*/
#[ORM\Entity(repositoryClass: \Chill\EventBundle\Repository\EventRepository::class)]
#[ORM\HasLifecycleCallbacks]
#[ORM\Table(name: 'chill_event_event')]
class Event implements HasCenterInterface, HasScopeInterface, TrackCreationInterface, TrackUpdateInterface
{
use TrackCreationTrait;
use TrackUpdateTrait;
/**
* @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\Center")A
*/
#[Assert\NotNull]
#[ORM\ManyToOne(targetEntity: \Chill\MainBundle\Entity\Center::class)] // A
private ?Center $center = null;
/**
* @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\Scope")
*/
#[ORM\ManyToOne(targetEntity: \Chill\MainBundle\Entity\Scope::class)]
private ?Scope $circle = null;
/**
* @ORM\Column(type="datetime")
*/
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::DATETIME_MUTABLE)]
private ?\DateTime $date;
/**
* @ORM\Id
*
* @ORM\Column(name="id", type="integer")
*
* @ORM\GeneratedValue(strategy="AUTO")
*/
#[ORM\Id]
#[ORM\Column(name: 'id', type: \Doctrine\DBAL\Types\Types::INTEGER)]
#[ORM\GeneratedValue(strategy: 'AUTO')]
private ?int $id = null;
/**
* @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\User")
*/
#[ORM\ManyToOne(targetEntity: \Chill\MainBundle\Entity\User::class)]
private ?User $moderator = null;
/**
* @ORM\Column(type="string", length=150)
*/
#[Assert\NotBlank]
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::STRING, length: 150)]
private ?string $name = null;
/**
* @var Collection<Participation>
*
* @ORM\OneToMany(
* targetEntity="Chill\EventBundle\Entity\Participation",
* mappedBy="event")
*/
#[ORM\OneToMany(targetEntity: \Chill\EventBundle\Entity\Participation::class, mappedBy: 'event')]
private Collection $participations;
/**
* @ORM\ManyToOne(targetEntity="Chill\EventBundle\Entity\EventType")
*/
#[Assert\NotNull]
#[ORM\ManyToOne(targetEntity: \Chill\EventBundle\Entity\EventType::class)]
private ?EventType $type = null;
/**
* @ORM\Embedded(class=CommentEmbeddable::class, columnPrefix="comment_")
*/
#[ORM\Embedded(class: CommentEmbeddable::class, columnPrefix: 'comment_')]
private CommentEmbeddable $comment;
/**
* @ORM\ManyToOne(targetEntity=Location::class)
*
* @ORM\JoinColumn(nullable=true)
*/
#[ORM\ManyToOne(targetEntity: Location::class)]
#[ORM\JoinColumn(nullable: true)]
private ?Location $location = null;
/**
* @var Collection<StoredObject>
*
* @ORM\ManyToMany(targetEntity=StoredObject::class, cascade={"persist","refresh"})
*
* @ORM\JoinTable("chill_event_event_documents")
*/
#[ORM\ManyToMany(targetEntity: StoredObject::class, cascade: ['persist', 'refresh'])]
#[ORM\JoinTable('chill_event_event_documents')]
private Collection $documents;
/**
* @ORM\Column(type="decimal", precision=10, scale=4, nullable=true, options={"default": null})
*/
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::DECIMAL, precision: 10, scale: 4, nullable: true, options: ['default' => null])]
private string $organizationCost = '0.0';
/**

View File

@@ -18,51 +18,39 @@ use Doctrine\ORM\Mapping as ORM;
/**
* Class EventType.
*
* @ORM\Entity
*
* @ORM\Table(name="chill_event_event_type")
*
* @ORM\HasLifecycleCallbacks
*/
#[ORM\Entity]
#[ORM\HasLifecycleCallbacks]
#[ORM\Table(name: 'chill_event_event_type')]
class EventType
{
/**
* @ORM\Column(type="boolean", nullable=false)
*/
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::BOOLEAN, nullable: false)]
private bool $active = true;
/**
* @ORM\Id
*
* @ORM\Column(name="id", type="integer")
*
* @ORM\GeneratedValue(strategy="AUTO")
*/
#[ORM\Id]
#[ORM\Column(name: 'id', type: \Doctrine\DBAL\Types\Types::INTEGER)]
#[ORM\GeneratedValue(strategy: 'AUTO')]
private ?int $id = null;
/**
* @var array
*
* @ORM\Column(type="json")
*/
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::JSON)]
private $name;
/**
* @var Collection<Role>
*
* @ORM\OneToMany(
* targetEntity="Chill\EventBundle\Entity\Role",
* mappedBy="type")
*/
#[ORM\OneToMany(targetEntity: \Chill\EventBundle\Entity\Role::class, mappedBy: 'type')]
private Collection $roles;
/**
* @var Collection<Status>
*
* @ORM\OneToMany(
* targetEntity="Chill\EventBundle\Entity\Status",
* mappedBy="type")
*/
#[ORM\OneToMany(targetEntity: \Chill\EventBundle\Entity\Status::class, mappedBy: 'type')]
private Collection $statuses;
/**

View File

@@ -27,55 +27,39 @@ use Symfony\Component\Validator\Context\ExecutionContextInterface;
/**
* Class Participation.
*
* @ORM\Entity(
* repositoryClass="Chill\EventBundle\Repository\ParticipationRepository")
*
* @ORM\Table(name="chill_event_participation", uniqueConstraints={
*
* @ORM\UniqueConstraint(name="chill_event_participation_event_person_unique_idx", columns={"event_id", "person_id"})
* })
* @ORM\UniqueConstraint(name="chill_event_participation_event_person_unique_idx", columns={"event_id", "person_id"})
* })
*
* @ORM\HasLifecycleCallbacks
*/
#[UniqueEntity(['event', 'person'], message: 'event.validation.person_already_participate_to_event')]
#[ORM\Entity(repositoryClass: \Chill\EventBundle\Repository\ParticipationRepository::class)]
#[ORM\UniqueConstraint(name: 'chill_event_participation_event_person_unique_idx', columns: ['event_id', 'person_id'])] // @ORM\HasLifecycleCallbacks
#[ORM\Table(name: 'chill_event_participation')]
#[ORM\UniqueConstraint(name: 'chill_event_participation_event_person_unique_idx', columns: ['event_id', 'person_id'])]
#[ORM\UniqueConstraint(name: 'chill_event_participation_event_person_unique_idx', columns: ['event_id', 'person_id'])]
#[ORM\HasLifecycleCallbacks] // @ORM\HasLifecycleCallbacks
class Participation implements \ArrayAccess, HasCenterInterface, HasScopeInterface, TrackUpdateInterface, TrackCreationInterface
{
use TrackCreationTrait;
use TrackUpdateTrait;
/**
* @ORM\ManyToOne(
* targetEntity="Chill\EventBundle\Entity\Event",
* inversedBy="participations")
*/
#[ORM\ManyToOne(targetEntity: \Chill\EventBundle\Entity\Event::class, inversedBy: 'participations')]
private ?Event $event = null;
/**
* @ORM\Id
*
* @ORM\Column(name="id", type="integer")
*
* @ORM\GeneratedValue(strategy="AUTO")
*/
#[ORM\Id]
#[ORM\Column(name: 'id', type: \Doctrine\DBAL\Types\Types::INTEGER)]
#[ORM\GeneratedValue(strategy: 'AUTO')]
private ?int $id = null;
/**
* @ORM\ManyToOne(targetEntity="Chill\PersonBundle\Entity\Person")
*/
#[Assert\NotNull]
#[ORM\ManyToOne(targetEntity: \Chill\PersonBundle\Entity\Person::class)]
private ?Person $person = null;
/**
* @ORM\ManyToOne(targetEntity="Chill\EventBundle\Entity\Role")
*/
#[ORM\ManyToOne(targetEntity: \Chill\EventBundle\Entity\Role::class)]
private ?Role $role = null;
/**
* @ORM\ManyToOne(targetEntity="Chill\EventBundle\Entity\Status")
*/
#[Assert\NotNull]
#[ORM\ManyToOne(targetEntity: \Chill\EventBundle\Entity\Status::class)]
private ?Status $status = null;
public function getCenter()

View File

@@ -16,40 +16,30 @@ use Doctrine\ORM\Mapping as ORM;
/**
* Class Role.
*
* @ORM\Entity
*
* @ORM\Table(name="chill_event_role")
*
* @ORM\HasLifecycleCallbacks
*/
#[ORM\Entity]
#[ORM\HasLifecycleCallbacks]
#[ORM\Table(name: 'chill_event_role')]
class Role
{
/**
* @ORM\Column(type="boolean", nullable=false)
*/
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::BOOLEAN, nullable: false)]
private bool $active = true;
/**
* @ORM\Id
*
* @ORM\Column(name="id", type="integer")
*
* @ORM\GeneratedValue(strategy="AUTO")
*/
#[ORM\Id]
#[ORM\Column(name: 'id', type: \Doctrine\DBAL\Types\Types::INTEGER)]
#[ORM\GeneratedValue(strategy: 'AUTO')]
private ?int $id = null;
/**
* @var array
*
* @ORM\Column(type="json")
*/
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::JSON)]
private $name;
/**
* @ORM\ManyToOne(
* targetEntity="Chill\EventBundle\Entity\EventType",
* inversedBy="roles")
*/
#[ORM\ManyToOne(targetEntity: \Chill\EventBundle\Entity\EventType::class, inversedBy: 'roles')]
private ?EventType $type = null;
/**

View File

@@ -16,40 +16,30 @@ use Doctrine\ORM\Mapping as ORM;
/**
* Class Status.
*
* @ORM\Entity
*
* @ORM\Table(name="chill_event_status")
*
* @ORM\HasLifecycleCallbacks
*/
#[ORM\Entity]
#[ORM\HasLifecycleCallbacks]
#[ORM\Table(name: 'chill_event_status')]
class Status
{
/**
* @ORM\Column(type="boolean", nullable=false)
*/
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::BOOLEAN, nullable: false)]
private bool $active = true;
/**
* @ORM\Id
*
* @ORM\Column(name="id", type="integer")
*
* @ORM\GeneratedValue(strategy="AUTO")
*/
#[ORM\Id]
#[ORM\Column(name: 'id', type: \Doctrine\DBAL\Types\Types::INTEGER)]
#[ORM\GeneratedValue(strategy: 'AUTO')]
private ?int $id = null;
/**
* @var array
*
* @ORM\Column(type="json")
*/
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::JSON)]
private $name;
/**
* @ORM\ManyToOne(
* targetEntity="Chill\EventBundle\Entity\EventType",
* inversedBy="statuses")
*/
#[ORM\ManyToOne(targetEntity: \Chill\EventBundle\Entity\EventType::class, inversedBy: 'statuses')]
private ?EventType $type = null;
/**