mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-20 14:43:49 +00:00
Apply rector rules: add annotation for doctrine mapping
This commit is contained in:
@@ -20,52 +20,33 @@ use Symfony\Component\Validator\Constraints as Assert;
|
||||
|
||||
/**
|
||||
* AbstractElement.
|
||||
*
|
||||
* @ORM\MappedSuperclass
|
||||
*/
|
||||
#[ORM\MappedSuperclass]
|
||||
abstract class AbstractElement
|
||||
{
|
||||
/**
|
||||
* @ORM\Column(name="amount", type="decimal", precision=10, scale=2)
|
||||
*/
|
||||
#[Assert\GreaterThan(value: 0)]
|
||||
#[Assert\NotNull(message: 'The amount cannot be empty')]
|
||||
#[ORM\Column(name: 'amount', type: \Doctrine\DBAL\Types\Types::DECIMAL, precision: 10, scale: 2)]
|
||||
private string $amount;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="comment", type="text", nullable=true)
|
||||
*/
|
||||
#[ORM\Column(name: 'comment', type: \Doctrine\DBAL\Types\Types::TEXT, nullable: true)]
|
||||
private ?string $comment = null;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="endDate", type="datetime_immutable", nullable=true)
|
||||
*/
|
||||
#[Assert\GreaterThan(propertyPath: 'startDate', message: "The budget element's end date must be after the start date")]
|
||||
#[ORM\Column(name: 'endDate', type: \Doctrine\DBAL\Types\Types::DATETIME_IMMUTABLE, nullable: true)]
|
||||
private ?\DateTimeImmutable $endDate = null;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(
|
||||
* targetEntity="\Chill\PersonBundle\Entity\Household\Household"
|
||||
* )
|
||||
*/
|
||||
#[ORM\ManyToOne(targetEntity: Household::class)]
|
||||
private ?Household $household = null;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(
|
||||
* targetEntity="\Chill\PersonBundle\Entity\Person"
|
||||
* )
|
||||
*/
|
||||
#[ORM\ManyToOne(targetEntity: Person::class)]
|
||||
private ?Person $person = null;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="startDate", type="datetime_immutable")
|
||||
*/
|
||||
#[Assert\Date]
|
||||
#[ORM\Column(name: 'startDate', type: \Doctrine\DBAL\Types\Types::DATETIME_IMMUTABLE)]
|
||||
private \DateTimeImmutable $startDate;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="type", type="string", length=255)
|
||||
*/
|
||||
#[ORM\Column(name: 'type', type: \Doctrine\DBAL\Types\Types::STRING, length: 255)]
|
||||
private string $type = '';
|
||||
|
||||
/* Getters and Setters */
|
||||
|
@@ -18,10 +18,10 @@ use Doctrine\ORM\Mapping as ORM;
|
||||
/**
|
||||
* Charge.
|
||||
*
|
||||
* @ORM\Table(name="chill_budget.charge")
|
||||
*
|
||||
* @ORM\Entity(repositoryClass="Chill\BudgetBundle\Repository\ChargeRepository")
|
||||
*/
|
||||
#[ORM\Entity(repositoryClass: \Chill\BudgetBundle\Repository\ChargeRepository::class)]
|
||||
#[ORM\Table(name: 'chill_budget.charge')]
|
||||
class Charge extends AbstractElement implements HasCentersInterface
|
||||
{
|
||||
final public const HELP_ASKED = 'running';
|
||||
@@ -39,25 +39,18 @@ class Charge extends AbstractElement implements HasCentersInterface
|
||||
self::HELP_NOT_RELEVANT,
|
||||
];
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity=ChargeKind::class, inversedBy="AbstractElement")
|
||||
*
|
||||
* @ORM\JoinColumn
|
||||
*/
|
||||
|
||||
#[ORM\ManyToOne(targetEntity: ChargeKind::class, inversedBy: 'AbstractElement')]
|
||||
#[ORM\JoinColumn]
|
||||
private ?ChargeKind $charge = null;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="help", type="string", nullable=true)
|
||||
*/
|
||||
#[ORM\Column(name: 'help', type: \Doctrine\DBAL\Types\Types::STRING, nullable: true)]
|
||||
private ?string $help = self::HELP_NOT_RELEVANT;
|
||||
|
||||
/**
|
||||
* @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;
|
||||
|
||||
public function __construct()
|
||||
|
@@ -18,49 +18,35 @@ use Symfony\Component\Validator\Constraints as Assert;
|
||||
/**
|
||||
* Type of charge.
|
||||
*
|
||||
* @ORM\Table(name="chill_budget.charge_type",
|
||||
* uniqueConstraints={@ORM\UniqueConstraint(name="charge_kind_unique_type_idx", fields={"kind"})}
|
||||
* )
|
||||
*
|
||||
* @ORM\Entity
|
||||
*/
|
||||
#[UniqueEntity(fields: ['kind'])]
|
||||
#[ORM\Entity]
|
||||
#[ORM\Table(name: 'chill_budget.charge_type')]
|
||||
#[ORM\UniqueConstraint(name: 'charge_kind_unique_type_idx', fields: ['kind'])]
|
||||
class ChargeKind
|
||||
{
|
||||
/**
|
||||
* @ORM\Id
|
||||
*
|
||||
* @ORM\GeneratedValue
|
||||
*
|
||||
* @ORM\Column(type="integer")
|
||||
*/
|
||||
|
||||
#[ORM\Id]
|
||||
#[ORM\GeneratedValue]
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::INTEGER)]
|
||||
private ?int $id = null;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="boolean", options={"default": true})
|
||||
*/
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::BOOLEAN, options: ['default' => true])]
|
||||
private bool $isActive = true;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="string", length=255, options={"default": ""}, nullable=false)
|
||||
*/
|
||||
#[Assert\Regex(pattern: '/^[a-z0-9\-_]{1,}$/', message: 'budget.admin.form.kind.only_alphanumeric')]
|
||||
#[Assert\Length(min: 3)]
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::STRING, length: 255, options: ['default' => ''], nullable: false)]
|
||||
private string $kind = '';
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="json", length=255, options={"default": "[]"})
|
||||
*/
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::JSON, length: 255, options: ['default' => '[]'])]
|
||||
private array $name = [];
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="float", options={"default": 0.00})
|
||||
*/
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::FLOAT, options: ['default' => '0.00'])]
|
||||
private float $ordering = 0.00;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="json", length=255, options={"default": "[]"})
|
||||
*/
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::JSON, length: 255, options: ['default' => '[]'])]
|
||||
private array $tags = [];
|
||||
|
||||
public function getId(): ?int
|
||||
|
@@ -18,26 +18,21 @@ use Doctrine\ORM\Mapping as ORM;
|
||||
/**
|
||||
* Resource.
|
||||
*
|
||||
* @ORM\Table(name="chill_budget.resource")
|
||||
*
|
||||
* @ORM\Entity(repositoryClass="Chill\BudgetBundle\Repository\ResourceRepository")
|
||||
*/
|
||||
#[ORM\Entity(repositoryClass: \Chill\BudgetBundle\Repository\ResourceRepository::class)]
|
||||
#[ORM\Table(name: 'chill_budget.resource')]
|
||||
class Resource extends AbstractElement implements HasCentersInterface
|
||||
{
|
||||
/**
|
||||
* @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=ResourceKind::class, inversedBy="AbstractElement")
|
||||
*
|
||||
* @ORM\JoinColumn
|
||||
*/
|
||||
|
||||
#[ORM\ManyToOne(targetEntity: ResourceKind::class, inversedBy: 'AbstractElement')]
|
||||
#[ORM\JoinColumn]
|
||||
private ?ResourceKind $resource = null;
|
||||
|
||||
public function __construct()
|
||||
|
@@ -18,52 +18,37 @@ use Symfony\Component\Validator\Constraints as Assert;
|
||||
/**
|
||||
* Type of resource.
|
||||
*
|
||||
* @ORM\Table(name="chill_budget.resource_type", uniqueConstraints={
|
||||
*
|
||||
* @ORM\UniqueConstraint(name="resource_kind_unique_type_idx", fields={"kind"})
|
||||
* })
|
||||
* @ORM\UniqueConstraint(name="resource_kind_unique_type_idx", fields={"kind"})
|
||||
* })
|
||||
*
|
||||
* @ORM\Entity
|
||||
*/
|
||||
#[UniqueEntity(fields: ['kind'])]
|
||||
#[ORM\UniqueConstraint(name: 'resource_kind_unique_type_idx', fields: ['kind'])] // @ORM\Entity
|
||||
#[ORM\Table(name: 'chill_budget.resource_type')]
|
||||
#[ORM\UniqueConstraint(name: 'resource_kind_unique_type_idx', fields: ['kind'])]
|
||||
#[ORM\UniqueConstraint(name: 'resource_kind_unique_type_idx', fields: ['kind'])]
|
||||
#[ORM\Entity] // @ORM\Entity
|
||||
class ResourceKind
|
||||
{
|
||||
/**
|
||||
* @ORM\Id
|
||||
*
|
||||
* @ORM\GeneratedValue
|
||||
*
|
||||
* @ORM\Column(type="integer")
|
||||
*/
|
||||
|
||||
#[ORM\Id]
|
||||
#[ORM\GeneratedValue]
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::INTEGER)]
|
||||
private ?int $id = null;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="boolean", options={"default": true})
|
||||
*/
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::BOOLEAN, options: ['default' => true])]
|
||||
private bool $isActive = true;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="string", length=255, nullable=false, options={"default": ""})
|
||||
*/
|
||||
#[Assert\Regex(pattern: '/^[a-z0-9\-_]{1,}$/', message: 'budget.admin.form.kind.only_alphanumeric')]
|
||||
#[Assert\Length(min: 3)]
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::STRING, length: 255, nullable: false, options: ['default' => ''])]
|
||||
private string $kind = '';
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="json", length=255, options={"default": "[]"})
|
||||
*/
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::JSON, length: 255, options: ['default' => '[]'])]
|
||||
private array $name = [];
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="float", options={"default": 0.00})
|
||||
*/
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::FLOAT, options: ['default' => '0.00'])]
|
||||
private float $ordering = 0.00;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="json", length=255, options={"default": "[]"})
|
||||
*/
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::JSON, length: 255, options: ['default' => '[]'])]
|
||||
private array $tags = [];
|
||||
|
||||
public function getId(): ?int
|
||||
|
Reference in New Issue
Block a user