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

@@ -71,15 +71,10 @@ use Symfony\Component\Validator\Constraints as Assert;
*
* The difference between categories and types is transparent for user: they choose the same fields into the UI, without
* noticing a difference.
*
* @ORM\Entity
*
* @ORM\Table(name="chill_3party.third_party")
*
* @DiscriminatorMap(typeProperty="type", mapping={
* "thirdparty": ThirdParty::class
* })
*/
#[ORM\Entity]
#[ORM\Table(name: "chill_3party.third_party")]
#[DiscriminatorMap(typeProperty: "type", mapping: ["thirdparty" => ThirdParty::class])]
class ThirdParty implements TrackCreationInterface, TrackUpdateInterface, \Stringable
{
final public const KIND_CHILD = 'child';
@@ -90,199 +85,161 @@ class ThirdParty implements TrackCreationInterface, TrackUpdateInterface, \Strin
/**
* [fr] Sigle.
*
* @ORM\Column(name="acronym", type="string", length=64, nullable=true)
*/
#[Assert\Length(min: 2)]
#[Groups(['read', 'write', 'docgen:read', 'docgen:read:3party:parent'])]
#[ORM\Column(name: 'acronym', type: \Doctrine\DBAL\Types\Types::STRING, length: 64, nullable: true)]
private ?string $acronym = '';
/**
* Soft-delete flag.
*
* @ORM\Column(name="active", type="boolean", options={"defaut": true})
*/
#[ORM\Column(name: 'active', type: \Doctrine\DBAL\Types\Types::BOOLEAN, options: ['defaut' => true])]
private bool $active = true;
/**
* @ORM\ManyToOne(targetEntity="\Chill\MainBundle\Entity\Address",
* cascade={"persist", "remove"})
*
* @ORM\JoinColumn(nullable=true, onDelete="SET NULL")
*
* @Context(normalizationContext={"groups": "docgen:read"}, groups={"docgen:read:3party:parent"})
*/
#[Groups(['read', 'write', 'docgen:read', 'docgen:read:3party:parent'])]
#[ORM\ManyToOne(targetEntity: Address::class, cascade: ['persist', 'remove'])]
#[ORM\JoinColumn(nullable: true, onDelete: 'SET NULL')]
private ?Address $address = null;
/**
* Canonicalized form composed of name, company name and acronym.
*
* This field is read-only, and is generated on database side.
*
* @ORM\Column(name="canonicalized", type="text", options={"default": ""})
*/
#[ORM\Column(name: 'canonicalized', type: \Doctrine\DBAL\Types\Types::TEXT, options: ['default' => ''])]
private ?string $canonicalized = '';
/**
* @var Collection<ThirdPartyCategory>
*
* @ORM\ManyToMany(targetEntity="Chill\ThirdPartyBundle\Entity\ThirdPartyCategory")
*
* @ORM\JoinTable(name="chill_3party.thirdparty_category",
* joinColumns={@ORM\JoinColumn(name="thirdparty_id", referencedColumnName="id")},
* inverseJoinColumns={@ORM\JoinColumn(name="category_id", referencedColumnName="id")})
*
* @Context(normalizationContext={"groups": "docgen:read"}, groups={"docgen:read:3party:parent"})
*/
#[Groups(['docgen:read', 'docgen:read:3party:parent'])]
#[ORM\ManyToMany(targetEntity: \Chill\ThirdPartyBundle\Entity\ThirdPartyCategory::class)]
#[ORM\JoinTable(name: 'chill_3party.thirdparty_category', joinColumns: [new ORM\JoinColumn(name: 'thirdparty_id', referencedColumnName: 'id')], inverseJoinColumns: [new ORM\JoinColumn(name: 'category_id', referencedColumnName: 'id')])]
private Collection $categories;
/**
* @var Collection<Center>
*
* @ORM\ManyToMany(targetEntity="\Chill\MainBundle\Entity\Center")
*
* @ORM\JoinTable(name="chill_3party.party_center")
*/
#[ORM\ManyToMany(targetEntity: Center::class)]
#[ORM\JoinTable(name: 'chill_3party.party_center')]
private Collection $centers;
/**
* Contact Persons: One Institutional ThirdParty has Many Contact Persons.
*
* @ORM\OneToMany(targetEntity="Chill\ThirdPartyBundle\Entity\ThirdParty", mappedBy="parent",
* cascade={"persist"}, orphanRemoval=true)
*
* @var Collection<ThirdParty>
*/
#[Assert\Valid(traverse: true)]
#[ORM\OneToMany(targetEntity: ThirdParty::class, mappedBy: 'parent', cascade: ['persist'], orphanRemoval: true)]
private Collection $children;
/**
* @ORM\ManyToOne(targetEntity=Civility::class)
* ORM\JoinColumn(name="civility", referencedColumnName="id", nullable=true)
*
* @Context(normalizationContext={"groups": "docgen:read"}, groups={"docgen:read:3party:parent"})
*/
#[Context(normalizationContext: ["groups" => "docgen:read"], groups: ['docgen:read:3party:parent'])]
#[Groups(['read', 'write', 'docgen:read', 'docgen:read:3party:parent'])]
#[ORM\ManyToOne(targetEntity: Civility::class)] // ORM\JoinColumn(name="civility", referencedColumnName="id", nullable=true)
private ?Civility $civility = null;
/**
* @ORM\Column(name="comment", type="text", nullable=true)
*/
#[Groups(['read', 'write'])]
#[ORM\Column(name: 'comment', type: \Doctrine\DBAL\Types\Types::TEXT, nullable: true)]
private ?string $comment = null;
/**
* @ORM\Column(name="contact_data_anonymous", type="boolean", options={"default": false})
*/
#[Groups(['read', 'docgen:read', 'docgen:read:3party:parent'])]
#[ORM\Column(name: 'contact_data_anonymous', type: \Doctrine\DBAL\Types\Types::BOOLEAN, options: ['default' => false])]
private bool $contactDataAnonymous = false;
/**
* @ORM\Column(name="created_at", type="datetime_immutable", nullable=false)
*/
#[ORM\Column(name: 'created_at', type: \Doctrine\DBAL\Types\Types::DATETIME_IMMUTABLE, nullable: false)]
private \DateTimeImmutable $createdAt;
/**
* @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\User")
*
* @ORM\JoinColumn(name="created_by", referencedColumnName="id")
*/
#[ORM\ManyToOne(targetEntity: \Chill\MainBundle\Entity\User::class)]
#[ORM\JoinColumn(name: 'created_by', referencedColumnName: 'id')]
private ?User $createdBy = null;
/**
* @ORM\Column(name="email", type="string", length=255, nullable=true)
*/
#[Assert\Email]
#[Groups(['read', 'write', 'docgen:read', 'docgen:read:3party:parent'])]
#[ORM\Column(name: 'email', type: \Doctrine\DBAL\Types\Types::STRING, length: 255, nullable: true)]
private ?string $email = null;
/**
* @ORM\Column(name="firstname", type="text", options={"default": ""})
*/
#[Groups(['read', 'write', 'docgen:read', 'docgen:read:3party:parent'])]
#[ORM\Column(name: 'firstname', type: \Doctrine\DBAL\Types\Types::TEXT, options: ['default' => ''])]
private ?string $firstname = '';
/**
* @ORM\Column(name="id", type="integer")
*
* @ORM\Id
*
* @ORM\GeneratedValue(strategy="AUTO")
*/
#[Groups(['read', 'docgen:read', 'docgen:read:3party:parent'])]
#[ORM\Column(name: 'id', type: \Doctrine\DBAL\Types\Types::INTEGER)]
#[ORM\Id]
#[ORM\GeneratedValue(strategy: 'AUTO')]
private ?int $id = null;
/**
* @ORM\Column(name="kind", type="string", length="20", options={"default": ""})
*/
#[Groups(['write', 'docgen:read', 'docgen:read:3party:parent'])]
#[ORM\Column(name: 'kind', type: \Doctrine\DBAL\Types\Types::STRING, length: 20, options: ['default' => ''])]
private string $kind = '';
/**
* @ORM\Column(name="name", type="string", length=255)
*/
#[Assert\Length(min: 2)]
#[Assert\NotNull]
#[Assert\NotBlank]
#[Groups(['read', 'write', 'docgen:read', 'docgen:read:3party:parent'])]
#[ORM\Column(name: 'name', type: \Doctrine\DBAL\Types\Types::STRING, length: 255)]
private string $name = '';
/**
* [fr] Raison sociale.
*
* @ORM\Column(name="name_company", type="string", length=255, nullable=true)
*/
#[Assert\Length(min: 3)]
#[Groups(['read', 'write', 'docgen:read', 'docgen:read:3party:parent'])]
#[ORM\Column(name: 'name_company', type: \Doctrine\DBAL\Types\Types::STRING, length: 255, nullable: true)]
private ?string $nameCompany = '';
/**
* Institutional ThirdParty: Many Contact Persons have One Institutional ThirdParty.
*
* @ORM\ManyToOne(targetEntity="Chill\ThirdPartyBundle\Entity\ThirdParty", inversedBy="children")
*
* @ORM\JoinColumn(name="parent_id", referencedColumnName="id")
*
* @Context(normalizationContext={"groups": "docgen:read:3party:parent"}, groups={"docgen:read"})
*/
#[Groups(['read', 'write', 'docgen:read'])]
#[ORM\ManyToOne(targetEntity: ThirdParty::class, inversedBy: 'children')]
#[ORM\JoinColumn(name: 'parent_id', referencedColumnName: 'id')]
private ?ThirdParty $parent = null;
/**
* [fr] Qualité.
*
* @ORM\Column(name="profession", type="text", nullable=false)
*
* @Context(normalizationContext={"groups": "docgen:read"}, groups={"docgen:read:3party:parent"})
*/
#[Groups(['read', 'write', 'docgen:read', 'docgen:read:3party:parent'])]
#[ORM\Column(name: 'profession', type: \Doctrine\DBAL\Types\Types::TEXT, nullable: false)]
private string $profession = '';
/**
* @ORM\Column(name="telephone", type="phone_number", nullable=true)
*
* @PhonenumberConstraint(type="any")
*/
#[Groups(['read', 'write', 'docgen:read', 'docgen:read:3party:parent'])]
#[ORM\Column(name: 'telephone', type: 'phone_number', nullable: true)]
private ?PhoneNumber $telephone = null;
/**
* @ORM\Column(name="types", type="json", nullable=true)
*/
#[ORM\Column(name: 'types', type: \Doctrine\DBAL\Types\Types::JSON, nullable: true)]
private ?array $thirdPartyTypes = [];
/**
* @ORM\Column(name="updated_at", type="datetime_immutable", nullable=true)
*/
#[ORM\Column(name: 'updated_at', type: \Doctrine\DBAL\Types\Types::DATETIME_IMMUTABLE, nullable: true)]
private ?\DateTimeImmutable $updatedAt = null;
/**
* @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\User")
*
* @ORM\JoinColumn(name="updated_by", referencedColumnName="id")
*/
#[ORM\ManyToOne(targetEntity: \Chill\MainBundle\Entity\User::class)]
#[ORM\JoinColumn(name: 'updated_by', referencedColumnName: 'id')]
private ?User $updatedBy = null;
/**

View File

@@ -15,32 +15,23 @@ use Chill\ThirdPartyBundle\Repository\ThirdPartyCategoryRepository;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation as Serializer;
/**
* @ORM\Table(name="chill_3party.party_category")
*
* @ORM\Entity(repositoryClass=ThirdPartyCategoryRepository::class)
*/
#[ORM\Entity(repositoryClass: ThirdPartyCategoryRepository::class)]
#[ORM\Table(name: 'chill_3party.party_category')]
class ThirdPartyCategory
{
/**
* @ORM\Column(type="boolean")
*/
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::BOOLEAN)]
private bool $active = true;
/**
* @ORM\Id
*
* @ORM\GeneratedValue
*
* @ORM\Column(type="integer")
*/
#[Serializer\Groups(['docgen:read'])]
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::INTEGER)]
private ?int $id = null;
/**
* @ORM\Column(type="json")
*/
#[Serializer\Groups(['docgen:read'])]
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::JSON)]
private array $name = [];
public function getActive(): ?bool

View File

@@ -15,34 +15,25 @@ use Chill\ThirdPartyBundle\Repository\ThirdPartyProfessionRepository;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation as Serializer;
/**
* @ORM\Table(name="chill_3party.party_profession")
*
* @ORM\Entity(repositoryClass=ThirdPartyProfessionRepository::class)
*/
#[Serializer\DiscriminatorMap(typeProperty: 'type', mapping: ['third_party_profession' => ThirdPartyProfession::class])]
#[ORM\Entity(repositoryClass: ThirdPartyProfessionRepository::class)]
#[ORM\Table(name: 'chill_3party.party_profession')]
class ThirdPartyProfession
{
/**
* @ORM\Column(type="boolean")
*/
#[Serializer\Groups(['read'])]
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::BOOLEAN)]
private bool $active = true;
/**
* @ORM\Id
*
* @ORM\GeneratedValue
*
* @ORM\Column(type="integer")
*/
#[Serializer\Groups(['docgen:read', 'read', 'write'])]
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::INTEGER)]
private ?int $id = null;
/**
* @ORM\Column(type="json")
*/
#[Serializer\Groups(['docgen:read', 'read'])]
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::JSON)]
private array $name = [];
public function getActive(): ?bool