apply more cs rules for php-cs

This commit is contained in:
2023-10-17 13:27:03 +02:00
parent 0b0cbed9db
commit bc2041cbdd
1485 changed files with 8169 additions and 9620 deletions

View File

@@ -18,7 +18,6 @@ use Chill\MainBundle\Doctrine\Model\TrackUpdateInterface;
use Chill\MainBundle\Doctrine\Model\TrackUpdateTrait;
use Chill\ThirdPartyBundle\Entity\ThirdParty;
use DateTime;
use DateTimeInterface;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
@@ -29,7 +28,9 @@ use Symfony\Component\Validator\Context\ExecutionContextInterface;
* Address.
*
* @ORM\Entity
*
* @ORM\Table(name="chill_main_address")
*
* @ORM\HasLifecycleCallbacks
*/
class Address implements TrackCreationInterface, TrackUpdateInterface
@@ -38,68 +39,76 @@ class Address implements TrackCreationInterface, TrackUpdateInterface
use TrackUpdateTrait;
/**
* When an Address does match with the AddressReference
* When an Address does match with the AddressReference.
*/
final public const ADDR_REFERENCE_STATUS_MATCH = 'match';
/**
* When an Address does not match with the AddressReference, and
* is pending for a review
* is pending for a review.
*/
final public const ADDR_REFERENCE_STATUS_TO_REVIEW = 'to_review';
/**
* When an Address does not match with the AddressReference, but
* is reviewed
* is reviewed.
*/
final public const ADDR_REFERENCE_STATUS_REVIEWED = 'reviewed';
/**
* @ORM\ManyToOne(targetEntity=AddressReference::class)
*
* @Groups({"write"})
*/
private ?AddressReference $addressReference = null;
/**
* @ORM\Column(type="text", nullable=false, options={"default": ""})
*
* @Groups({"write"})
*/
private string $buildingName = '';
/**
* @ORM\Column(type="boolean", options={"default": false})
*
* @Groups({"write"})
*/
private bool $confidential = false;
/**
* @ORM\Column(type="text", nullable=false, options={"default": ""})
*
* @Groups({"write"})
*/
private string $corridor = '';
/**
* used for the CEDEX information
* used for the CEDEX information.
*
* @ORM\Column(type="text", nullable=false, options={"default": ""})
*
* @Groups({"write"})
*/
private string $distribution = '';
/**
* @ORM\Column(type="text", nullable=false, options={"default": ""})
*
* @Groups({"write"})
*/
private string $extra = '';
/**
* @ORM\Column(type="text", nullable=false, options={"default": ""})
*
* @Groups({"write"})
*/
private string $flat = '';
/**
* @ORM\Column(type="text", nullable=false, options={"default": ""})
*
* @Groups({"write"})
*/
private string $floor = '';
@@ -111,8 +120,11 @@ class Address implements TrackCreationInterface, TrackUpdateInterface
* on the materialized view.
*
* @var Collection<GeographicalUnit>
*
* @readonly
*
* @ORM\ManyToMany(targetEntity=GeographicalUnit::class)
*
* @ORM\JoinTable(
* name="view_chill_main_address_geographical_unit",
* joinColumns={@ORM\JoinColumn(name="address_id")},
@@ -122,12 +134,14 @@ class Address implements TrackCreationInterface, TrackUpdateInterface
private Collection $geographicalUnits;
/**
* @var int
*
* @ORM\Id
*
* @ORM\Column(name="id", type="integer")
*
* @ORM\GeneratedValue(strategy="AUTO")
*
* @Groups({"write"})
*
* @readonly
*/
private ?int $id = null;
@@ -136,6 +150,7 @@ class Address implements TrackCreationInterface, TrackUpdateInterface
* True if the address is a "no address", aka homeless person, ...
*
* @Groups({"write"})
*
* @ORM\Column(type="boolean", options={"default": false})
*/
private bool $isNoAddress = false;
@@ -143,10 +158,10 @@ class Address implements TrackCreationInterface, TrackUpdateInterface
/**
* A ThirdParty reference for person's addresses that are linked to a third party.
*
* @var ThirdParty|null
*
* @ORM\ManyToOne(targetEntity="Chill\ThirdPartyBundle\Entity\ThirdParty")
*
* @Groups({"write"})
*
* @ORM\JoinColumn(nullable=true, onDelete="SET NULL")
*/
private ?ThirdParty $linkedToThirdParty = null;
@@ -154,22 +169,24 @@ class Address implements TrackCreationInterface, TrackUpdateInterface
/**
* A geospatial field storing the coordinates of the Address.
*
* @var Point|null
*
* @ORM\Column(type="point", nullable=true)
*
* @Groups({"write"})
*/
private ?Point $point = null;
/**
* @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\PostalCode")
*
* @ORM\JoinColumn(nullable=false)
*
* @Groups({"write"})
*/
private ?PostalCode $postcode = null;
/**
* @var self::ADDR_REFERENCE_STATUS_*
*
* @ORM\Column(type="text", nullable=false, options={"default": self::ADDR_REFERENCE_STATUS_MATCH})
*/
private string $refStatus = self::ADDR_REFERENCE_STATUS_MATCH;
@@ -180,22 +197,22 @@ class Address implements TrackCreationInterface, TrackUpdateInterface
private \DateTimeImmutable $refStatusLastUpdate;
/**
*
* @ORM\Column(type="text", nullable=false, options={"default": ""})
*
* @Groups({"write"})
*/
private string $steps = '';
/**
*
* @ORM\Column(type="text", nullable=false, options={"default": ""})
*
* @Groups({"write"})
*/
private string $street = '';
/**
*
* @ORM\Column(type="text", nullable=false, options={"default": ""})
*
* @Groups({"write"})
*/
private string $streetNumber = '';
@@ -205,22 +222,24 @@ class Address implements TrackCreationInterface, TrackUpdateInterface
* of address. By default, the current date.
*
* @ORM\Column(type="date")
*
* @Groups({"write"})
*/
private DateTime $validFrom;
private \DateTime $validFrom;
/**
* Indicates when the address ends. Used to build an history
* of address.
*
* @ORM\Column(type="date", nullable=true)
*
* @Groups({"write"})
*/
private ?DateTime $validTo = null;
private ?\DateTime $validTo = null;
public function __construct()
{
$this->validFrom = new DateTime();
$this->validFrom = new \DateTime();
$this->refStatusLastUpdate = new \DateTimeImmutable('now');
$this->geographicalUnits = new ArrayCollection();
}
@@ -376,6 +395,7 @@ class Address implements TrackCreationInterface, TrackUpdateInterface
* Get streetAddress1 (legacy function).
*
* @return string
*
* @deprecated
*/
public function getStreetAddress1()
@@ -387,6 +407,7 @@ class Address implements TrackCreationInterface, TrackUpdateInterface
* Get streetAddress2 (legacy function).
*
* @return string
*
* @deprecated
*/
public function getStreetAddress2()
@@ -399,12 +420,12 @@ class Address implements TrackCreationInterface, TrackUpdateInterface
return $this->streetNumber;
}
public function getValidFrom(): DateTime
public function getValidFrom(): \DateTime
{
return $this->validFrom;
}
public function getValidTo(): ?DateTimeInterface
public function getValidTo(): ?\DateTimeInterface
{
return $this->validTo;
}
@@ -419,7 +440,7 @@ class Address implements TrackCreationInterface, TrackUpdateInterface
return $this->getIsNoAddress();
}
public function setAddressReference(?AddressReference $addressReference = null): Address
public function setAddressReference(AddressReference $addressReference = null): Address
{
$this->addressReference = $addressReference;
@@ -506,11 +527,9 @@ class Address implements TrackCreationInterface, TrackUpdateInterface
/**
* Set postcode.
*
* @param PostalCode $postcode
*
* @return Address
*/
public function setPostcode(?PostalCode $postcode = null)
public function setPostcode(PostalCode $postcode = null)
{
$this->postcode = $postcode;
@@ -518,14 +537,15 @@ class Address implements TrackCreationInterface, TrackUpdateInterface
}
/**
* Update the ref status
* Update the ref status.
*
* <<<<<<< HEAD
*
* @param Address::ADDR_REFERENCE_STATUS_* $refStatus
* @param bool|null $updateLastUpdate Also update the "refStatusLastUpdate"
* =======
* The refstatuslast update is also updated
* >>>>>>> 31152616d (Feature: Provide api endpoint for reviewing addresses)
* @param bool|null $updateLastUpdate Also update the "refStatusLastUpdate"
* =======
* The refstatuslast update is also updated
* >>>>>>> 31152616d (Feature: Provide api endpoint for reviewing addresses)
*/
public function setRefStatus(string $refStatus, ?bool $updateLastUpdate = true): self
{
@@ -562,8 +582,6 @@ class Address implements TrackCreationInterface, TrackUpdateInterface
/**
* Set streetAddress1 (legacy function).
*
* @param string $streetAddress1
*
* @deprecated
*/
public function setStreetAddress1(?string $streetAddress1): self
@@ -576,7 +594,6 @@ class Address implements TrackCreationInterface, TrackUpdateInterface
/**
* Set streetAddress2 (legacy function).
*
* @param string $streetAddress2
* @deprecated
*/
public function setStreetAddress2(?string $streetAddress2): self
@@ -596,14 +613,14 @@ class Address implements TrackCreationInterface, TrackUpdateInterface
/**
* @return Address
*/
public function setValidFrom(DateTime $validFrom)
public function setValidFrom(\DateTime $validFrom)
{
$this->validFrom = $validFrom;
return $this;
}
public function setValidTo(?DateTimeInterface $validTo = null): self
public function setValidTo(\DateTimeInterface $validTo = null): self
{
$this->validTo = $validTo;
@@ -624,7 +641,7 @@ class Address implements TrackCreationInterface, TrackUpdateInterface
*/
public function validate(ExecutionContextInterface $context, $payload)
{
if (!$this->getValidFrom() instanceof DateTime) {
if (!$this->getValidFrom() instanceof \DateTime) {
$context
->buildViolation('address.date-should-be-set')
->atPath('validFrom')

View File

@@ -12,18 +12,21 @@ declare(strict_types=1);
namespace Chill\MainBundle\Entity;
use Chill\MainBundle\Doctrine\Model\Point;
use DateTimeImmutable;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation\Groups;
/**
* @ORM\Entity
*
* @ORM\Table(name="chill_main_address_reference", indexes={
*
* @ORM\Index(name="address_refid", columns={"refId"})
* },
* uniqueConstraints={
*
* @ORM\UniqueConstraint(name="chill_main_address_reference_unicity", columns={"refId", "source"})
* })
*
* @ORM\HasLifecycleCallbacks
*/
class AddressReference
@@ -39,26 +42,32 @@ class AddressReference
/**
* @ORM\Column(type="datetime_immutable", nullable=true)
*
* @groups({"read"})
*/
private ?DateTimeImmutable $createdAt = null;
private ?\DateTimeImmutable $createdAt = null;
/**
* @ORM\Column(type="datetime_immutable", nullable=true)
*
* @groups({"read"})
*/
private ?DateTimeImmutable $deletedAt = null;
private ?\DateTimeImmutable $deletedAt = null;
/**
* @ORM\Id
*
* @ORM\GeneratedValue
*
* @ORM\Column(type="integer")
*
* @groups({"read"})
*/
private ?int $id = null;
/**
* @ORM\Column(type="text", nullable=false, options={"default": ""})
*
* @groups({"read"})
*/
private string $municipalityCode = '';
@@ -66,57 +75,60 @@ class AddressReference
/**
* A geospatial field storing the coordinates of the Address.
*
* @var Point
*
* @ORM\Column(type="point")
*
* @groups({"read"})
*/
private ?Point $point = null;
/**
* @var PostalCode
*
* @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\PostalCode")
*
* @groups({"read"})
*/
private ?PostalCode $postcode = null;
/**
* @ORM\Column(type="text", nullable=false, options={"default": ""})
*
* @groups({"read"})
*/
private string $refId = '';
/**
* @ORM\Column(type="text", nullable=false, options={"default": ""})
*
* @groups({"read"})
*/
private string $source = '';
/**
* @ORM\Column(type="text", nullable=false, options={"default": ""})
*
* @groups({"read"})
*/
private string $street = '';
/**
* @ORM\Column(type="text", nullable=false, options={"default": ""})
*
* @groups({"read"})
*/
private string $streetNumber = '';
/**
* @ORM\Column(type="datetime_immutable", nullable=true)
*
* @groups({"read"})
*/
private ?DateTimeImmutable $updatedAt = null;
private ?\DateTimeImmutable $updatedAt = null;
public function getCreatedAt(): ?DateTimeImmutable
public function getCreatedAt(): ?\DateTimeImmutable
{
return $this->createdAt;
}
public function getDeletedAt(): ?DateTimeImmutable
public function getDeletedAt(): ?\DateTimeImmutable
{
return $this->deletedAt;
}
@@ -138,8 +150,6 @@ class AddressReference
/**
* Get postcode.
*
* @return PostalCode
*/
public function getPostcode(): ?PostalCode
{
@@ -166,7 +176,7 @@ class AddressReference
return $this->streetNumber;
}
public function getUpdatedAt(): ?DateTimeImmutable
public function getUpdatedAt(): ?\DateTimeImmutable
{
return $this->updatedAt;
}
@@ -176,14 +186,14 @@ class AddressReference
return null !== $this->getPoint();
}
public function setCreatedAt(?DateTimeImmutable $createdAt): self
public function setCreatedAt(?\DateTimeImmutable $createdAt): self
{
$this->createdAt = $createdAt;
return $this;
}
public function setDeletedAt(?DateTimeImmutable $deletedAt): self
public function setDeletedAt(?\DateTimeImmutable $deletedAt): self
{
$this->deletedAt = $deletedAt;
@@ -207,11 +217,9 @@ class AddressReference
/**
* Set postcode.
*
* @param PostalCode $postcode
*
* @return Address
*/
public function setPostcode(?PostalCode $postcode = null)
public function setPostcode(PostalCode $postcode = null)
{
$this->postcode = $postcode;
@@ -246,7 +254,7 @@ class AddressReference
return $this;
}
public function setUpdatedAt(?DateTimeImmutable $updatedAt): self
public function setUpdatedAt(?\DateTimeImmutable $updatedAt): self
{
$this->updatedAt = $updatedAt;

View File

@@ -18,6 +18,7 @@ use Symfony\Component\Serializer\Annotation as Serializer;
/**
* @ORM\Entity
*
* @ORM\Table(name="centers")
*/
class Center implements HasCenterInterface, \Stringable
@@ -33,17 +34,19 @@ class Center implements HasCenterInterface, \Stringable
private Collection $groupCenters;
/**
* @var int
*
* @ORM\Id
*
* @ORM\Column(name="id", type="integer")
*
* @ORM\GeneratedValue(strategy="AUTO")
*
* @Serializer\Groups({"docgen:read"})
*/
private ?int $id = null;
/**
* @ORM\Column(type="string", length=255)
*
* @Serializer\Groups({"docgen:read"})
*/
private string $name = '';
@@ -55,6 +58,7 @@ class Center implements HasCenterInterface, \Stringable
/**
* @var Collection<Regroupment>
*
* @ORM\ManyToMany(targetEntity=Regroupment::class, mappedBy="centers")
*/
private Collection $regroupments;
@@ -68,9 +72,6 @@ class Center implements HasCenterInterface, \Stringable
$this->regroupments = new ArrayCollection();
}
/**
* @return string
*/
public function __toString(): string
{
return $this->getName();
@@ -94,10 +95,7 @@ class Center implements HasCenterInterface, \Stringable
return $this;
}
/**
* @return ArrayCollection|Collection
*/
public function getGroupCenters(): \Doctrine\Common\Collections\ArrayCollection|\Doctrine\Common\Collections\Collection
public function getGroupCenters(): ArrayCollection|Collection
{
return $this->groupCenters;
}
@@ -132,8 +130,6 @@ class Center implements HasCenterInterface, \Stringable
}
/**
* @param $name
*
* @return $this
*/
public function setName($name)

View File

@@ -16,35 +16,45 @@ use Symfony\Component\Serializer\Annotation as Serializer;
/**
* @ORM\Table(name="chill_main_civility")
*
* @ORM\Entity
*
* @Serializer\DiscriminatorMap(typeProperty="type", mapping={"chill_main_civility": Civility::class})
*/
class Civility
{
/**
* @ORM\Column(type="json")
*
* @Serializer\Groups({"read", "docgen:read"})
*
* @Serializer\Context({"is-translatable": true}, groups={"docgen:read"})
*/
private array $abbreviation = [];
/**
* @ORM\Column(type="boolean")
*
* @Serializer\Groups({"read"})
*/
private bool $active = true;
/**
* @ORM\Id
*
* @ORM\GeneratedValue
*
* @ORM\Column(type="integer")
*
* @Serializer\Groups({"read", "docgen:read"})
*/
private ?int $id = null;
/**
* @ORM\Column(type="json")
*
* @Serializer\Groups({"read", "docgen:read"})
*
* @Serializer\Context({"is-translatable": true}, groups={"docgen:read"})
*/
private array $name = [];

View File

@@ -19,25 +19,31 @@ use Symfony\Component\Serializer\Annotation\Groups;
* Country.
*
* @ORM\Entity
*
* @ORM\Table(name="country")
*
* @ORM\Cache(usage="READ_ONLY", region="country_cache_region")
*
* @ORM\HasLifecycleCallbacks
*/
class Country
{
/**
* @ORM\Column(type="string", length=3)
*
* @groups({"read", "docgen:read"})
*
* @Context({"is-translatable": true}, groups={"docgen:read"})
*/
private string $countryCode = '';
/**
* @var int
*
* @ORM\Id
*
* @ORM\Column(name="id", type="integer")
*
* @ORM\GeneratedValue(strategy="AUTO")
*
* @groups({"read", "docgen:read"})
*/
private ?int $id = null;
@@ -46,7 +52,9 @@ class Country
* @var array<string, string>
*
* @ORM\Column(type="json")
*
* @groups({"read", "docgen:read"})
*
* @Context({"is-translatable": true}, groups={"docgen:read"})
*/
private array $name = [];
@@ -63,7 +71,6 @@ class Country
/**
* Get name.
*
*/
public function getName(): array
{

View File

@@ -11,11 +11,11 @@ declare(strict_types=1);
namespace Chill\MainBundle\Entity;
use DateTimeImmutable;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity
*
* @ORM\Table(name="chill_main_cronjob_execution")
*/
class CronJobExecution
@@ -27,12 +27,12 @@ class CronJobExecution
/**
* @ORM\Column(type="datetime_immutable", nullable=true, options={"default": null})
*/
private ?DateTimeImmutable $lastEnd = null;
private ?\DateTimeImmutable $lastEnd = null;
/**
* @ORM\Column(type="datetime_immutable", nullable=false)
*/
private DateTimeImmutable $lastStart;
private \DateTimeImmutable $lastStart;
/**
* @ORM\Column(type="integer", nullable=true, options={"default": null})
@@ -46,11 +46,12 @@ class CronJobExecution
public function __construct(/**
* @ORM\Column(type="text", nullable=false)
*
* @ORM\Id
*/
private string $key
) {
$this->lastStart = new DateTimeImmutable('now');
$this->lastStart = new \DateTimeImmutable('now');
}
public function getKey(): string
@@ -58,12 +59,12 @@ class CronJobExecution
return $this->key;
}
public function getLastEnd(): DateTimeImmutable
public function getLastEnd(): \DateTimeImmutable
{
return $this->lastEnd;
}
public function getLastStart(): DateTimeImmutable
public function getLastStart(): \DateTimeImmutable
{
return $this->lastStart;
}
@@ -73,14 +74,14 @@ class CronJobExecution
return $this->lastStatus;
}
public function setLastEnd(?DateTimeImmutable $lastEnd): CronJobExecution
public function setLastEnd(?\DateTimeImmutable $lastEnd): CronJobExecution
{
$this->lastEnd = $lastEnd;
return $this;
}
public function setLastStart(DateTimeImmutable $lastStart): CronJobExecution
public function setLastStart(\DateTimeImmutable $lastStart): CronJobExecution
{
$this->lastStart = $lastStart;

View File

@@ -32,7 +32,6 @@ class CommentEmbeddable
/**
* Embeddable does not support associations.
*
* @var int
* @ORM\Column(type="integer", nullable=true)
*/
private ?int $userId = null;
@@ -43,7 +42,7 @@ class CommentEmbeddable
}
/**
* @return DateTime
* @return \DateTime
*/
public function getDate()
{
@@ -65,10 +64,7 @@ class CommentEmbeddable
$this->comment = $comment;
}
/**
* @param DateTime $date
*/
public function setDate(?DateTime $date)
public function setDate(?\DateTime $date)
{
$this->date = $date;
}

View File

@@ -13,7 +13,6 @@ namespace Chill\MainBundle\Entity\Embeddable;
use Chill\MainBundle\Entity\User;
use Doctrine\ORM\Mapping as ORM;
use function array_key_exists;
/**
* @ORM\Embeddable
@@ -39,7 +38,7 @@ class PrivateCommentEmbeddable
public function hasCommentForUser(User $user): bool
{
return array_key_exists($user->getId(), $this->comments)
return \array_key_exists($user->getId(), $this->comments)
&& '' !== $this->comments[$user->getId()];
}

View File

@@ -15,8 +15,10 @@ use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Table(name="chill_main_geographical_unit", uniqueConstraints={
*
* @ORM\UniqueConstraint(name="geographical_unit_refid", columns={"layer_id", "unitRefId"})
* })
*
* @ORM\Entity(readOnly=true)
*/
class GeographicalUnit
@@ -28,7 +30,9 @@ class GeographicalUnit
/**
* @ORM\Id
*
* @ORM\GeneratedValue
*
* @ORM\Column(type="integer")
*/
private ?int $id = null;

View File

@@ -23,25 +23,33 @@ class SimpleGeographicalUnitDTO
public function __construct(
/**
* @readonly
*
* @psalm-readonly
*
* @Serializer\Groups({"read"})
*/
public int $id,
/**
* @readonly
*
* @psalm-readonly
*
* @Serializer\Groups({"read"})
*/
public string $unitName,
/**
* @readonly
*
* @psalm-readonly
*
* @Serializer\Groups({"read"})
*/
public string $unitRefId,
/**
* @readonly
*
* @psalm-readonly
*
* @Serializer\Groups({"read"})
*/
public int $layerId

View File

@@ -18,34 +18,42 @@ use Symfony\Component\Serializer\Annotation as Serializer;
/**
* @ORM\Table(name="chill_main_geographical_unit_layer", uniqueConstraints={
*
* @ORM\UniqueConstraint(name="geographical_unit_layer_refid", columns={"refId"})
* })
*
* @ORM\Entity
*/
class GeographicalUnitLayer
{
/**
* @ORM\Id
*
* @ORM\GeneratedValue
*
* @ORM\Column(type="integer")
*
* @Serializer\Groups({"read"})
*/
private ?int $id = null;
/**
* @ORM\Column(type="json", nullable=false, options={"default": "[]"})
*
* @Serializer\Groups({"read"})
*/
private array $name = [];
/**
* @ORM\Column(type="text", nullable=false, options={"default": ""})
*
* @Serializer\Groups({"read"})
*/
private string $refId = '';
/**
* @var Collection<GeographicalUnit>
*
* @ORM\OneToMany(targetEntity=GeographicalUnit::class, mappedBy="layer")
*/
private Collection $units;

View File

@@ -17,27 +17,28 @@ use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity
*
* @ORM\Table(name="group_centers")
*
* @ORM\Cache(usage="NONSTRICT_READ_WRITE", region="acl_cache_region")
*/
class GroupCenter
{
/**
* @var Center
*
* @ORM\ManyToOne(
* targetEntity="Chill\MainBundle\Entity\Center",
* inversedBy="groupCenters"
* )
*
* @ORM\Cache(usage="NONSTRICT_READ_WRITE")
*/
private ?Center $center = null;
/**
* @var int
*
* @ORM\Id
*
* @ORM\Column(name="id", type="integer")
*
* @ORM\GeneratedValue(strategy="AUTO")
*/
private ?int $id = null;
@@ -46,6 +47,7 @@ class GroupCenter
* @ORM\ManyToOne(
* targetEntity="Chill\MainBundle\Entity\PermissionsGroup",
* inversedBy="groupCenters")
*
* @ORM\Cache(usage="NONSTRICT_READ_WRITE")
*/
private ?PermissionsGroup $permissionsGroup = null;
@@ -55,6 +57,7 @@ class GroupCenter
* targetEntity="Chill\MainBundle\Entity\User",
* mappedBy="groupCenters"
* )
*
* @var Collection<User::class>
*/
private Collection $users;

View File

@@ -18,17 +18,20 @@ use Symfony\Component\Serializer\Annotation as Serializer;
* Language.
*
* @ORM\Entity
*
* @ORM\Table(name="language")
*
* @ORM\Cache(usage="READ_ONLY", region="language_cache_region")
*
* @ORM\HasLifecycleCallbacks
*/
class Language
{
/**
* @var string
*
* @ORM\Id
*
* @ORM\Column(type="string")
*
* @Serializer\Groups({"docgen:read"})
*/
private ?string $id = null;
@@ -37,7 +40,9 @@ class Language
* @var string array
*
* @ORM\Column(type="json")
*
* @Serializer\Groups({"docgen:read"})
*
* @Serializer\Context({"is-translatable": true}, groups={"docgen:read"})
*/
private array $name = [];

View File

@@ -15,8 +15,6 @@ use Chill\MainBundle\Doctrine\Model\TrackCreationInterface;
use Chill\MainBundle\Doctrine\Model\TrackUpdateInterface;
use Chill\MainBundle\Repository\LocationRepository;
use Chill\MainBundle\Validation\Constraint\PhonenumberConstraint;
use DateTimeImmutable;
use DateTimeInterface;
use Doctrine\ORM\Mapping as ORM;
use libphonenumber\PhoneNumber;
use Symfony\Component\Serializer\Annotation as Serializer;
@@ -24,7 +22,9 @@ use Symfony\Component\Serializer\Annotation\DiscriminatorMap;
/**
* @ORM\Table(name="chill_main_location")
*
* @ORM\Entity(repositoryClass=LocationRepository::class)
*
* @DiscriminatorMap(typeProperty="type", mapping={
* "location": Location::class
* })
@@ -33,84 +33,103 @@ class Location implements TrackCreationInterface, TrackUpdateInterface
{
/**
* @ORM\Column(type="boolean", nullable=true)
*
* @Serializer\Groups({"read"})
*/
private bool $active = true;
/**
* @ORM\ManyToOne(targetEntity=Address::class, cascade={"persist"})
*
* @ORM\JoinColumn(nullable=true)
*
* @Serializer\Groups({"read", "write", "docgen:read"})
*/
private ?Address $address = null;
/**
* @ORM\Column(type="boolean")
*
* @Serializer\Groups({"read"})
*/
private bool $availableForUsers = false;
/**
* @ORM\Column(type="datetime_immutable", nullable=true)
*
* @Serializer\Groups({"read"})
*/
private ?DateTimeImmutable $createdAt = null;
private ?\DateTimeImmutable $createdAt = null;
/**
* @ORM\ManyToOne(targetEntity=User::class)
*
* @Serializer\Groups({"read"})
*/
private ?User $createdBy = null;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*
* @Serializer\Groups({"read", "write", "docgen:read"})
*/
private ?string $email = null;
/**
* @ORM\Id
*
* @ORM\GeneratedValue
*
* @ORM\Column(type="integer")
*
* @Serializer\Groups({"read", "docgen:read"})
*/
private ?int $id = null;
/**
* @ORM\ManyToOne(targetEntity=LocationType::class)
*
* @ORM\JoinColumn(nullable=false)
*
* @Serializer\Groups({"read", "write", "docgen:read"})
*/
private ?LocationType $locationType = null;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*
* @Serializer\Groups({"read", "write", "docgen:read"})
*/
private ?string $name = null;
/**
* @ORM\Column(type="phone_number", nullable=true)
*
* @Serializer\Groups({"read", "write", "docgen:read"})
*
* @PhonenumberConstraint(type="any")
*/
private ?PhoneNumber $phonenumber1 = null;
/**
* @ORM\Column(type="phone_number", nullable=true)
*
* @Serializer\Groups({"read", "write", "docgen:read"})
*
* @PhonenumberConstraint(type="any")
*/
private ?PhoneNumber $phonenumber2 = null;
/**
* @ORM\Column(type="datetime_immutable", nullable=true)
*
* @Serializer\Groups({"read"})
*/
private ?DateTimeImmutable $updatedAt = null;
private ?\DateTimeImmutable $updatedAt = null;
/**
* @ORM\ManyToOne(targetEntity=User::class)
*
* @Serializer\Groups({"read"})
*/
private ?User $updatedBy = null;
@@ -130,7 +149,7 @@ class Location implements TrackCreationInterface, TrackUpdateInterface
return $this->availableForUsers;
}
public function getCreatedAt(): ?DateTimeImmutable
public function getCreatedAt(): ?\DateTimeImmutable
{
return $this->createdAt;
}
@@ -170,7 +189,7 @@ class Location implements TrackCreationInterface, TrackUpdateInterface
return $this->phonenumber2;
}
public function getUpdatedAt(): ?DateTimeImmutable
public function getUpdatedAt(): ?\DateTimeImmutable
{
return $this->updatedAt;
}
@@ -206,7 +225,7 @@ class Location implements TrackCreationInterface, TrackUpdateInterface
return $this;
}
public function setCreatedAt(?DateTimeInterface $createdAt): self
public function setCreatedAt(?\DateTimeInterface $createdAt): self
{
$this->createdAt = $createdAt;
@@ -255,7 +274,7 @@ class Location implements TrackCreationInterface, TrackUpdateInterface
return $this;
}
public function setUpdatedAt(?DateTimeInterface $updatedAt): self
public function setUpdatedAt(?\DateTimeInterface $updatedAt): self
{
$this->updatedAt = $updatedAt;

View File

@@ -19,10 +19,13 @@ use Symfony\Component\Serializer\Annotation\DiscriminatorMap;
/**
* @ORM\Table(name="chill_main_location_type")
*
* @ORM\Entity(repositoryClass=LocationTypeRepository::class)
*
* @DiscriminatorMap(typeProperty="type", mapping={
* "location-type": LocationType::class
* })
*
* @UniqueEntity({"defaultFor"})
*/
class LocationType
@@ -39,51 +42,62 @@ class LocationType
/**
* @ORM\Column(type="boolean", nullable=true)
*
* @Serializer\Groups({"read"})
*/
private bool $active = true;
/**
* @ORM\Column(type="string", length=32, options={"default": "optional"})
*
* @Serializer\Groups({"read"})
*/
private string $addressRequired = self::STATUS_OPTIONAL;
/**
* @ORM\Column(type="boolean")
*
* @Serializer\Groups({"read"})
*/
private bool $availableForUsers = true;
/**
* @ORM\Column(type="string", length=32, options={"default": "optional"})
*
* @Serializer\Groups({"read"})
*/
private string $contactData = self::STATUS_OPTIONAL;
/**
* @ORM\Column(type="string", nullable=true, length=32, unique=true)
*
* @Serializer\Groups({"read"})
*/
private ?string $defaultFor = null;
/**
* @ORM\Column(type="boolean")
*
* @Serializer\Groups({"read"})
*/
private bool $editableByUsers = true;
/**
* @ORM\Id
*
* @ORM\GeneratedValue
*
* @ORM\Column(type="integer")
*
* @Serializer\Groups({"read", "docgen:read"})
*/
private ?int $id = null;
/**
* @ORM\Column(type="json")
*
* @Serializer\Groups({"read", "docgen:read"})
*
* @Serializer\Context({"is-translatable": true}, groups={"docgen:read"})
*/
private array $title = [];

View File

@@ -12,24 +12,23 @@ declare(strict_types=1);
namespace Chill\MainBundle\Entity;
use Chill\MainBundle\Doctrine\Model\TrackUpdateInterface;
use DateTimeImmutable;
use DateTimeInterface;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
use Symfony\Component\Validator\Context\ExecutionContextInterface;
use function count;
use function in_array;
/**
* @ORM\Entity
*
* @ORM\Table(
* name="chill_main_notification",
* indexes={
*
* @ORM\Index(name="chill_main_notification_related_entity_idx", columns={"relatedentityclass", "relatedentityid"})
* }
* )
*
* @ORM\HasLifecycleCallbacks
*/
class Notification implements TrackUpdateInterface
@@ -43,7 +42,9 @@ class Notification implements TrackUpdateInterface
/**
* @var Collection<User>
*
* @ORM\ManyToMany(targetEntity=User::class)
*
* @ORM\JoinTable(name="chill_main_notification_addresses_user")
*/
private Collection $addressees;
@@ -52,6 +53,7 @@ class Notification implements TrackUpdateInterface
* a list of destinee which will receive notifications.
*
* @var array|string[]
*
* @ORM\Column(type="json")
*/
private array $addressesEmails = [];
@@ -67,7 +69,9 @@ class Notification implements TrackUpdateInterface
/**
* @var Collection<NotificationComment>
*
* @ORM\OneToMany(targetEntity=NotificationComment::class, mappedBy="notification", orphanRemoval=true)
*
* @ORM\OrderBy({"createdAt": "ASC"})
*/
private Collection $comments;
@@ -75,11 +79,13 @@ class Notification implements TrackUpdateInterface
/**
* @ORM\Column(type="datetime_immutable")
*/
private DateTimeImmutable $date;
private \DateTimeImmutable $date;
/**
* @ORM\Id
*
* @ORM\GeneratedValue
*
* @ORM\Column(type="integer")
*/
private ?int $id = null;
@@ -103,19 +109,23 @@ class Notification implements TrackUpdateInterface
/**
* @ORM\ManyToOne(targetEntity=User::class)
*
* @ORM\JoinColumn(nullable=true)
*/
private ?User $sender = null;
/**
* @ORM\Column(type="text", options={"default": ""})
*
* @Assert\NotBlank(message="notification.Title must be defined")
*/
private string $title = '';
/**
* @var Collection<User>
*
* @ORM\ManyToMany(targetEntity=User::class)
*
* @ORM\JoinTable(name="chill_main_notification_addresses_unread")
*/
private Collection $unreadBy;
@@ -123,7 +133,7 @@ class Notification implements TrackUpdateInterface
/**
* @ORM\Column(type="datetime_immutable")
*/
private ?DateTimeImmutable $updatedAt = null;
private ?\DateTimeImmutable $updatedAt = null;
/**
* @ORM\ManyToOne(targetEntity=User::class)
@@ -135,7 +145,7 @@ class Notification implements TrackUpdateInterface
$this->addressees = new ArrayCollection();
$this->unreadBy = new ArrayCollection();
$this->comments = new ArrayCollection();
$this->setDate(new DateTimeImmutable());
$this->setDate(new \DateTimeImmutable());
$this->accessKey = bin2hex(openssl_random_pseudo_bytes(24));
}
@@ -151,7 +161,7 @@ class Notification implements TrackUpdateInterface
public function addAddressesEmail(string $email)
{
if (!in_array($email, $this->addressesEmails, true)) {
if (!\in_array($email, $this->addressesEmails, true)) {
$this->addressesEmails[] = $email;
$this->addressesEmailsAdded[] = $email;
}
@@ -183,7 +193,7 @@ class Notification implements TrackUpdateInterface
*/
public function assertCountAddresses(ExecutionContextInterface $context, $payload): void
{
if (0 === (count($this->getAddressesEmails()) + count($this->getAddressees()))) {
if (0 === (\count($this->getAddressesEmails()) + \count($this->getAddressees()))) {
$context->buildViolation('notification.At least one addressee')
->atPath('addressees')
->addViolation();
@@ -234,7 +244,7 @@ class Notification implements TrackUpdateInterface
return $this->comments;
}
public function getDate(): ?DateTimeImmutable
public function getDate(): ?\DateTimeImmutable
{
return $this->date;
}
@@ -274,7 +284,7 @@ class Notification implements TrackUpdateInterface
return $this->unreadBy;
}
public function getUpdatedAt(): ?DateTimeImmutable
public function getUpdatedAt(): ?\DateTimeImmutable
{
return $this->updatedAt;
}
@@ -347,7 +357,7 @@ class Notification implements TrackUpdateInterface
public function removeAddressesEmail(string $email)
{
if (in_array($email, $this->addressesEmails, true)) {
if (\in_array($email, $this->addressesEmails, true)) {
$this->addressesEmails = array_filter($this->addressesEmails, static fn ($e) => $e !== $email);
$this->addressesEmailsAdded = array_filter($this->addressesEmailsAdded, static fn ($e) => $e !== $email);
}
@@ -367,7 +377,7 @@ class Notification implements TrackUpdateInterface
return $this;
}
public function setDate(DateTimeImmutable $date): self
public function setDate(\DateTimeImmutable $date): self
{
$this->date = $date;
@@ -409,7 +419,7 @@ class Notification implements TrackUpdateInterface
return $this;
}
public function setUpdatedAt(DateTimeInterface $datetime): self
public function setUpdatedAt(\DateTimeInterface $datetime): self
{
$this->updatedAt = $datetime;

View File

@@ -13,9 +13,6 @@ namespace Chill\MainBundle\Entity;
use Chill\MainBundle\Doctrine\Model\TrackCreationInterface;
use Chill\MainBundle\Doctrine\Model\TrackUpdateInterface;
use DateTimeImmutable;
use DateTimeInterface;
use Doctrine\ORM\Event\LifecycleEventArgs;
use Doctrine\ORM\Event\PreFlushEventArgs;
use Doctrine\ORM\Event\PrePersistEventArgs;
use Doctrine\ORM\Mapping as ORM;
@@ -23,13 +20,16 @@ use Symfony\Component\Validator\Constraints as Assert;
/**
* @ORM\Entity
*
* @ORM\Table("chill_main_notification_comment")
*
* @ORM\HasLifecycleCallbacks
*/
class NotificationComment implements TrackCreationInterface, TrackUpdateInterface
{
/**
* @ORM\Column(type="text")
*
* @Assert\NotBlank(message="notification.Comment content might not be blank")
*/
private string $content = '';
@@ -37,23 +37,27 @@ class NotificationComment implements TrackCreationInterface, TrackUpdateInterfac
/**
* @ORM\Column(type="datetime_immutable", nullable=true)
*/
private ?DateTimeImmutable $createdAt = null;
private ?\DateTimeImmutable $createdAt = null;
/**
* @ORM\ManyToOne(targetEntity=User::class)
*
* @ORM\JoinColumn(nullable=true)
*/
private ?User $createdBy = null;
/**
* @ORM\Id
*
* @ORM\GeneratedValue
*
* @ORM\Column(type="integer")
*/
private ?int $id = null;
/**
* @ORM\ManyToOne(targetEntity=Notification::class, inversedBy="comments")
*
* @ORM\JoinColumn(nullable=false)
*/
private ?Notification $notification = null;
@@ -70,10 +74,11 @@ class NotificationComment implements TrackCreationInterface, TrackUpdateInterfac
*
* @ORM\Column(type="datetime_immutable", nullable=true)
*/
private ?DateTimeImmutable $updateAt = null;
private ?\DateTimeImmutable $updateAt = null;
/**
* @ORM\ManyToOne(targetEntity=User::class)
*
* @ORM\JoinColumn(nullable=true)
*/
private ?User $updatedBy = null;
@@ -83,7 +88,7 @@ class NotificationComment implements TrackCreationInterface, TrackUpdateInterfac
return $this->content;
}
public function getCreatedAt(): ?DateTimeImmutable
public function getCreatedAt(): ?\DateTimeImmutable
{
return $this->createdAt;
}
@@ -103,7 +108,7 @@ class NotificationComment implements TrackCreationInterface, TrackUpdateInterfac
return $this->notification;
}
public function getUpdatedAt(): ?DateTimeImmutable
public function getUpdatedAt(): ?\DateTimeImmutable
{
return $this->updateAt;
}
@@ -146,7 +151,7 @@ class NotificationComment implements TrackCreationInterface, TrackUpdateInterfac
return $this;
}
public function setCreatedAt(DateTimeInterface $datetime): self
public function setCreatedAt(\DateTimeInterface $datetime): self
{
$this->createdAt = $datetime;
@@ -173,12 +178,12 @@ class NotificationComment implements TrackCreationInterface, TrackUpdateInterfac
/**
* @deprecated use @see{self::setUpdatedAt} instead
*/
public function setUpdateAt(?DateTimeImmutable $updateAt): self
public function setUpdateAt(?\DateTimeImmutable $updateAt): self
{
return $this->setUpdatedAt($updateAt);
}
public function setUpdatedAt(DateTimeInterface $datetime): self
public function setUpdatedAt(\DateTimeInterface $datetime): self
{
$this->updateAt = $datetime;

View File

@@ -14,12 +14,13 @@ namespace Chill\MainBundle\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use RuntimeException;
use Symfony\Component\Validator\Context\ExecutionContextInterface;
/**
* @ORM\Entity
*
* @ORM\Table(name="permission_groups")
*
* @ORM\Cache(usage="NONSTRICT_READ_WRITE", region="acl_cache_region")
*/
class PermissionsGroup
@@ -33,6 +34,7 @@ class PermissionsGroup
/**
* @var Collection<GroupCenter>
*
* @ORM\OneToMany(
* targetEntity="Chill\MainBundle\Entity\GroupCenter",
* mappedBy="permissionsGroup"
@@ -41,27 +43,27 @@ class PermissionsGroup
private Collection $groupCenters;
/**
* @var int
*
* @ORM\Id
*
* @ORM\Column(name="id", type="integer")
*
* @ORM\GeneratedValue(strategy="AUTO")
*/
private ?int $id = null;
/**
* @var string
*
* @ORM\Column(type="string", length=255, nullable=false, options={"default": ""})
*/
private string $name = '';
/**
* @var Collection<RoleScope>
*
* @ORM\ManyToMany(
* targetEntity="Chill\MainBundle\Entity\RoleScope",
* inversedBy="permissionsGroups",
* cascade={ "persist" })
*
* @ORM\Cache(usage="NONSTRICT_READ_WRITE")
*/
private Collection $roleScopes;
@@ -104,10 +106,7 @@ class PermissionsGroup
return $this->name;
}
/**
* @return ArrayCollection|Collection
*/
public function getRoleScopes(): \Doctrine\Common\Collections\ArrayCollection|\Doctrine\Common\Collections\Collection
public function getRoleScopes(): ArrayCollection|Collection
{
return $this->roleScopes;
}
@@ -127,22 +126,21 @@ class PermissionsGroup
foreach ($countedIds as $id => $nb) {
if (1 < $nb) {
$context->buildViolation('A permission is already present '
. 'for the same role and scope')
.'for the same role and scope')
->addViolation();
}
}
}
/**
* @throws RuntimeException if the roleScope could not be removed.
* @throws \RuntimeException if the roleScope could not be removed
*/
public function removeRoleScope(RoleScope $roleScope)
{
$result = $this->roleScopes->removeElement($roleScope);
if (false === $result) {
throw new RuntimeException(sprintf("The roleScope '%s' could not be removed, "
. 'aborting.', spl_object_hash($roleScope)));
throw new \RuntimeException(sprintf("The roleScope '%s' could not be removed, ".'aborting.', spl_object_hash($roleScope)));
}
}
@@ -157,8 +155,6 @@ class PermissionsGroup
}
/**
* @param $name
*
* @return $this
*/
public function setName($name)

View File

@@ -16,7 +16,6 @@ use Chill\MainBundle\Doctrine\Model\TrackCreationInterface;
use Chill\MainBundle\Doctrine\Model\TrackCreationTrait;
use Chill\MainBundle\Doctrine\Model\TrackUpdateInterface;
use Chill\MainBundle\Doctrine\Model\TrackUpdateTrait;
use DateTimeImmutable;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation\Groups;
@@ -24,13 +23,16 @@ use Symfony\Component\Serializer\Annotation\Groups;
* PostalCode.
*
* @ORM\Entity
*
* @ORM\Table(
* name="chill_main_postal_code",
* uniqueConstraints={
*
* @ORM\UniqueConstraint(name="postal_code_import_unicity", columns={"code", "refpostalcodeid", "postalcodesource"},
* options={"where": "refpostalcodeid is not null"})
* },
* indexes={
*
* @ORM\Index(name="search_name_code", columns={"code", "label"}),
* @ORM\Index(name="search_by_reference_code", columns={"code", "refpostalcodeid"})
* })
@@ -53,23 +55,22 @@ class PostalCode implements TrackUpdateInterface, TrackCreationInterface
private string $canonical = '';
/**
*
* @ORM\Column(type="point", nullable=true)
*
* @groups({"read"})
*/
private ?\Chill\MainBundle\Doctrine\Model\Point $center = null;
/**
* @var string
*
* @ORM\Column(type="string", length=100)
*
* @groups({"write", "read"})
*/
private ?string $code = null;
/**
*
* @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\Country")
*
* @groups({"write", "read"})
*/
private ?\Chill\MainBundle\Entity\Country $country = null;
@@ -77,43 +78,43 @@ class PostalCode implements TrackUpdateInterface, TrackCreationInterface
/**
* @ORM\Column(type="datetime_immutable", nullable=true, options={"default": null})
*/
private ?DateTimeImmutable $deletedAt = null;
private ?\DateTimeImmutable $deletedAt = null;
/**
* @var int
*
* @ORM\Id
*
* @ORM\Column(name="id", type="integer")
*
* @ORM\GeneratedValue(strategy="AUTO")
*
* @groups({"write", "read"})
*/
private ?int $id = null;
/**
* @var string
*
* @ORM\Column(type="string", length=255, name="label")
*
* @groups({"write", "read"})
*/
private ?string $name = null;
/**
*
* @ORM\Column(name="origin", type="integer", nullable=true)
*
* @groups({"write", "read"})
*/
private int $origin = 0;
/**
*
* @ORM\Column(type="string", length=255, nullable=true)
*
* @groups({"read"})
*/
private ?string $postalCodeSource = null;
/**
*
* @ORM\Column(type="string", length=255, nullable=true)
*
* @groups({"read"})
*/
private ?string $refPostalCodeId = null;
@@ -207,11 +208,9 @@ class PostalCode implements TrackUpdateInterface, TrackCreationInterface
/**
* Set country.
*
* @param Country $country
*
* @return PostalCode
*/
public function setCountry(?Country $country = null)
public function setCountry(Country $country = null)
{
$this->country = $country;

View File

@@ -17,6 +17,7 @@ use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity
*
* @ORM\Table(name="regroupment")
*/
class Regroupment
@@ -26,14 +27,18 @@ class Regroupment
* targetEntity=Center::class,
* inversedBy="regroupments"
* )
*
* @ORM\Id
*
* @var Collection<Center>
*/
private Collection $centers;
/**
* @ORM\Id
*
* @ORM\GeneratedValue
*
* @ORM\Column(type="integer")
*/
private ?int $id = null;

View File

@@ -17,14 +17,18 @@ use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity
*
* @ORM\Table(name="role_scopes")
*
* @ORM\Cache(usage="NONSTRICT_READ_WRITE", region="acl_cache_region")
*/
class RoleScope
{
/**
* @ORM\Id
*
* @ORM\Column(name="id", type="integer")
*
* @ORM\GeneratedValue(strategy="AUTO")
*/
private ?int $id = null;
@@ -47,7 +51,9 @@ class RoleScope
* @ORM\ManyToOne(
* targetEntity="Chill\MainBundle\Entity\Scope",
* inversedBy="roleScopes")
*
* @ORM\JoinColumn(nullable=true, name="scope_id")
*
* @ORM\Cache(usage="NONSTRICT_READ_WRITE")
*/
private ?Scope $scope = null;
@@ -72,14 +78,14 @@ class RoleScope
return $this->scope;
}
public function setRole(?string $role = null): self
public function setRole(string $role = null): self
{
$this->role = $role;
return $this;
}
public function setScope(?Scope $scope = null): self
public function setScope(Scope $scope = null): self
{
$this->scope = $scope;

View File

@@ -22,6 +22,7 @@ use Symfony\Component\Validator\Constraints as Assert;
/**
* @ORM\Entity
*
* @ORM\Table(name="chill_main_saved_export")
*/
class SavedExport implements TrackCreationInterface, TrackUpdateInterface
@@ -32,6 +33,7 @@ class SavedExport implements TrackCreationInterface, TrackUpdateInterface
/**
* @ORM\Column(type="text", nullable=false, options={"default": ""})
*
* @Assert\NotBlank
*/
private string $description = '';
@@ -43,7 +45,9 @@ class SavedExport implements TrackCreationInterface, TrackUpdateInterface
/**
* @ORM\Id
*
* @ORM\Column(name="id", type="uuid", unique="true")
*
* @ORM\GeneratedValue(strategy="NONE")
*/
private UuidInterface $id;
@@ -55,6 +59,7 @@ class SavedExport implements TrackCreationInterface, TrackUpdateInterface
/**
* @ORM\Column(type="text", nullable=false, options={"default": ""})
*
* @Assert\NotBlank
*/
private string $title = '';

View File

@@ -20,8 +20,11 @@ use Symfony\Component\Serializer\Annotation\Groups;
/**
* @ORM\Entity
*
* @ORM\Table(name="scopes")
*
* @ORM\Cache(usage="NONSTRICT_READ_WRITE", region="acl_cache_region")
*
* @DiscriminatorMap(typeProperty="type", mapping={
* "scope": Scope::class
* })
@@ -35,8 +38,11 @@ class Scope
/**
* @ORM\Id
*
* @ORM\Column(name="id", type="integer")
*
* @ORM\GeneratedValue(strategy="AUTO")
*
* @Groups({"read", "docgen:read"})
*/
private ?int $id = null;
@@ -45,7 +51,9 @@ class Scope
* translatable names.
*
* @ORM\Column(type="json")
*
* @Groups({"read", "docgen:read"})
*
* @Context({"is-translatable": true}, groups={"docgen:read"})
*/
private array $name = [];
@@ -56,6 +64,7 @@ class Scope
* @ORM\OneToMany(
* targetEntity="Chill\MainBundle\Entity\RoleScope",
* mappedBy="scope")
*
* @ORM\Cache(usage="NONSTRICT_READ_WRITE")
*/
private Collection $roleScopes;
@@ -75,9 +84,6 @@ class Scope
return $this;
}
/**
* @return int
*/
public function getId(): ?int
{
return $this->id;
@@ -106,8 +112,6 @@ class Scope
}
/**
* @param $name
*
* @return $this
*/
public function setName(array $name): self

View File

@@ -13,26 +13,24 @@ namespace Chill\MainBundle\Entity;
use Chill\MainBundle\Entity\User\UserJobHistory;
use Chill\MainBundle\Entity\User\UserScopeHistory;
use DateTimeImmutable;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\Common\Collections\Criteria;
use Doctrine\Common\Collections\Selectable;
use Doctrine\ORM\Mapping as ORM;
use Iterator;
use RuntimeException;
use Symfony\Component\Security\Core\User\UserInterface;
use Symfony\Component\Serializer\Annotation as Serializer;
use Symfony\Component\Validator\Context\ExecutionContextInterface;
use function in_array;
/**
* User.
*
* @ORM\Entity
*
* @ORM\Table(name="users")
*
* @ORM\Cache(usage="NONSTRICT_READ_WRITE", region="acl_cache_region")
*
* @Serializer\DiscriminatorMap(typeProperty="type", mapping={
* "user": User::class
* })
@@ -41,7 +39,9 @@ class User implements UserInterface, \Stringable
{
/**
* @ORM\Id
*
* @ORM\Column(name="id", type="integer")
*
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected ?int $id = null;
@@ -49,7 +49,7 @@ class User implements UserInterface, \Stringable
/**
* @ORM\Column(type="datetime_immutable", nullable=true)
*/
private ?DateTimeImmutable $absenceStart = null;
private ?\DateTimeImmutable $absenceStart = null;
/**
* Array where SAML attributes's data are stored.
@@ -89,9 +89,11 @@ class User implements UserInterface, \Stringable
/**
* @var Collection<GroupCenter>
*
* @ORM\ManyToMany(
* targetEntity="Chill\MainBundle\Entity\GroupCenter",
* inversedBy="users")
*
* @ORM\Cache(usage="NONSTRICT_READ_WRITE")
*/
private Collection $groupCenters;
@@ -119,6 +121,7 @@ class User implements UserInterface, \Stringable
/**
* @var Collection&Selectable<int, UserScopeHistory>
*
* @ORM\OneToMany(targetEntity=UserScopeHistory::class,
* mappedBy="user", cascade={"persist", "remove"}, orphanRemoval=true)
*/
@@ -138,6 +141,7 @@ class User implements UserInterface, \Stringable
/**
* @var Collection&Selectable<int, UserJobHistory>
*
* @ORM\OneToMany(targetEntity=UserJobHistory::class,
* mappedBy="user", cascade={"persist", "remove"}, orphanRemoval=true)
*/
@@ -167,9 +171,6 @@ class User implements UserInterface, \Stringable
$this->jobHistories = new ArrayCollection();
}
/**
* @return string
*/
public function __toString(): string
{
return $this->getLabel();
@@ -187,7 +188,7 @@ class User implements UserInterface, \Stringable
public function eraseCredentials() {}
public function getAbsenceStart(): ?DateTimeImmutable
public function getAbsenceStart(): ?\DateTimeImmutable
{
return $this->absenceStart;
}
@@ -216,9 +217,6 @@ class User implements UserInterface, \Stringable
return $this->currentLocation;
}
/**
* @return string
*/
public function getEmail(): ?string
{
return $this->email;
@@ -263,9 +261,9 @@ class User implements UserInterface, \Stringable
return $this->mainLocation;
}
public function getMainScope(?DateTimeImmutable $at = null): ?Scope
public function getMainScope(\DateTimeImmutable $at = null): ?Scope
{
$at ??= new DateTimeImmutable('now');
$at ??= new \DateTimeImmutable('now');
foreach ($this->scopeHistories as $scopeHistory) {
if ($at >= $scopeHistory->getStartDate() && (
@@ -315,9 +313,9 @@ class User implements UserInterface, \Stringable
return $this->salt;
}
public function getUserJob(?DateTimeImmutable $at = null): ?UserJob
public function getUserJob(\DateTimeImmutable $at = null): ?UserJob
{
$at ??= new DateTimeImmutable('now');
$at ??= new \DateTimeImmutable('now');
foreach ($this->jobHistories as $jobHistory) {
if ($at >= $jobHistory->getStartDate() && (
@@ -367,7 +365,7 @@ class User implements UserInterface, \Stringable
public function isAbsent(): bool
{
return null !== $this->getAbsenceStart() && $this->getAbsenceStart() <= new DateTimeImmutable('now');
return null !== $this->getAbsenceStart() && $this->getAbsenceStart() <= new \DateTimeImmutable('now');
}
/**
@@ -412,7 +410,7 @@ class User implements UserInterface, \Stringable
$groupCentersIds = [];
foreach ($this->getGroupCenters() as $groupCenter) {
if (in_array($groupCenter->getId(), $groupCentersIds, true)) {
if (\in_array($groupCenter->getId(), $groupCentersIds, true)) {
$context->buildViolation('The user has already those permissions')
->addViolation();
} else {
@@ -422,17 +420,16 @@ class User implements UserInterface, \Stringable
}
/**
* @throws RuntimeException if the groupCenter is not in the collection
* @throws \RuntimeException if the groupCenter is not in the collection
*/
public function removeGroupCenter(GroupCenter $groupCenter)
{
if ($this->groupCenters->removeElement($groupCenter) === false) {
throw new RuntimeException('The groupCenter could not be removed, '
. 'it seems not to be associated with the user. Aborting.');
if (false === $this->groupCenters->removeElement($groupCenter)) {
throw new \RuntimeException('The groupCenter could not be removed, it seems not to be associated with the user. Aborting.');
}
}
public function setAbsenceStart(?DateTimeImmutable $absenceStart): void
public function setAbsenceStart(?\DateTimeImmutable $absenceStart): void
{
$this->absenceStart = $absenceStart;
}
@@ -471,8 +468,6 @@ class User implements UserInterface, \Stringable
}
/**
* @param $email
*
* @return $this
*/
public function setEmail($email)
@@ -483,8 +478,6 @@ class User implements UserInterface, \Stringable
}
/**
* @param $emailCanonical
*
* @return $this
*/
public function setEmailCanonical($emailCanonical)
@@ -531,7 +524,7 @@ class User implements UserInterface, \Stringable
$newScope = new UserScopeHistory();
$newScope
->setStartDate(new DateTimeImmutable('now'))
->setStartDate(new \DateTimeImmutable('now'))
->setScope($mainScope)
->setUser($this);
@@ -540,7 +533,7 @@ class User implements UserInterface, \Stringable
$criteria = new Criteria();
$criteria->orderBy(['startDate' => Criteria::ASC, 'id' => Criteria::ASC]);
/** @var Iterator $scopes */
/** @var \Iterator $scopes */
$scopes = $this->scopeHistories->matching($criteria)->getIterator();
$scopes->rewind();
@@ -559,8 +552,6 @@ class User implements UserInterface, \Stringable
}
/**
* @param $password
*
* @return $this
*/
public function setPassword($password)
@@ -571,8 +562,6 @@ class User implements UserInterface, \Stringable
}
/**
* @param $salt
*
* @return $this
*/
public function setSalt($salt)
@@ -591,7 +580,7 @@ class User implements UserInterface, \Stringable
$newJob = new UserJobHistory();
$newJob
->setStartDate(new DateTimeImmutable('now'))
->setStartDate(new \DateTimeImmutable('now'))
->setJob($userJob)
->setUser($this);
@@ -600,7 +589,7 @@ class User implements UserInterface, \Stringable
$criteria = new Criteria();
$criteria->orderBy(['startDate' => Criteria::ASC, 'id' => Criteria::ASC]);
/** @var Iterator $jobs */
/** @var \Iterator $jobs */
$jobs = $this->jobHistories->matching($criteria)->getIterator();
$jobs->rewind();
@@ -621,15 +610,13 @@ class User implements UserInterface, \Stringable
/**
* Set username.
*
* @param string $name
*
* @return User
*/
public function setUsername(?string $name)
{
$this->username = (string) $name;
if ("" === trim($this->getLabel())) {
if ('' === trim($this->getLabel())) {
$this->setLabel($name);
}
@@ -637,8 +624,6 @@ class User implements UserInterface, \Stringable
}
/**
* @param $usernameCanonical
*
* @return $this
*/
public function setUsernameCanonical($usernameCanonical)

View File

@@ -14,11 +14,11 @@ namespace Chill\MainBundle\Entity\User;
use App\Repository\UserJobHistoryRepository;
use Chill\MainBundle\Entity\User;
use Chill\MainBundle\Entity\UserJob;
use DateTimeImmutable;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Table(name="chill_main_user_job_history")
*
* @ORM\Entity(repositoryClass=UserJobHistoryRepository::class)
*/
class UserJobHistory
@@ -26,11 +26,13 @@ class UserJobHistory
/**
* @ORM\Column(type="datetime_immutable", nullable=true)
*/
private ?DateTimeImmutable $endDate = null;
private ?\DateTimeImmutable $endDate = null;
/**
* @ORM\Id
*
* @ORM\GeneratedValue
*
* @ORM\Column(type="integer")
*/
private ?int $id = null;
@@ -43,15 +45,14 @@ class UserJobHistory
/**
* @ORM\Column(type="datetime_immutable")
*/
private DateTimeImmutable $startDate;
private \DateTimeImmutable $startDate;
/**
* @ORM\ManyToOne(targetEntity=User::class)
*/
private User $user;
public function getEndDate(): ?DateTimeImmutable
public function getEndDate(): ?\DateTimeImmutable
{
return $this->endDate;
}
@@ -66,7 +67,7 @@ class UserJobHistory
return $this->job;
}
public function getStartDate(): ?DateTimeImmutable
public function getStartDate(): ?\DateTimeImmutable
{
return $this->startDate;
}
@@ -76,7 +77,7 @@ class UserJobHistory
return $this->user;
}
public function setEndDate(?DateTimeImmutable $endDate): self
public function setEndDate(?\DateTimeImmutable $endDate): self
{
$this->endDate = $endDate;
@@ -90,7 +91,7 @@ class UserJobHistory
return $this;
}
public function setStartDate(DateTimeImmutable $startDate): self
public function setStartDate(\DateTimeImmutable $startDate): self
{
$this->startDate = $startDate;
@@ -103,5 +104,4 @@ class UserJobHistory
return $this;
}
}

View File

@@ -14,11 +14,11 @@ namespace Chill\MainBundle\Entity\User;
use App\Repository\UserScopeHistoryRepository;
use Chill\MainBundle\Entity\Scope;
use Chill\MainBundle\Entity\User;
use DateTimeImmutable;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Table(name="chill_main_user_scope_history")
*
* @ORM\Entity(repositoryClass=UserScopeHistoryRepository::class)
*/
class UserScopeHistory
@@ -26,11 +26,13 @@ class UserScopeHistory
/**
* @ORM\Column(type="datetime_immutable", nullable=true)
*/
private ?DateTimeImmutable $endDate = null;
private ?\DateTimeImmutable $endDate = null;
/**
* @ORM\Id
*
* @ORM\GeneratedValue
*
* @ORM\Column(type="integer")
*/
private ?int $id = null;
@@ -43,15 +45,14 @@ class UserScopeHistory
/**
* @ORM\Column(type="datetime_immutable")
*/
private DateTimeImmutable $startDate;
private \DateTimeImmutable $startDate;
/**
* @ORM\ManyToOne(targetEntity=User::class)
*/
private User $user;
public function getEndDate(): ?DateTimeImmutable
public function getEndDate(): ?\DateTimeImmutable
{
return $this->endDate;
}
@@ -66,7 +67,7 @@ class UserScopeHistory
return $this->scope;
}
public function getStartDate(): ?DateTimeImmutable
public function getStartDate(): ?\DateTimeImmutable
{
return $this->startDate;
}
@@ -76,7 +77,7 @@ class UserScopeHistory
return $this->user;
}
public function setEndDate(?DateTimeImmutable $endDate): self
public function setEndDate(?\DateTimeImmutable $endDate): self
{
$this->endDate = $endDate;
@@ -90,7 +91,7 @@ class UserScopeHistory
return $this;
}
public function setStartDate(DateTimeImmutable $startDate): self
public function setStartDate(\DateTimeImmutable $startDate): self
{
$this->startDate = $startDate;
@@ -103,5 +104,4 @@ class UserScopeHistory
return $this;
}
}

View File

@@ -16,7 +16,9 @@ use Symfony\Component\Serializer\Annotation as Serializer;
/**
* @ORM\Entity
*
* @ORM\Table("chill_main_user_job")
*
* @Serializer\DiscriminatorMap(typeProperty="type", mapping={
* "user_job": UserJob::class
* })
@@ -30,16 +32,22 @@ class UserJob
/**
* @ORM\Id
*
* @ORM\Column(name="id", type="integer")
*
* @ORM\GeneratedValue(strategy="AUTO")
*
* @Serializer\Groups({"read", "docgen:read"})
*/
protected ?int $id = null;
/**
* @var array<string, string>
*
* @ORM\Column(name="label", type="json")
*
* @Serializer\Groups({"read", "docgen:read"})
*
* @Serializer\Context({"is-translatable": true}, groups={"docgen:read"})
*/
protected array $label = [];

View File

@@ -16,23 +16,20 @@ use Chill\MainBundle\Doctrine\Model\TrackCreationTrait;
use Chill\MainBundle\Doctrine\Model\TrackUpdateInterface;
use Chill\MainBundle\Doctrine\Model\TrackUpdateTrait;
use Chill\MainBundle\Entity\User;
use Chill\MainBundle\Validator\Constraints\Entity\WorkflowStepUsersOnTransition;
use Chill\MainBundle\Workflow\Validator\EntityWorkflowCreation;
use DateTimeInterface;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Iterator;
use RuntimeException;
use Symfony\Component\Serializer\Annotation as Serializer;
use Symfony\Component\Validator\Constraints as Assert;
use function count;
use function is_array;
/**
* @ORM\Entity
*
* @ORM\Table("chill_main_workflow_entity")
*
* @EntityWorkflowCreation(groups={"creation"})
*
* @Serializer\DiscriminatorMap(typeProperty="type", mapping={
* "entity_workflow": EntityWorkflow::class
* })
@@ -81,7 +78,9 @@ class EntityWorkflow implements TrackCreationInterface, TrackUpdateInterface
/**
* @ORM\Id
*
* @ORM\GeneratedValue
*
* @ORM\Column(type="integer")
*/
private ?int $id = null;
@@ -98,19 +97,23 @@ class EntityWorkflow implements TrackCreationInterface, TrackUpdateInterface
/**
* @ORM\OneToMany(targetEntity=EntityWorkflowStep::class, mappedBy="entityWorkflow", orphanRemoval=true, cascade={"persist"})
*
* @ORM\OrderBy({"transitionAt": "ASC", "id": "ASC"})
*
* @Assert\Valid(traverse=true)
*
* @var Collection<EntityWorkflowStep>
*/
private Collection $steps;
/**
* @var null|array|EntityWorkflowStep[]
* @var array|EntityWorkflowStep[]|null
*/
private ?array $stepsChainedCache = null;
/**
* @ORM\ManyToMany(targetEntity=User::class)
*
* @ORM\JoinTable(name="chill_main_workflow_entity_subscriber_to_final")
*
* @var Collection<User>
@@ -119,6 +122,7 @@ class EntityWorkflow implements TrackCreationInterface, TrackUpdateInterface
/**
* @ORM\ManyToMany(targetEntity=User::class)
*
* @ORM\JoinTable(name="chill_main_workflow_entity_subscriber_to_step")
*
* @var Collection<User>
@@ -220,7 +224,7 @@ class EntityWorkflow implements TrackCreationInterface, TrackUpdateInterface
return null;
}
public function getCurrentStepCreatedAt(): ?DateTimeInterface
public function getCurrentStepCreatedAt(): ?\DateTimeInterface
{
if (null !== $previous = $this->getPreviousStepIfAny()) {
return $previous->getTransitionAt();
@@ -267,7 +271,7 @@ class EntityWorkflow implements TrackCreationInterface, TrackUpdateInterface
{
$iterator = $this->steps->getIterator();
if ($iterator instanceof Iterator) {
if ($iterator instanceof \Iterator) {
$iterator->rewind();
while ($iterator->valid()) {
@@ -288,20 +292,17 @@ class EntityWorkflow implements TrackCreationInterface, TrackUpdateInterface
return null;
}
throw new RuntimeException();
throw new \RuntimeException();
}
/**
* @return ArrayCollection|Collection
*/
public function getSteps(): \Doctrine\Common\Collections\ArrayCollection|\Doctrine\Common\Collections\Collection
public function getSteps(): ArrayCollection|Collection
{
return $this->steps;
}
public function getStepsChained(): array
{
if (is_array($this->stepsChainedCache)) {
if (\is_array($this->stepsChainedCache)) {
return $this->stepsChainedCache;
}
@@ -332,18 +333,12 @@ class EntityWorkflow implements TrackCreationInterface, TrackUpdateInterface
return $steps;
}
/**
* @return ArrayCollection|Collection
*/
public function getSubscriberToFinal(): \Doctrine\Common\Collections\ArrayCollection|\Doctrine\Common\Collections\Collection
public function getSubscriberToFinal(): ArrayCollection|Collection
{
return $this->subscriberToFinal;
}
/**
* @return ArrayCollection|Collection
*/
public function getSubscriberToStep(): \Doctrine\Common\Collections\ArrayCollection|\Doctrine\Common\Collections\Collection
public function getSubscriberToStep(): ArrayCollection|Collection
{
return $this->subscriberToStep;
}
@@ -495,7 +490,7 @@ class EntityWorkflow implements TrackCreationInterface, TrackUpdateInterface
private function getPreviousStepIfAny(): ?EntityWorkflowStep
{
if (1 === count($this->steps)) {
if (1 === \count($this->steps)) {
return null;
}

View File

@@ -19,6 +19,7 @@ use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity
*
* @ORM\Table("chill_main_workflow_entity_comment")
*/
class EntityWorkflowComment implements TrackCreationInterface, TrackUpdateInterface
@@ -39,7 +40,9 @@ class EntityWorkflowComment implements TrackCreationInterface, TrackUpdateInterf
/**
* @ORM\Id
*
* @ORM\GeneratedValue
*
* @ORM\Column(type="integer")
*/
private ?int $id = null;

View File

@@ -12,17 +12,15 @@ declare(strict_types=1);
namespace Chill\MainBundle\Entity\Workflow;
use Chill\MainBundle\Entity\User;
use DateTimeImmutable;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
use Symfony\Component\Validator\Context\ExecutionContextInterface;
use function count;
use function in_array;
/**
* @ORM\Entity
*
* @ORM\Table("chill_main_workflow_entity_step")
*/
class EntityWorkflowStep
@@ -34,7 +32,9 @@ class EntityWorkflowStep
/**
* @var Collection<User>
*
* @ORM\ManyToMany(targetEntity=User::class)
*
* @ORM\JoinTable(name="chill_main_workflow_entity_step_cc_user")
*/
private Collection $ccUser;
@@ -56,14 +56,18 @@ class EntityWorkflowStep
/**
* @var Collection<User>
*
* @ORM\ManyToMany(targetEntity=User::class)
*
* @ORM\JoinTable(name="chill_main_workflow_entity_step_user")
*/
private Collection $destUser;
/**
* @var Collection<User>
*
* @ORM\ManyToMany(targetEntity=User::class)
*
* @ORM\JoinTable(name="chill_main_workflow_entity_step_user_by_accesskey")
*/
private Collection $destUserByAccessKey;
@@ -80,7 +84,9 @@ class EntityWorkflowStep
/**
* @ORM\Id
*
* @ORM\GeneratedValue
*
* @ORM\Column(type="integer")
*/
private ?int $id = null;
@@ -108,10 +114,11 @@ class EntityWorkflowStep
/**
* @ORM\Column(type="datetime_immutable", nullable=true, options={"default": null})
*/
private ?DateTimeImmutable $transitionAt = null;
private ?\DateTimeImmutable $transitionAt = null;
/**
* @ORM\ManyToOne(targetEntity=User::class)
*
* @ORM\JoinColumn(nullable=true)
*/
private ?User $transitionBy = null;
@@ -140,7 +147,7 @@ class EntityWorkflowStep
public function addDestEmail(string $email): self
{
if (!in_array($email, $this->destEmail, true)) {
if (!\in_array($email, $this->destEmail, true)) {
$this->destEmail[] = $email;
}
@@ -247,7 +254,7 @@ class EntityWorkflowStep
return $this->transitionAfter;
}
public function getTransitionAt(): ?DateTimeImmutable
public function getTransitionAt(): ?\DateTimeImmutable
{
return $this->transitionAt;
}
@@ -385,7 +392,7 @@ class EntityWorkflowStep
return $this;
}
public function setTransitionAt(?DateTimeImmutable $transitionAt): EntityWorkflowStep
public function setTransitionAt(?\DateTimeImmutable $transitionAt): EntityWorkflowStep
{
$this->transitionAt = $transitionAt;
@@ -414,13 +421,13 @@ class EntityWorkflowStep
return;
if ($this->isFinalizeAfter()) {
if (0 !== count($this->getDestUser())) {
if (0 !== \count($this->getDestUser())) {
$context->buildViolation('workflow.No dest users when the workflow is finalized')
->atPath('finalizeAfter')
->addViolation();
}
} else {
if (0 === count($this->getDestUser())) {
if (0 === \count($this->getDestUser())) {
$context->buildViolation('workflow.The next step must count at least one dest')
->atPath('finalizeAfter')
->addViolation();