mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-20 22:53:49 +00:00
cs: Fix code style (safe rules only).
This commit is contained in:
@@ -1,79 +1,36 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Chill\MainBundle\Entity;
|
||||
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Component\Validator\Context\ExecutionContextInterface;
|
||||
use Symfony\Component\Serializer\Annotation\Groups;
|
||||
use Chill\MainBundle\Doctrine\Model\Point;
|
||||
use Chill\ThirdPartyBundle\Entity\ThirdParty;
|
||||
use DateTime;
|
||||
use DateTimeInterface;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Component\Serializer\Annotation\Groups;
|
||||
use Symfony\Component\Validator\Context\ExecutionContextInterface;
|
||||
|
||||
/**
|
||||
* Address
|
||||
* Address.
|
||||
*
|
||||
* @ORM\Entity
|
||||
* @ORM\Table(name="chill_main_address")
|
||||
* @ORM\HasLifecycleCallbacks()
|
||||
* @ORM\HasLifecycleCallbacks
|
||||
*/
|
||||
class Address
|
||||
{
|
||||
/**
|
||||
* @var integer
|
||||
*
|
||||
* @ORM\Id
|
||||
* @ORM\Column(name="id", type="integer")
|
||||
* @ORM\GeneratedValue(strategy="AUTO")
|
||||
* @ORM\ManyToOne(targetEntity=AddressReference::class)
|
||||
* @Groups({"write"})
|
||||
*/
|
||||
private $id;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*
|
||||
* @ORM\Column(type="string", length=255)
|
||||
* @Groups({"write"})
|
||||
*/
|
||||
private $street = '';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*
|
||||
* @ORM\Column(type="string", length=255)
|
||||
* @Groups({"write"})
|
||||
*/
|
||||
private $streetNumber = '';
|
||||
|
||||
/**
|
||||
* @var PostalCode
|
||||
*
|
||||
* @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\PostalCode")
|
||||
* @Groups({"write"})
|
||||
*/
|
||||
private $postcode;
|
||||
|
||||
/**
|
||||
* @var string|null
|
||||
*
|
||||
* @ORM\Column(type="string", length=16, nullable=true)
|
||||
* @Groups({"write"})
|
||||
*/
|
||||
private $floor;
|
||||
|
||||
/**
|
||||
* @var string|null
|
||||
*
|
||||
* @ORM\Column(type="string", length=16, nullable=true)
|
||||
* @Groups({"write"})
|
||||
*/
|
||||
private $corridor;
|
||||
|
||||
/**
|
||||
* @var string|null
|
||||
*
|
||||
* @ORM\Column(type="string", length=16, nullable=true)
|
||||
* @Groups({"write"})
|
||||
*/
|
||||
private $steps;
|
||||
private ?AddressReference $addressReference = null;
|
||||
|
||||
/**
|
||||
* @var string|null
|
||||
@@ -89,7 +46,14 @@ class Address
|
||||
* @ORM\Column(type="string", length=16, nullable=true)
|
||||
* @Groups({"write"})
|
||||
*/
|
||||
private $flat;
|
||||
private $corridor;
|
||||
|
||||
/**
|
||||
* A list of metadata, added by customizable fields.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $customs = [];
|
||||
|
||||
/**
|
||||
* @var string|null
|
||||
@@ -108,29 +72,34 @@ class Address
|
||||
private $extra;
|
||||
|
||||
/**
|
||||
* Indicates when the address starts validation. Used to build an history
|
||||
* of address. By default, the current date.
|
||||
* @var string|null
|
||||
*
|
||||
* @var \DateTime
|
||||
*
|
||||
* @ORM\Column(type="date")
|
||||
* @ORM\Column(type="string", length=16, nullable=true)
|
||||
* @Groups({"write"})
|
||||
*/
|
||||
private \DateTime $validFrom;
|
||||
private $flat;
|
||||
|
||||
/**
|
||||
* Indicates when the address ends. Used to build an history
|
||||
* of address.
|
||||
* @var string|null
|
||||
*
|
||||
* @var \DateTime|null
|
||||
*
|
||||
* @ORM\Column(type="date", nullable=true)
|
||||
* @ORM\Column(type="string", length=16, nullable=true)
|
||||
* @Groups({"write"})
|
||||
*/
|
||||
private ?\DateTime $validTo = null;
|
||||
private $floor;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*
|
||||
* @ORM\Id
|
||||
* @ORM\Column(name="id", type="integer")
|
||||
* @ORM\GeneratedValue(strategy="AUTO")
|
||||
* @Groups({"write"})
|
||||
*/
|
||||
private $id;
|
||||
|
||||
/**
|
||||
* True if the address is a "no address", aka homeless person, ...
|
||||
*
|
||||
* @Groups({"write"})
|
||||
* @ORM\Column(type="boolean")
|
||||
*
|
||||
@@ -139,17 +108,7 @@ class Address
|
||||
private $isNoAddress = false;
|
||||
|
||||
/**
|
||||
* A geospatial field storing the coordinates of the Address
|
||||
*
|
||||
* @var Point|null
|
||||
*
|
||||
* @ORM\Column(type="point", nullable=true)
|
||||
* @Groups({"write"})
|
||||
*/
|
||||
private $point;
|
||||
|
||||
/**
|
||||
* A ThirdParty reference for person's addresses that are linked to a third party
|
||||
* A ThirdParty reference for person's addresses that are linked to a third party.
|
||||
*
|
||||
* @var ThirdParty|null
|
||||
*
|
||||
@@ -160,226 +119,71 @@ class Address
|
||||
private $linkedToThirdParty;
|
||||
|
||||
/**
|
||||
* A list of metadata, added by customizable fields
|
||||
* A geospatial field storing the coordinates of the Address.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $customs = [];
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity=AddressReference::class)
|
||||
* @var Point|null
|
||||
*
|
||||
* @ORM\Column(type="point", nullable=true)
|
||||
* @Groups({"write"})
|
||||
*/
|
||||
private ?AddressReference $addressReference = null;
|
||||
private $point;
|
||||
|
||||
/**
|
||||
* @var PostalCode
|
||||
*
|
||||
* @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\PostalCode")
|
||||
* @Groups({"write"})
|
||||
*/
|
||||
private $postcode;
|
||||
|
||||
/**
|
||||
* @var string|null
|
||||
*
|
||||
* @ORM\Column(type="string", length=16, nullable=true)
|
||||
* @Groups({"write"})
|
||||
*/
|
||||
private $steps;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*
|
||||
* @ORM\Column(type="string", length=255)
|
||||
* @Groups({"write"})
|
||||
*/
|
||||
private $street = '';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*
|
||||
* @ORM\Column(type="string", length=255)
|
||||
* @Groups({"write"})
|
||||
*/
|
||||
private $streetNumber = '';
|
||||
|
||||
/**
|
||||
* Indicates when the address starts validation. Used to build an history
|
||||
* of address. By default, the current date.
|
||||
*
|
||||
* @ORM\Column(type="date")
|
||||
* @Groups({"write"})
|
||||
*/
|
||||
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;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->validFrom = new \DateTime();
|
||||
$this->validFrom = new DateTime();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get id
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function getId()
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set streetAddress1 (legacy function)
|
||||
*
|
||||
* @param string $streetAddress1
|
||||
*
|
||||
* @return Address
|
||||
*/
|
||||
public function setStreetAddress1($streetAddress1)
|
||||
{
|
||||
$this->street = $streetAddress1 === NULL ? '' : $streetAddress1;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get streetAddress1 (legacy function)
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getStreetAddress1()
|
||||
{
|
||||
return $this->street;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set streetAddress2 (legacy function)
|
||||
*
|
||||
* @param string $streetAddress2
|
||||
*
|
||||
* @return Address
|
||||
*/
|
||||
public function setStreetAddress2($streetAddress2)
|
||||
{
|
||||
$this->streetNumber = $streetAddress2 === NULL ? '' : $streetAddress2;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get streetAddress2 (legacy function)
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getStreetAddress2()
|
||||
{
|
||||
return $this->streetNumber;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set postcode
|
||||
*
|
||||
* @param PostalCode $postcode
|
||||
*
|
||||
* @return Address
|
||||
*/
|
||||
public function setPostcode(PostalCode $postcode = null)
|
||||
{
|
||||
$this->postcode = $postcode;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get postcode
|
||||
*
|
||||
* @return PostalCode
|
||||
*/
|
||||
public function getPostcode()
|
||||
{
|
||||
return $this->postcode;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \DateTime
|
||||
*/
|
||||
public function getValidFrom()
|
||||
{
|
||||
return $this->validFrom;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \DateTime $validFrom
|
||||
* @return Address
|
||||
*/
|
||||
public function setValidFrom(\DateTime $validFrom)
|
||||
{
|
||||
$this->validFrom = $validFrom;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get IsNoAddress
|
||||
*
|
||||
* Indicate true if the address is a fake address (homeless, ...)
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function getIsNoAddress(): bool
|
||||
{
|
||||
return $this->isNoAddress;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isNoAddress(): bool
|
||||
{
|
||||
return $this->getIsNoAddress();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set IsNoAddress
|
||||
*
|
||||
* Indicate true if the address is a fake address (homeless, ...)
|
||||
*
|
||||
* @param bool $isNoAddress
|
||||
* @return $this
|
||||
*/
|
||||
public function setIsNoAddress(bool $isNoAddress): self
|
||||
{
|
||||
$this->isNoAddress = $isNoAddress;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get customs informations in the address
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getCustoms(): array
|
||||
{
|
||||
return $this->customs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Store custom informations in the address
|
||||
*
|
||||
* @param array $customs
|
||||
* @return $this
|
||||
*/
|
||||
public function setCustoms(array $customs): self
|
||||
{
|
||||
$this->customs = $customs;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate the address.
|
||||
*
|
||||
* Check that:
|
||||
*
|
||||
* * if the address is not home address:
|
||||
* * the postal code is present
|
||||
* * the valid from is not null
|
||||
* * the address street 1 is greater than 2
|
||||
*
|
||||
* @param ExecutionContextInterface $context
|
||||
* @param array $payload
|
||||
*/
|
||||
public function validate(ExecutionContextInterface $context, $payload)
|
||||
{
|
||||
if (!$this->getValidFrom() instanceof \DateTime) {
|
||||
$context
|
||||
->buildViolation("address.date-should-be-set")
|
||||
->atPath('validFrom')
|
||||
->addViolation();
|
||||
}
|
||||
|
||||
if ($this->isNoAddress()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (empty($this->getStreetAddress1())) {
|
||||
$context
|
||||
->buildViolation("address.street1-should-be-set")
|
||||
->atPath('streetAddress1')
|
||||
->addViolation();
|
||||
}
|
||||
|
||||
if (!$this->getPostcode() instanceof PostalCode) {
|
||||
$context
|
||||
->buildViolation("address.postcode-should-be-set")
|
||||
->atPath('postCode')
|
||||
->addViolation();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Address $original
|
||||
* @return Address
|
||||
*/
|
||||
public static function createFromAddress(Address $original) : Address
|
||||
public static function createFromAddress(Address $original): Address
|
||||
{
|
||||
return (new Address())
|
||||
->setAddressReference($original->getAddressReference())
|
||||
@@ -398,8 +202,7 @@ class Address
|
||||
->setStreet($original->getStreet())
|
||||
->setStreetNumber($original->getStreetNumber())
|
||||
->setValidFrom($original->getValidFrom())
|
||||
->setValidTo($original->getValidTo())
|
||||
;
|
||||
->setValidTo($original->getValidTo());
|
||||
}
|
||||
|
||||
public static function createFromAddressReference(AddressReference $original): Address
|
||||
@@ -409,44 +212,17 @@ class Address
|
||||
->setPostcode($original->getPostcode())
|
||||
->setStreet($original->getStreet())
|
||||
->setStreetNumber($original->getStreetNumber())
|
||||
->setAddressReference($original)
|
||||
;
|
||||
->setAddressReference($original);
|
||||
}
|
||||
|
||||
public function getStreet(): ?string
|
||||
public function getAddressReference(): ?AddressReference
|
||||
{
|
||||
return $this->street;
|
||||
return $this->addressReference;
|
||||
}
|
||||
|
||||
public function setStreet(string $street): self
|
||||
public function getBuildingName(): ?string
|
||||
{
|
||||
$this->street = $street;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getStreetNumber(): ?string
|
||||
{
|
||||
return $this->streetNumber;
|
||||
}
|
||||
|
||||
public function setStreetNumber(string $streetNumber): self
|
||||
{
|
||||
$this->streetNumber = $streetNumber;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getFloor(): ?string
|
||||
{
|
||||
return $this->floor;
|
||||
}
|
||||
|
||||
public function setFloor(?string $floor): self
|
||||
{
|
||||
$this->floor = $floor;
|
||||
|
||||
return $this;
|
||||
return $this->buildingName;
|
||||
}
|
||||
|
||||
public function getCorridor(): ?string
|
||||
@@ -454,11 +230,72 @@ class Address
|
||||
return $this->corridor;
|
||||
}
|
||||
|
||||
public function setCorridor(?string $corridor): self
|
||||
/**
|
||||
* Get customs informations in the address.
|
||||
*/
|
||||
public function getCustoms(): array
|
||||
{
|
||||
$this->corridor = $corridor;
|
||||
return $this->customs;
|
||||
}
|
||||
|
||||
return $this;
|
||||
public function getDistribution(): ?string
|
||||
{
|
||||
return $this->distribution;
|
||||
}
|
||||
|
||||
public function getExtra(): ?string
|
||||
{
|
||||
return $this->extra;
|
||||
}
|
||||
|
||||
public function getFlat(): ?string
|
||||
{
|
||||
return $this->flat;
|
||||
}
|
||||
|
||||
public function getFloor(): ?string
|
||||
{
|
||||
return $this->floor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get id.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getId()
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get IsNoAddress.
|
||||
*
|
||||
* Indicate true if the address is a fake address (homeless, ...)
|
||||
*/
|
||||
public function getIsNoAddress(): bool
|
||||
{
|
||||
return $this->isNoAddress;
|
||||
}
|
||||
|
||||
public function getLinkedToThirdParty()
|
||||
{
|
||||
return $this->linkedToThirdParty;
|
||||
}
|
||||
|
||||
public function getPoint(): ?Point
|
||||
{
|
||||
return $this->point;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get postcode.
|
||||
*
|
||||
* @return PostalCode
|
||||
*/
|
||||
public function getPostcode()
|
||||
{
|
||||
return $this->postcode;
|
||||
}
|
||||
|
||||
public function getSteps(): ?string
|
||||
@@ -466,16 +303,59 @@ class Address
|
||||
return $this->steps;
|
||||
}
|
||||
|
||||
public function setSteps(?string $steps): self
|
||||
public function getStreet(): ?string
|
||||
{
|
||||
$this->steps = $steps;
|
||||
|
||||
return $this;
|
||||
return $this->street;
|
||||
}
|
||||
|
||||
public function getBuildingName(): ?string
|
||||
/**
|
||||
* Get streetAddress1 (legacy function).
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getStreetAddress1()
|
||||
{
|
||||
return $this->buildingName;
|
||||
return $this->street;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get streetAddress2 (legacy function).
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getStreetAddress2()
|
||||
{
|
||||
return $this->streetNumber;
|
||||
}
|
||||
|
||||
public function getStreetNumber(): ?string
|
||||
{
|
||||
return $this->streetNumber;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return DateTime
|
||||
*/
|
||||
public function getValidFrom()
|
||||
{
|
||||
return $this->validFrom;
|
||||
}
|
||||
|
||||
public function getValidTo(): ?DateTimeInterface
|
||||
{
|
||||
return $this->validTo;
|
||||
}
|
||||
|
||||
public function isNoAddress(): bool
|
||||
{
|
||||
return $this->getIsNoAddress();
|
||||
}
|
||||
|
||||
public function setAddressReference(?AddressReference $addressReference = null): Address
|
||||
{
|
||||
$this->addressReference = $addressReference;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setBuildingName(?string $buildingName): self
|
||||
@@ -485,21 +365,23 @@ class Address
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getFlat(): ?string
|
||||
public function setCorridor(?string $corridor): self
|
||||
{
|
||||
return $this->flat;
|
||||
}
|
||||
|
||||
public function setFlat(?string $flat): self
|
||||
{
|
||||
$this->flat = $flat;
|
||||
$this->corridor = $corridor;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getDistribution(): ?string
|
||||
/**
|
||||
* Store custom informations in the address.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setCustoms(array $customs): self
|
||||
{
|
||||
return $this->distribution;
|
||||
$this->customs = $customs;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setDistribution(?string $distribution): self
|
||||
@@ -509,11 +391,6 @@ class Address
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getExtra(): ?string
|
||||
{
|
||||
return $this->extra;
|
||||
}
|
||||
|
||||
public function setExtra(?string $extra): self
|
||||
{
|
||||
$this->extra = $extra;
|
||||
@@ -521,33 +398,32 @@ class Address
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getValidTo(): ?\DateTimeInterface
|
||||
public function setFlat(?string $flat): self
|
||||
{
|
||||
return $this->validTo;
|
||||
}
|
||||
|
||||
public function setValidTo(?\DateTimeInterface $validTo = null): self
|
||||
{
|
||||
$this->validTo = $validTo;
|
||||
$this->flat = $flat;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getPoint(): ?Point
|
||||
public function setFloor(?string $floor): self
|
||||
{
|
||||
return $this->point;
|
||||
}
|
||||
|
||||
public function setPoint(?Point $point): self
|
||||
{
|
||||
$this->point = $point;
|
||||
$this->floor = $floor;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getLinkedToThirdParty()
|
||||
/**
|
||||
* Set IsNoAddress.
|
||||
*
|
||||
* Indicate true if the address is a fake address (homeless, ...)
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setIsNoAddress(bool $isNoAddress): self
|
||||
{
|
||||
return $this->linkedToThirdParty;
|
||||
$this->isNoAddress = $isNoAddress;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setLinkedToThirdParty($linkedToThirdParty): self
|
||||
@@ -557,22 +433,130 @@ class Address
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return AddressReference|null
|
||||
*/
|
||||
public function getAddressReference(): ?AddressReference
|
||||
public function setPoint(?Point $point): self
|
||||
{
|
||||
return $this->addressReference;
|
||||
}
|
||||
$this->point = $point;
|
||||
|
||||
/**
|
||||
* @param AddressReference|null $addressReference
|
||||
* @return Address
|
||||
*/
|
||||
public function setAddressReference(?AddressReference $addressReference = null): Address
|
||||
{
|
||||
$this->addressReference = $addressReference;
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set postcode.
|
||||
*
|
||||
* @param PostalCode $postcode
|
||||
*
|
||||
* @return Address
|
||||
*/
|
||||
public function setPostcode(?PostalCode $postcode = null)
|
||||
{
|
||||
$this->postcode = $postcode;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setSteps(?string $steps): self
|
||||
{
|
||||
$this->steps = $steps;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setStreet(string $street): self
|
||||
{
|
||||
$this->street = $street;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set streetAddress1 (legacy function).
|
||||
*
|
||||
* @param string $streetAddress1
|
||||
*
|
||||
* @return Address
|
||||
*/
|
||||
public function setStreetAddress1($streetAddress1)
|
||||
{
|
||||
$this->street = null === $streetAddress1 ? '' : $streetAddress1;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set streetAddress2 (legacy function).
|
||||
*
|
||||
* @param string $streetAddress2
|
||||
*
|
||||
* @return Address
|
||||
*/
|
||||
public function setStreetAddress2($streetAddress2)
|
||||
{
|
||||
$this->streetNumber = null === $streetAddress2 ? '' : $streetAddress2;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setStreetNumber(string $streetNumber): self
|
||||
{
|
||||
$this->streetNumber = $streetNumber;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Address
|
||||
*/
|
||||
public function setValidFrom(DateTime $validFrom)
|
||||
{
|
||||
$this->validFrom = $validFrom;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setValidTo(?DateTimeInterface $validTo = null): self
|
||||
{
|
||||
$this->validTo = $validTo;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate the address.
|
||||
*
|
||||
* Check that:
|
||||
*
|
||||
* * if the address is not home address:
|
||||
* * the postal code is present
|
||||
* * the valid from is not null
|
||||
* * the address street 1 is greater than 2
|
||||
*
|
||||
* @param array $payload
|
||||
*/
|
||||
public function validate(ExecutionContextInterface $context, $payload)
|
||||
{
|
||||
if (!$this->getValidFrom() instanceof DateTime) {
|
||||
$context
|
||||
->buildViolation('address.date-should-be-set')
|
||||
->atPath('validFrom')
|
||||
->addViolation();
|
||||
}
|
||||
|
||||
if ($this->isNoAddress()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (empty($this->getStreetAddress1())) {
|
||||
$context
|
||||
->buildViolation('address.street1-should-be-set')
|
||||
->atPath('streetAddress1')
|
||||
->addViolation();
|
||||
}
|
||||
|
||||
if (!$this->getPostcode() instanceof PostalCode) {
|
||||
$context
|
||||
->buildViolation('address.postcode-should-be-set')
|
||||
->atPath('postCode')
|
||||
->addViolation();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,15 +1,22 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Chill\MainBundle\Entity;
|
||||
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Chill\MainBundle\Doctrine\Model\Point;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Component\Serializer\Annotation\Groups;
|
||||
|
||||
/**
|
||||
* @ORM\Entity
|
||||
* @ORM\Table(name="chill_main_address_reference")
|
||||
* @ORM\HasLifecycleCallbacks()
|
||||
* @ORM\HasLifecycleCallbacks
|
||||
*/
|
||||
class AddressReference
|
||||
{
|
||||
@@ -21,12 +28,42 @@ class AddressReference
|
||||
*/
|
||||
private $id;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="string", length=255, nullable=true)
|
||||
* @groups({"read"})
|
||||
*/
|
||||
private $municipalityCode;
|
||||
|
||||
/**
|
||||
* A geospatial field storing the coordinates of the Address.
|
||||
*
|
||||
* @var Point
|
||||
*
|
||||
* @ORM\Column(type="point")
|
||||
* @groups({"read"})
|
||||
*/
|
||||
private $point;
|
||||
|
||||
/**
|
||||
* @var PostalCode
|
||||
*
|
||||
* @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\PostalCode")
|
||||
* @groups({"read"})
|
||||
*/
|
||||
private $postcode;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="string", length=255)
|
||||
* @groups({"read"})
|
||||
*/
|
||||
private $refId;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="string", length=255, nullable=true)
|
||||
* @groups({"read"})
|
||||
*/
|
||||
private $source;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="string", length=255, nullable=true)
|
||||
* @groups({"read"})
|
||||
@@ -39,94 +76,23 @@ class AddressReference
|
||||
*/
|
||||
private $streetNumber;
|
||||
|
||||
/**
|
||||
* @var PostalCode
|
||||
*
|
||||
* @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\PostalCode")
|
||||
* @groups({"read"})
|
||||
*/
|
||||
private $postcode;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="string", length=255, nullable=true)
|
||||
* @groups({"read"})
|
||||
*/
|
||||
private $municipalityCode;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="string", length=255, nullable=true)
|
||||
* @groups({"read"})
|
||||
*/
|
||||
private $source;
|
||||
|
||||
/**
|
||||
* A geospatial field storing the coordinates of the Address
|
||||
*
|
||||
* @var Point
|
||||
*
|
||||
* @ORM\Column(type="point")
|
||||
* @groups({"read"})
|
||||
*/
|
||||
private $point;
|
||||
|
||||
|
||||
public function getId(): ?int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getRefId(): ?string
|
||||
public function getMunicipalityCode(): ?string
|
||||
{
|
||||
return $this->refId;
|
||||
return $this->municipalityCode;
|
||||
}
|
||||
|
||||
public function setRefId(string $refId): self
|
||||
public function getPoint(): ?Point
|
||||
{
|
||||
$this->refId = $refId;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getStreet(): ?string
|
||||
{
|
||||
return $this->street;
|
||||
}
|
||||
|
||||
public function setStreet(?string $street): self
|
||||
{
|
||||
$this->street = $street;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getStreetNumber(): ?string
|
||||
{
|
||||
return $this->streetNumber;
|
||||
}
|
||||
|
||||
public function setStreetNumber(?string $streetNumber): self
|
||||
{
|
||||
$this->streetNumber = $streetNumber;
|
||||
|
||||
return $this;
|
||||
return $this->point;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set postcode
|
||||
*
|
||||
* @param PostalCode $postcode
|
||||
*
|
||||
* @return Address
|
||||
*/
|
||||
public function setPostcode(PostalCode $postcode = null)
|
||||
{
|
||||
$this->postcode = $postcode;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get postcode
|
||||
* Get postcode.
|
||||
*
|
||||
* @return PostalCode
|
||||
*/
|
||||
@@ -135,9 +101,24 @@ class AddressReference
|
||||
return $this->postcode;
|
||||
}
|
||||
|
||||
public function getMunicipalityCode(): ?string
|
||||
public function getRefId(): ?string
|
||||
{
|
||||
return $this->municipalityCode;
|
||||
return $this->refId;
|
||||
}
|
||||
|
||||
public function getSource(): ?string
|
||||
{
|
||||
return $this->source;
|
||||
}
|
||||
|
||||
public function getStreet(): ?string
|
||||
{
|
||||
return $this->street;
|
||||
}
|
||||
|
||||
public function getStreetNumber(): ?string
|
||||
{
|
||||
return $this->streetNumber;
|
||||
}
|
||||
|
||||
public function setMunicipalityCode(?string $municipalityCode): self
|
||||
@@ -147,9 +128,32 @@ class AddressReference
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getSource(): ?string
|
||||
public function setPoint(?Point $point): self
|
||||
{
|
||||
return $this->source;
|
||||
$this->point = $point;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set postcode.
|
||||
*
|
||||
* @param PostalCode $postcode
|
||||
*
|
||||
* @return Address
|
||||
*/
|
||||
public function setPostcode(?PostalCode $postcode = null)
|
||||
{
|
||||
$this->postcode = $postcode;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setRefId(string $refId): self
|
||||
{
|
||||
$this->refId = $refId;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setSource(?string $source): self
|
||||
@@ -159,14 +163,16 @@ class AddressReference
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getPoint(): ?Point
|
||||
public function setStreet(?string $street): self
|
||||
{
|
||||
return $this->point;
|
||||
$this->street = $street;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setPoint(?Point $point): self
|
||||
public function setStreetNumber(?string $streetNumber): self
|
||||
{
|
||||
$this->point = $point;
|
||||
$this->streetNumber = $streetNumber;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
@@ -1,28 +1,17 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
/**
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* Copyright (C) 2014, Champs Libres Cooperative SCRLFS, <http://www.champs-libres.coop>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Chill\MainBundle\Entity;
|
||||
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Component\Serializer\Annotation as Serializer;
|
||||
|
||||
/**
|
||||
@@ -31,24 +20,6 @@ use Symfony\Component\Serializer\Annotation as Serializer;
|
||||
*/
|
||||
class Center implements HasCenterInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* @var integer
|
||||
*
|
||||
* @ORM\Id
|
||||
* @ORM\Column(name="id", type="integer")
|
||||
* @ORM\GeneratedValue(strategy="AUTO")
|
||||
*/
|
||||
private $id;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*
|
||||
* @ORM\Column(type="string", length=255)
|
||||
* @Serializer\Groups({"docgen:read"})
|
||||
*/
|
||||
private string $name = '';
|
||||
|
||||
/**
|
||||
* @var Collection
|
||||
*
|
||||
@@ -59,6 +30,20 @@ class Center implements HasCenterInterface
|
||||
*/
|
||||
private $groupCenters;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*
|
||||
* @ORM\Id
|
||||
* @ORM\Column(name="id", type="integer")
|
||||
* @ORM\GeneratedValue(strategy="AUTO")
|
||||
*/
|
||||
private $id;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="string", length=255)
|
||||
* @Serializer\Groups({"docgen:read"})
|
||||
*/
|
||||
private string $name = '';
|
||||
|
||||
/**
|
||||
* Center constructor.
|
||||
@@ -71,27 +56,27 @@ class Center implements HasCenterInterface
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getName()
|
||||
public function __toString()
|
||||
{
|
||||
return $this->name;
|
||||
return $this->getName();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $name
|
||||
* @return $this
|
||||
*/
|
||||
public function setName($name)
|
||||
public function addGroupCenter(GroupCenter $groupCenter)
|
||||
{
|
||||
$this->name = $name;
|
||||
$this->groupCenters->add($groupCenter);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
* @return $this|Center
|
||||
*/
|
||||
public function getId()
|
||||
public function getCenter()
|
||||
{
|
||||
return $this->id;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -103,29 +88,30 @@ class Center implements HasCenterInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* @param GroupCenter $groupCenter
|
||||
* @return $this
|
||||
* @return int
|
||||
*/
|
||||
public function addGroupCenter(GroupCenter $groupCenter)
|
||||
public function getId()
|
||||
{
|
||||
$this->groupCenters->add($groupCenter);
|
||||
return $this;
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
public function getName()
|
||||
{
|
||||
return $this->getName();
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return $this|Center
|
||||
* @param $name
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function getCenter()
|
||||
public function setName($name)
|
||||
{
|
||||
$this->name = $name;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1,23 +1,10 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
/**
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* Copyright (C) 2021, Champs Libres Cooperative SCRLFS,
|
||||
* <http://www.champs-libres.coop>, <info@champs-libres.coop>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Chill\MainBundle\Entity;
|
||||
@@ -31,6 +18,17 @@ use Symfony\Component\Serializer\Annotation as Serializer;
|
||||
*/
|
||||
class Civility
|
||||
{
|
||||
/**
|
||||
* @ORM\Column(type="json")
|
||||
* @Serializer\Groups({"read"})
|
||||
*/
|
||||
private array $abbreviation = [];
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="boolean")
|
||||
*/
|
||||
private bool $active = true;
|
||||
|
||||
/**
|
||||
* @ORM\Id
|
||||
* @ORM\GeneratedValue
|
||||
@@ -45,16 +43,15 @@ class Civility
|
||||
*/
|
||||
private array $name = [];
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="json")
|
||||
* @Serializer\Groups({"read"})
|
||||
*/
|
||||
private array $abbreviation = [];
|
||||
public function getAbbreviation(): array
|
||||
{
|
||||
return $this->abbreviation;
|
||||
}
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="boolean")
|
||||
*/
|
||||
private bool $active = true;
|
||||
public function getActive(): ?bool
|
||||
{
|
||||
return $this->active;
|
||||
}
|
||||
|
||||
public function getId(): ?int
|
||||
{
|
||||
@@ -66,18 +63,16 @@ class Civility
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
public function setName(array $name): self
|
||||
/**
|
||||
* @return Civility
|
||||
*/
|
||||
public function setAbbreviation(array $abbreviation): self
|
||||
{
|
||||
$this->name = $name;
|
||||
$this->abbreviation = $abbreviation;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getActive(): ?bool
|
||||
{
|
||||
return $this->active;
|
||||
}
|
||||
|
||||
public function setActive(bool $active): self
|
||||
{
|
||||
$this->active = $active;
|
||||
@@ -85,21 +80,10 @@ class Civility
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getAbbreviation(): array
|
||||
public function setName(array $name): self
|
||||
{
|
||||
return $this->abbreviation;
|
||||
}
|
||||
$this->name = $name;
|
||||
|
||||
/**
|
||||
* @param array $abbreviation
|
||||
* @return Civility
|
||||
*/
|
||||
public function setAbbreviation(array $abbreviation): self
|
||||
{
|
||||
$this->abbreviation = $abbreviation;
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
@@ -1,22 +1,37 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Chill\MainBundle\Entity;
|
||||
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Component\Serializer\Annotation\Groups;
|
||||
|
||||
/**
|
||||
* Country
|
||||
* Country.
|
||||
*
|
||||
* @ORM\Entity
|
||||
* @ORM\Table(name="country")
|
||||
* @ORM\Cache(usage="READ_ONLY", region="country_cache_region")
|
||||
* @ORM\HasLifecycleCallbacks()
|
||||
* @ORM\HasLifecycleCallbacks
|
||||
*/
|
||||
class Country
|
||||
{
|
||||
/**
|
||||
* @var integer
|
||||
* @var string
|
||||
*
|
||||
* @ORM\Column(type="string", length=3)
|
||||
* @groups({"read"})
|
||||
*/
|
||||
private $countryCode;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*
|
||||
* @ORM\Id
|
||||
* @ORM\Column(name="id", type="integer")
|
||||
@@ -30,52 +45,9 @@ class Country
|
||||
*
|
||||
* @ORM\Column(type="json")
|
||||
* @groups({"read"})
|
||||
*
|
||||
*/
|
||||
private $name;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*
|
||||
* @ORM\Column(type="string", length=3)
|
||||
* @groups({"read"})
|
||||
*/
|
||||
private $countryCode;
|
||||
|
||||
|
||||
/**
|
||||
* Get id
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function getId()
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set name
|
||||
*
|
||||
* @param string $name
|
||||
* @return Country
|
||||
*/
|
||||
public function setName($name)
|
||||
{
|
||||
$this->name = $name;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get name
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
@@ -85,7 +57,6 @@ class Country
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return the string
|
||||
*/
|
||||
public function getCountryCode()
|
||||
@@ -94,13 +65,46 @@ class Country
|
||||
}
|
||||
|
||||
/**
|
||||
* Get id.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getId()
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get name.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $countryCode
|
||||
*/
|
||||
public function setCountryCode($countryCode)
|
||||
{
|
||||
$this->countryCode = $countryCode;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set name.
|
||||
*
|
||||
* @param string $name
|
||||
*
|
||||
* @return Country
|
||||
*/
|
||||
public function setName($name)
|
||||
{
|
||||
$this->name = $name;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
@@ -1,12 +1,19 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Chill\MainBundle\Entity\Embeddable;
|
||||
|
||||
use Chill\MainBundle\Entity\User;
|
||||
use DateTime;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
/**
|
||||
* @ORM\Embeddable()
|
||||
* @ORM\Embeddable
|
||||
*/
|
||||
class CommentEmbeddable
|
||||
{
|
||||
@@ -17,18 +24,19 @@ class CommentEmbeddable
|
||||
private $comment;
|
||||
|
||||
/**
|
||||
* Embeddable does not support associations
|
||||
* @var integer
|
||||
* @ORM\Column(type="integer", nullable=true)
|
||||
*/
|
||||
private $userId;
|
||||
|
||||
/**
|
||||
* @var \DateTime
|
||||
* @var DateTime
|
||||
* @ORM\Column(type="datetime", nullable=true)
|
||||
*/
|
||||
private $date;
|
||||
|
||||
/**
|
||||
* Embeddable does not support associations.
|
||||
*
|
||||
* @var int
|
||||
* @ORM\Column(type="integer", nullable=true)
|
||||
*/
|
||||
private $userId;
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
@@ -37,6 +45,22 @@ class CommentEmbeddable
|
||||
return $this->comment;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return DateTime
|
||||
*/
|
||||
public function getDate()
|
||||
{
|
||||
return $this->date;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return interger $userId
|
||||
*/
|
||||
public function getUserId()
|
||||
{
|
||||
return $this->userId;
|
||||
}
|
||||
|
||||
public function isEmpty()
|
||||
{
|
||||
return empty($this->getComment());
|
||||
@@ -51,34 +75,18 @@ class CommentEmbeddable
|
||||
}
|
||||
|
||||
/**
|
||||
* @return interger $userId
|
||||
* @param DateTime $date
|
||||
*/
|
||||
public function getUserId()
|
||||
public function setDate(?DateTime $date)
|
||||
{
|
||||
return $this->userId;
|
||||
$this->date = $date;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param integer $userId
|
||||
* @param int $userId
|
||||
*/
|
||||
public function setUserId($userId)
|
||||
{
|
||||
$this->userId = $userId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \DateTime
|
||||
*/
|
||||
public function getDate()
|
||||
{
|
||||
return $this->date;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \DateTime $date
|
||||
*/
|
||||
public function setDate(?\DateTime $date)
|
||||
{
|
||||
$this->date = $date;
|
||||
}
|
||||
}
|
||||
|
@@ -1,49 +1,25 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Chill is a suite of a modules, Chill is a software for social workers
|
||||
* Copyright (C) 2014, Champs Libres Cooperative SCRLFS, <http://www.champs-libres.coop>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
/**
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Chill\MainBundle\Entity;
|
||||
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Chill\MainBundle\Entity\Center;
|
||||
use Chill\MainBundle\Entity\PermissionsGroup;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
/**
|
||||
* @ORM\Entity
|
||||
* @ORM\Table(name="group_centers")
|
||||
* @ORM\Cache(usage="NONSTRICT_READ_WRITE", region="acl_cache_region")
|
||||
*
|
||||
* @author Julien Fastré <julien.fastre@champs-libres.coop>
|
||||
*/
|
||||
class GroupCenter
|
||||
{
|
||||
/**
|
||||
* @var int
|
||||
*
|
||||
* @ORM\Id
|
||||
* @ORM\Column(name="id", type="integer")
|
||||
* @ORM\GeneratedValue(strategy="AUTO")
|
||||
*/
|
||||
private $id;
|
||||
|
||||
/**
|
||||
* @var Center
|
||||
*
|
||||
@@ -54,7 +30,26 @@ class GroupCenter
|
||||
* @ORM\Cache(usage="NONSTRICT_READ_WRITE")
|
||||
*/
|
||||
private $center;
|
||||
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*
|
||||
* @ORM\Id
|
||||
* @ORM\Column(name="id", type="integer")
|
||||
* @ORM\GeneratedValue(strategy="AUTO")
|
||||
*/
|
||||
private $id;
|
||||
|
||||
/**
|
||||
* @var PermissionsGroup
|
||||
*
|
||||
* @ORM\ManyToOne(
|
||||
* targetEntity="Chill\MainBundle\Entity\PermissionsGroup",
|
||||
* inversedBy="groupCenters")
|
||||
* @ORM\Cache(usage="NONSTRICT_READ_WRITE")
|
||||
*/
|
||||
private $permissionsGroup;
|
||||
|
||||
/**
|
||||
* @var Collection
|
||||
*
|
||||
@@ -64,18 +59,7 @@ class GroupCenter
|
||||
* )
|
||||
*/
|
||||
private $users;
|
||||
|
||||
/**
|
||||
* @var PermissionsGroup
|
||||
*
|
||||
* @ORM\ManyToOne(
|
||||
* targetEntity="Chill\MainBundle\Entity\PermissionsGroup",
|
||||
* inversedBy="groupCenters")
|
||||
* @ORM\Cache(usage="NONSTRICT_READ_WRITE")
|
||||
*/
|
||||
private $permissionsGroup;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* GroupCenter constructor.
|
||||
*/
|
||||
@@ -84,14 +68,6 @@ class GroupCenter
|
||||
$this->permissionsGroup = new ArrayCollection();
|
||||
$this->users = new ArrayCollection();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getId()
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Center
|
||||
@@ -102,23 +78,13 @@ class GroupCenter
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Center $center
|
||||
* @return \Chill\MainBundle\Entity\GroupCenter
|
||||
* @return int
|
||||
*/
|
||||
public function setCenter(Center $center)
|
||||
public function getId()
|
||||
{
|
||||
$this->center = $center;
|
||||
return $this;
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ArrayCollection|Collection
|
||||
*/
|
||||
public function getUsers()
|
||||
{
|
||||
return $this->users;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return PermissionGroup
|
||||
*/
|
||||
@@ -128,17 +94,30 @@ class GroupCenter
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Chill\MainBundle\Entity\PermissionsGroup $permissionGroup
|
||||
* @return ArrayCollection|Collection
|
||||
*/
|
||||
public function getUsers()
|
||||
{
|
||||
return $this->users;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Chill\MainBundle\Entity\GroupCenter
|
||||
*/
|
||||
public function setCenter(Center $center)
|
||||
{
|
||||
$this->center = $center;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Chill\MainBundle\Entity\GroupCenter
|
||||
*/
|
||||
public function setPermissionsGroup(PermissionsGroup $permissionsGroup)
|
||||
{
|
||||
$this->permissionsGroup = $permissionsGroup;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@@ -1,35 +1,22 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Copyright (C) 2015 Julien Fastré <julien.fastre@champs-libres.coop>
|
||||
/**
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Chill\MainBundle\Entity;
|
||||
|
||||
/**
|
||||
* Interface for entities which may be linked to a center
|
||||
*
|
||||
*
|
||||
* @author Julien Fastré <julien.fastre@champs-libres.coop>
|
||||
* Interface for entities which may be linked to a center.
|
||||
*/
|
||||
interface HasCenterInterface
|
||||
{
|
||||
/**
|
||||
* the linked center
|
||||
*
|
||||
* the linked center.
|
||||
*
|
||||
* @return Center
|
||||
*/
|
||||
public function getCenter();
|
||||
|
@@ -1,5 +1,12 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Chill\MainBundle\Entity;
|
||||
|
||||
interface HasCentersInterface
|
||||
|
@@ -1,34 +1,22 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Copyright (C) 2015 Julien Fastré <julien.fastre@champs-libres.coop>
|
||||
/**
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Chill\MainBundle\Entity;
|
||||
|
||||
/**
|
||||
* Interface for entities which have a scop
|
||||
*
|
||||
* @author Julien Fastré <julien.fastre@champs-libres.coop>
|
||||
* Interface for entities which have a scop.
|
||||
*/
|
||||
interface HasScopeInterface
|
||||
{
|
||||
/**
|
||||
* Return the linked scope
|
||||
*
|
||||
* Return the linked scope.
|
||||
*
|
||||
* @return Scope
|
||||
*/
|
||||
public function getScope();
|
||||
|
@@ -1,5 +1,12 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Chill\MainBundle\Entity;
|
||||
|
||||
interface HasScopesInterface
|
||||
|
@@ -1,21 +1,10 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
/**
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* Copyright (C) 2014, Champs Libres Cooperative SCRLFS, <http://www.champs-libres.coop>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Chill\MainBundle\Entity;
|
||||
@@ -23,19 +12,19 @@ namespace Chill\MainBundle\Entity;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
/**
|
||||
* Language
|
||||
* Language.
|
||||
*
|
||||
* @ORM\Entity
|
||||
* @ORM\Table(name="language")
|
||||
* @ORM\Cache(usage="READ_ONLY", region="language_cache_region")
|
||||
* @ORM\HasLifecycleCallbacks()
|
||||
* @ORM\HasLifecycleCallbacks
|
||||
*/
|
||||
class Language
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*
|
||||
* @ORM\Id()
|
||||
* @ORM\Id
|
||||
* @ORM\Column(type="string")
|
||||
*/
|
||||
private $id;
|
||||
@@ -48,7 +37,7 @@ class Language
|
||||
private $name;
|
||||
|
||||
/**
|
||||
* Get id
|
||||
* Get id.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
@@ -58,21 +47,34 @@ class Language
|
||||
}
|
||||
|
||||
/**
|
||||
* Set id
|
||||
* Get name.
|
||||
*
|
||||
* @return string array
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set id.
|
||||
*
|
||||
* @param string $id
|
||||
*
|
||||
* @return Language
|
||||
*/
|
||||
public function setId($id)
|
||||
{
|
||||
$this->id = $id;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set name
|
||||
* Set name.
|
||||
*
|
||||
* @param string array $name
|
||||
*
|
||||
* @return Language
|
||||
*/
|
||||
public function setName($name)
|
||||
@@ -81,14 +83,4 @@ class Language
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get name
|
||||
*
|
||||
* @return string array
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
}
|
||||
|
@@ -1,25 +1,71 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Chill\MainBundle\Entity;
|
||||
|
||||
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 Symfony\Component\Serializer\Annotation as Serializer;
|
||||
use Symfony\Component\Validator\Constraints as Assert;
|
||||
use Symfony\Component\Serializer\Annotation\DiscriminatorMap;
|
||||
use Symfony\Component\Validator\Constraints as Assert;
|
||||
|
||||
/**
|
||||
* @ORM\Table(name="chill_main_location")
|
||||
* @ORM\Entity(repositoryClass=LocationRepository::class)
|
||||
* @DiscriminatorMap(typeProperty="type", mapping={
|
||||
* "location"=Location::class
|
||||
* })
|
||||
* "location": Location::class
|
||||
* })
|
||||
*/
|
||||
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"})
|
||||
*/
|
||||
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;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity=User::class)
|
||||
* @Serializer\Groups({"read"})
|
||||
*/
|
||||
private ?User $createdBy = null;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="string", length=255, nullable=true)
|
||||
* @Serializer\Groups({"read", "write"})
|
||||
*/
|
||||
private ?string $email = null;
|
||||
|
||||
/**
|
||||
* @ORM\Id
|
||||
* @ORM\GeneratedValue
|
||||
@@ -35,13 +81,6 @@ class Location implements TrackCreationInterface, TrackUpdateInterface
|
||||
*/
|
||||
private ?LocationType $locationType = null;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity=Address::class, cascade={"persist"})
|
||||
* @ORM\JoinColumn(nullable=true)
|
||||
* @Serializer\Groups({"read", "write"})
|
||||
*/
|
||||
private ?Address $address = null;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="string", length=255, nullable=true)
|
||||
* @Serializer\Groups({"read", "write"})
|
||||
@@ -64,35 +103,11 @@ class Location implements TrackCreationInterface, TrackUpdateInterface
|
||||
*/
|
||||
private ?string $phonenumber2 = null;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="string", length=255, nullable=true)
|
||||
* @Serializer\Groups({"read", "write"})
|
||||
*/
|
||||
private ?string $email = null;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="boolean")
|
||||
* @Serializer\Groups({"read"})
|
||||
*/
|
||||
private bool $availableForUsers = false;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="boolean", nullable=true)
|
||||
* @Serializer\Groups({"read"})
|
||||
*/
|
||||
private bool $active = true;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity=User::class)
|
||||
* @Serializer\Groups({"read"})
|
||||
*/
|
||||
private ?User $createdBy = null;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="datetime_immutable", nullable=true)
|
||||
* @Serializer\Groups({"read"})
|
||||
*/
|
||||
private ?\DateTimeImmutable $createdAt = null;
|
||||
private ?DateTimeImmutable $updatedAt = null;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity=User::class)
|
||||
@@ -100,14 +115,35 @@ class Location implements TrackCreationInterface, TrackUpdateInterface
|
||||
*/
|
||||
private ?User $updatedBy = null;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="datetime_immutable", nullable=true)
|
||||
* @Serializer\Groups({"read"})
|
||||
*/
|
||||
private ?\DateTimeImmutable $updatedAt = null;
|
||||
public function getActive(): ?bool
|
||||
{
|
||||
return $this->active;
|
||||
}
|
||||
|
||||
public function getAddress(): ?Address
|
||||
{
|
||||
return $this->address;
|
||||
}
|
||||
|
||||
public function getAvailableForUsers(): ?bool
|
||||
{
|
||||
return $this->availableForUsers;
|
||||
}
|
||||
|
||||
public function getCreatedAt(): ?DateTimeImmutable
|
||||
{
|
||||
return $this->createdAt;
|
||||
}
|
||||
|
||||
public function getCreatedBy(): ?User
|
||||
{
|
||||
return $this->createdBy;
|
||||
}
|
||||
|
||||
public function getEmail(): ?string
|
||||
{
|
||||
return $this->email;
|
||||
}
|
||||
|
||||
public function getId(): ?int
|
||||
{
|
||||
@@ -119,88 +155,29 @@ class Location implements TrackCreationInterface, TrackUpdateInterface
|
||||
return $this->locationType;
|
||||
}
|
||||
|
||||
public function setLocationType(?LocationType $locationType): self
|
||||
{
|
||||
$this->locationType = $locationType;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getAddress(): ?Address
|
||||
{
|
||||
return $this->address;
|
||||
}
|
||||
|
||||
public function setAddress(Address $address): self
|
||||
{
|
||||
$this->address = $address;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getName(): ?string
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
public function setName(?string $name): self
|
||||
{
|
||||
$this->name = $name;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getPhonenumber1(): ?string
|
||||
{
|
||||
return $this->phonenumber1;
|
||||
}
|
||||
|
||||
public function setPhonenumber1(?string $phonenumber1): self
|
||||
{
|
||||
$this->phonenumber1 = $phonenumber1;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getPhonenumber2(): ?string
|
||||
{
|
||||
return $this->phonenumber2;
|
||||
}
|
||||
|
||||
public function setPhonenumber2(?string $phonenumber2): self
|
||||
public function getUpdatedAt(): ?DateTimeImmutable
|
||||
{
|
||||
$this->phonenumber2 = $phonenumber2;
|
||||
|
||||
return $this;
|
||||
return $this->updatedAt;
|
||||
}
|
||||
|
||||
public function getEmail(): ?string
|
||||
public function getUpdatedBy(): ?User
|
||||
{
|
||||
return $this->email;
|
||||
}
|
||||
|
||||
public function setEmail(?string $email): self
|
||||
{
|
||||
$this->email = $email;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getAvailableForUsers(): ?bool
|
||||
{
|
||||
return $this->availableForUsers;
|
||||
}
|
||||
|
||||
public function setAvailableForUsers(bool $availableForUsers): self
|
||||
{
|
||||
$this->availableForUsers = $availableForUsers;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getActive(): ?bool
|
||||
{
|
||||
return $this->active;
|
||||
return $this->updatedBy;
|
||||
}
|
||||
|
||||
public function setActive(bool $active): self
|
||||
@@ -210,9 +187,25 @@ class Location implements TrackCreationInterface, TrackUpdateInterface
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getCreatedBy(): ?User
|
||||
public function setAddress(Address $address): self
|
||||
{
|
||||
return $this->createdBy;
|
||||
$this->address = $address;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setAvailableForUsers(bool $availableForUsers): self
|
||||
{
|
||||
$this->availableForUsers = $availableForUsers;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setCreatedAt(?DateTimeInterface $createdAt): self
|
||||
{
|
||||
$this->createdAt = $createdAt;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setCreatedBy(?User $createdBy): self
|
||||
@@ -222,21 +215,46 @@ class Location implements TrackCreationInterface, TrackUpdateInterface
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getCreatedAt(): ?\DateTimeImmutable
|
||||
public function setEmail(?string $email): self
|
||||
{
|
||||
return $this->createdAt;
|
||||
}
|
||||
|
||||
public function setCreatedAt(?\DateTimeInterface $createdAt): self
|
||||
{
|
||||
$this->createdAt = $createdAt;
|
||||
$this->email = $email;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getUpdatedBy(): ?User
|
||||
public function setLocationType(?LocationType $locationType): self
|
||||
{
|
||||
return $this->updatedBy;
|
||||
$this->locationType = $locationType;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setName(?string $name): self
|
||||
{
|
||||
$this->name = $name;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setPhonenumber1(?string $phonenumber1): self
|
||||
{
|
||||
$this->phonenumber1 = $phonenumber1;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setPhonenumber2(?string $phonenumber2): self
|
||||
{
|
||||
$this->phonenumber2 = $phonenumber2;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setUpdatedAt(?DateTimeInterface $updatedAt): self
|
||||
{
|
||||
$this->updatedAt = $updatedAt;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setUpdatedBy(?User $updatedBy): self
|
||||
@@ -245,16 +263,4 @@ class Location implements TrackCreationInterface, TrackUpdateInterface
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getUpdatedAt(): ?\DateTimeImmutable
|
||||
{
|
||||
return $this->updatedAt;
|
||||
}
|
||||
|
||||
public function setUpdatedAt(?\DateTimeInterface $updatedAt): self
|
||||
{
|
||||
$this->updatedAt = $updatedAt;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
@@ -1,5 +1,12 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Chill\MainBundle\Entity;
|
||||
|
||||
use Chill\MainBundle\Repository\LocationTypeRepository;
|
||||
@@ -11,14 +18,40 @@ 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
|
||||
* })
|
||||
* "location-type": LocationType::class
|
||||
* })
|
||||
*/
|
||||
class LocationType
|
||||
{
|
||||
const STATUS_OPTIONAL = 'optional';
|
||||
const STATUS_REQUIRED = 'required';
|
||||
const STATUS_NEVER = 'never';
|
||||
public const STATUS_NEVER = 'never';
|
||||
|
||||
public const STATUS_OPTIONAL = 'optional';
|
||||
|
||||
public const STATUS_REQUIRED = 'required';
|
||||
|
||||
/**
|
||||
* @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\Id
|
||||
@@ -34,30 +67,25 @@ class LocationType
|
||||
*/
|
||||
private array $title = [];
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="boolean")
|
||||
* @Serializer\Groups({"read"})
|
||||
*/
|
||||
private bool $availableForUsers = true;
|
||||
public function getActive(): ?bool
|
||||
{
|
||||
return $this->active;
|
||||
}
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="boolean", nullable=true)
|
||||
* @Serializer\Groups({"read"})
|
||||
*/
|
||||
private bool $active = true;
|
||||
public function getAddressRequired(): ?string
|
||||
{
|
||||
return $this->addressRequired;
|
||||
}
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="string", length=32, options={"default"="optional"})
|
||||
* @Serializer\Groups({"read"})
|
||||
*/
|
||||
private string $addressRequired = self::STATUS_OPTIONAL;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="string", length=32, options={"default"="optional"})
|
||||
* @Serializer\Groups({"read"})
|
||||
*/
|
||||
private string $contactData = self::STATUS_OPTIONAL;
|
||||
public function getAvailableForUsers(): ?bool
|
||||
{
|
||||
return $this->availableForUsers;
|
||||
}
|
||||
|
||||
public function getContactData(): ?string
|
||||
{
|
||||
return $this->contactData;
|
||||
}
|
||||
|
||||
public function getId(): ?int
|
||||
{
|
||||
@@ -69,18 +97,6 @@ class LocationType
|
||||
return $this->title;
|
||||
}
|
||||
|
||||
public function setTitle(array $title): self
|
||||
{
|
||||
$this->title = $title;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getActive(): ?bool
|
||||
{
|
||||
return $this->active;
|
||||
}
|
||||
|
||||
public function setActive(bool $active): self
|
||||
{
|
||||
$this->active = $active;
|
||||
@@ -88,23 +104,6 @@ class LocationType
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getAvailableForUsers(): ?bool
|
||||
{
|
||||
return $this->availableForUsers;
|
||||
}
|
||||
|
||||
public function setAvailableForUsers(bool $availableForUsers): self
|
||||
{
|
||||
$this->availableForUsers = $availableForUsers;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getAddressRequired(): ?string
|
||||
{
|
||||
return $this->addressRequired;
|
||||
}
|
||||
|
||||
public function setAddressRequired(string $addressRequired): self
|
||||
{
|
||||
$this->addressRequired = $addressRequired;
|
||||
@@ -112,9 +111,11 @@ class LocationType
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getContactData(): ?string
|
||||
public function setAvailableForUsers(bool $availableForUsers): self
|
||||
{
|
||||
return $this->contactData;
|
||||
$this->availableForUsers = $availableForUsers;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setContactData(string $contactData): self
|
||||
@@ -123,4 +124,11 @@ class LocationType
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setTitle(array $title): self
|
||||
{
|
||||
$this->title = $title;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
@@ -1,25 +1,15 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Copyright (C) 2021 Champs-Libres <info@champs-libres.coop>
|
||||
/**
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Chill\MainBundle\Entity;
|
||||
|
||||
use Chill\MainBundle\Entity\User;
|
||||
use DateTimeImmutable;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
@@ -27,14 +17,25 @@ use Doctrine\ORM\Mapping as ORM;
|
||||
/**
|
||||
* @ORM\Entity
|
||||
* @ORM\Table(
|
||||
* name="chill_main_notification",
|
||||
* uniqueConstraints={
|
||||
* @ORM\UniqueConstraint(columns={"relatedEntityClass", "relatedEntityId"})
|
||||
* }
|
||||
* name="chill_main_notification",
|
||||
* uniqueConstraints={
|
||||
* @ORM\UniqueConstraint(columns={"relatedEntityClass", "relatedEntityId"})
|
||||
* }
|
||||
* )
|
||||
*/
|
||||
class Notification
|
||||
{
|
||||
/**
|
||||
* @ORM\ManyToMany(targetEntity=User::class)
|
||||
* @ORM\JoinTable(name="chill_main_notification_addresses_user")
|
||||
*/
|
||||
private Collection $addressees;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="datetime_immutable")
|
||||
*/
|
||||
private DateTimeImmutable $date;
|
||||
|
||||
/**
|
||||
* @ORM\Id
|
||||
* @ORM\GeneratedValue
|
||||
@@ -48,21 +49,9 @@ class Notification
|
||||
private string $message;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="datetime_immutable")
|
||||
* @ORM\Column(type="json")
|
||||
*/
|
||||
private \DateTimeImmutable $date;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity=User::class)
|
||||
* @ORM\JoinColumn(nullable=false)
|
||||
*/
|
||||
private User $sender;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToMany(targetEntity=User::class)
|
||||
* @ORM\JoinTable(name="chill_main_notification_addresses_user")
|
||||
*/
|
||||
private Collection $addressees;
|
||||
private array $read;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="string", length=255)
|
||||
@@ -75,52 +64,21 @@ class Notification
|
||||
private int $relatedEntityId;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="json")
|
||||
* @ORM\ManyToOne(targetEntity=User::class)
|
||||
* @ORM\JoinColumn(nullable=false)
|
||||
*/
|
||||
private array $read;
|
||||
private User $sender;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->addressees = new ArrayCollection();
|
||||
}
|
||||
|
||||
public function getId(): ?int
|
||||
public function addAddressee(User $addressee): self
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getMessage(): ?string
|
||||
{
|
||||
return $this->message;
|
||||
}
|
||||
|
||||
public function setMessage(string $message): self
|
||||
{
|
||||
$this->message = $message;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getDate(): ?\DateTimeImmutable
|
||||
{
|
||||
return $this->date;
|
||||
}
|
||||
|
||||
public function setDate(\DateTimeImmutable $date): self
|
||||
{
|
||||
$this->date = $date;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getSender(): ?User
|
||||
{
|
||||
return $this->sender;
|
||||
}
|
||||
|
||||
public function setSender(?User $sender): self
|
||||
{
|
||||
$this->sender = $sender;
|
||||
if (!$this->addressees->contains($addressee)) {
|
||||
$this->addressees[] = $addressee;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
@@ -133,13 +91,39 @@ class Notification
|
||||
return $this->addressees;
|
||||
}
|
||||
|
||||
public function addAddressee(User $addressee): self
|
||||
public function getDate(): ?DateTimeImmutable
|
||||
{
|
||||
if (!$this->addressees->contains($addressee)) {
|
||||
$this->addressees[] = $addressee;
|
||||
}
|
||||
return $this->date;
|
||||
}
|
||||
|
||||
return $this;
|
||||
public function getId(): ?int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getMessage(): ?string
|
||||
{
|
||||
return $this->message;
|
||||
}
|
||||
|
||||
public function getRead(): array
|
||||
{
|
||||
return $this->read;
|
||||
}
|
||||
|
||||
public function getRelatedEntityClass(): ?string
|
||||
{
|
||||
return $this->relatedEntityClass;
|
||||
}
|
||||
|
||||
public function getRelatedEntityId(): ?int
|
||||
{
|
||||
return $this->relatedEntityId;
|
||||
}
|
||||
|
||||
public function getSender(): ?User
|
||||
{
|
||||
return $this->sender;
|
||||
}
|
||||
|
||||
public function removeAddressee(User $addressee): self
|
||||
@@ -149,9 +133,25 @@ class Notification
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getRelatedEntityClass(): ?string
|
||||
public function setDate(DateTimeImmutable $date): self
|
||||
{
|
||||
return $this->relatedEntityClass;
|
||||
$this->date = $date;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setMessage(string $message): self
|
||||
{
|
||||
$this->message = $message;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setRead(array $read): self
|
||||
{
|
||||
$this->read = $read;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setRelatedEntityClass(string $relatedEntityClass): self
|
||||
@@ -161,11 +161,6 @@ class Notification
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getRelatedEntityId(): ?int
|
||||
{
|
||||
return $this->relatedEntityId;
|
||||
}
|
||||
|
||||
public function setRelatedEntityId(int $relatedEntityId): self
|
||||
{
|
||||
$this->relatedEntityId = $relatedEntityId;
|
||||
@@ -173,14 +168,9 @@ class Notification
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getRead(): array
|
||||
public function setSender(?User $sender): self
|
||||
{
|
||||
return $this->read;
|
||||
}
|
||||
|
||||
public function setRead(array $read): self
|
||||
{
|
||||
$this->read = $read;
|
||||
$this->sender = $sender;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
@@ -1,74 +1,34 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Chill is a suite of a modules, Chill is a software for social workers
|
||||
* Copyright (C) 2014, Champs Libres Cooperative SCRLFS, <http://www.champs-libres.coop>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
/**
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Chill\MainBundle\Entity;
|
||||
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Chill\MainBundle\Entity\RoleScope;
|
||||
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")
|
||||
*
|
||||
* @author Julien Fastré <julien.fastre@champs-libres.coop>
|
||||
*/
|
||||
class PermissionsGroup
|
||||
{
|
||||
/**
|
||||
* @var integer
|
||||
*
|
||||
* @ORM\Id
|
||||
* @ORM\Column(name="id", type="integer")
|
||||
* @ORM\GeneratedValue(strategy="AUTO")
|
||||
*/
|
||||
private $id;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*
|
||||
* @ORM\Column(type="string", length=255)
|
||||
*/
|
||||
private $name;
|
||||
|
||||
/**
|
||||
* @var string[]
|
||||
*
|
||||
* @ORM\Column(type="json")
|
||||
*/
|
||||
private $flags = [];
|
||||
|
||||
/**
|
||||
* @var Collection
|
||||
*
|
||||
* @ORM\ManyToMany(
|
||||
* targetEntity="Chill\MainBundle\Entity\RoleScope",
|
||||
* inversedBy="permissionsGroups",
|
||||
* cascade={ "persist" })
|
||||
* @ORM\Cache(usage="NONSTRICT_READ_WRITE")
|
||||
*/
|
||||
private $roleScopes;
|
||||
|
||||
|
||||
/**
|
||||
* @var Collection
|
||||
*
|
||||
@@ -78,8 +38,34 @@ class PermissionsGroup
|
||||
* )
|
||||
*/
|
||||
private $groupCenters;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*
|
||||
* @ORM\Id
|
||||
* @ORM\Column(name="id", type="integer")
|
||||
* @ORM\GeneratedValue(strategy="AUTO")
|
||||
*/
|
||||
private $id;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*
|
||||
* @ORM\Column(type="string", length=255)
|
||||
*/
|
||||
private $name;
|
||||
|
||||
/**
|
||||
* @var Collection
|
||||
*
|
||||
* @ORM\ManyToMany(
|
||||
* targetEntity="Chill\MainBundle\Entity\RoleScope",
|
||||
* inversedBy="permissionsGroups",
|
||||
* cascade={ "persist" })
|
||||
* @ORM\Cache(usage="NONSTRICT_READ_WRITE")
|
||||
*/
|
||||
private $roleScopes;
|
||||
|
||||
/**
|
||||
* PermissionsGroup constructor.
|
||||
*/
|
||||
@@ -88,7 +74,20 @@ class PermissionsGroup
|
||||
$this->roleScopes = new \Doctrine\Common\Collections\ArrayCollection();
|
||||
$this->groupCenters = new \Doctrine\Common\Collections\ArrayCollection();
|
||||
}
|
||||
|
||||
|
||||
public function addRoleScope(RoleScope $roleScope)
|
||||
{
|
||||
$this->roleScopes->add($roleScope);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string[]
|
||||
*/
|
||||
public function getFlags()
|
||||
{
|
||||
return $this->flags;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
@@ -104,7 +103,7 @@ class PermissionsGroup
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return ArrayCollection|Collection
|
||||
*/
|
||||
@@ -112,78 +111,62 @@ class PermissionsGroup
|
||||
{
|
||||
return $this->roleScopes;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $name
|
||||
* @return $this
|
||||
* Test that a role scope is associated only once
|
||||
* with the permission group.
|
||||
*/
|
||||
public function setName($name)
|
||||
public function isRoleScopePresentOnce(ExecutionContextInterface $context)
|
||||
{
|
||||
$this->name = $name;
|
||||
return $this;
|
||||
$roleScopesId = array_map(
|
||||
function (RoleScope $roleScope) {
|
||||
return $roleScope->getId();
|
||||
},
|
||||
$this->getRoleScopes()->toArray()
|
||||
);
|
||||
$countedIds = array_count_values($roleScopesId);
|
||||
|
||||
foreach ($countedIds as $id => $nb) {
|
||||
if (1 < $nb) {
|
||||
$context->buildViolation('A permission is already present '
|
||||
. 'for the same role and scope')
|
||||
->addViolation();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param RoleScope $roleScope
|
||||
*/
|
||||
public function addRoleScope(RoleScope $roleScope)
|
||||
{
|
||||
$this->roleScopes->add($roleScope);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param RoleScope $roleScope
|
||||
* @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 ($result === FALSE) {
|
||||
throw new \RuntimeException(sprintf("The roleScope '%s' could not be removed, "
|
||||
. "aborting.", spl_object_hash($roleScope)));
|
||||
|
||||
if (false === $result) {
|
||||
throw new RuntimeException(sprintf("The roleScope '%s' could not be removed, "
|
||||
. 'aborting.', spl_object_hash($roleScope)));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return string[]
|
||||
*/
|
||||
public function getFlags()
|
||||
{
|
||||
return $this->flags;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $flags
|
||||
* @return $this
|
||||
*/
|
||||
public function setFlags(array $flags)
|
||||
{
|
||||
$this->flags = $flags;
|
||||
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that a role scope is associated only once
|
||||
* with the permission group
|
||||
*
|
||||
* @param ExecutionContextInterface $context
|
||||
*/
|
||||
public function isRoleScopePresentOnce(ExecutionContextInterface $context)
|
||||
{
|
||||
$roleScopesId = array_map(function(RoleScope $roleScope) {
|
||||
return $roleScope->getId();
|
||||
},
|
||||
$this->getRoleScopes()->toArray());
|
||||
$countedIds = array_count_values($roleScopesId);
|
||||
|
||||
foreach ($countedIds as $id => $nb) {
|
||||
if ($nb > 1) {
|
||||
$context->buildViolation("A permission is already present "
|
||||
. "for the same role and scope")
|
||||
->addViolation();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $name
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setName($name)
|
||||
{
|
||||
$this->name = $name;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
@@ -1,5 +1,12 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Chill\MainBundle\Entity;
|
||||
|
||||
use Chill\MainBundle\Doctrine\Model\Point;
|
||||
@@ -7,37 +14,26 @@ use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Component\Serializer\Annotation\Groups;
|
||||
|
||||
/**
|
||||
* PostalCode
|
||||
* PostalCode.
|
||||
*
|
||||
* @ORM\Entity
|
||||
* @ORM\Table(
|
||||
* name="chill_main_postal_code",
|
||||
* indexes={@ORM\Index(
|
||||
* name="search_name_code",
|
||||
* columns={"code", "label"}
|
||||
* )})
|
||||
* @ORM\HasLifecycleCallbacks()
|
||||
*
|
||||
* name="search_name_code",
|
||||
* columns={"code", "label"}
|
||||
* )})
|
||||
* @ORM\HasLifecycleCallbacks
|
||||
*/
|
||||
class PostalCode
|
||||
{
|
||||
/**
|
||||
* @var integer
|
||||
* @var Point
|
||||
*
|
||||
* @ORM\Id
|
||||
* @ORM\Column(name="id", type="integer")
|
||||
* @ORM\GeneratedValue(strategy="AUTO")
|
||||
* @groups({"write", "read"})
|
||||
* @ORM\Column(type="point", nullable=true)
|
||||
* @groups({"read"})
|
||||
*/
|
||||
private $id;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*
|
||||
* @ORM\Column(type="string", length=255, name="label")
|
||||
* @groups({"write", "read"})
|
||||
*/
|
||||
private $name;
|
||||
private $center;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
@@ -56,7 +52,25 @@ class PostalCode
|
||||
private $country;
|
||||
|
||||
/**
|
||||
* @var integer
|
||||
* @var int
|
||||
*
|
||||
* @ORM\Id
|
||||
* @ORM\Column(name="id", type="integer")
|
||||
* @ORM\GeneratedValue(strategy="AUTO")
|
||||
* @groups({"write", "read"})
|
||||
*/
|
||||
private $id;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*
|
||||
* @ORM\Column(type="string", length=255, name="label")
|
||||
* @groups({"write", "read"})
|
||||
*/
|
||||
private $name;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*
|
||||
* @ORM\Column(name="origin", type="integer", nullable=true)
|
||||
* @groups({"write", "read"})
|
||||
@@ -69,7 +83,7 @@ class PostalCode
|
||||
* @ORM\Column(type="string", length=255, nullable=true)
|
||||
* @groups({"read"})
|
||||
*/
|
||||
private $refPostalCodeId;
|
||||
private $postalCodeSource;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
@@ -77,68 +91,45 @@ class PostalCode
|
||||
* @ORM\Column(type="string", length=255, nullable=true)
|
||||
* @groups({"read"})
|
||||
*/
|
||||
private $postalCodeSource;
|
||||
private $refPostalCodeId;
|
||||
|
||||
public function getCenter(): ?Point
|
||||
{
|
||||
return $this->center;
|
||||
}
|
||||
|
||||
/**
|
||||
* @var Point
|
||||
* Get code.
|
||||
*
|
||||
* @ORM\Column(type="point", nullable=true)
|
||||
* @groups({"read"})
|
||||
* @return string
|
||||
*/
|
||||
private $center;
|
||||
public function getCode()
|
||||
{
|
||||
return $this->code;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get id
|
||||
* Get country.
|
||||
*
|
||||
* @return integer
|
||||
* @return Country
|
||||
*/
|
||||
public function getCountry()
|
||||
{
|
||||
return $this->country;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get id.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getId()
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set origin
|
||||
*
|
||||
* @param int $origin
|
||||
*
|
||||
* @return PostalCode
|
||||
*/
|
||||
public function setOrigin($origin)
|
||||
{
|
||||
$this->origin = $origin;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get origin
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getOrigin()
|
||||
{
|
||||
return $this->origin;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set name
|
||||
*
|
||||
* @param string $name
|
||||
*
|
||||
* @return PostalCode
|
||||
*/
|
||||
public function setName($name)
|
||||
{
|
||||
$this->name = $name;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get name
|
||||
* Get name.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
@@ -148,7 +139,34 @@ class PostalCode
|
||||
}
|
||||
|
||||
/**
|
||||
* Set code
|
||||
* Get origin.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getOrigin()
|
||||
{
|
||||
return $this->origin;
|
||||
}
|
||||
|
||||
public function getPostalCodeSource(): ?string
|
||||
{
|
||||
return $this->postalCodeSource;
|
||||
}
|
||||
|
||||
public function getRefPostalCodeId(): ?string
|
||||
{
|
||||
return $this->refPostalCodeId;
|
||||
}
|
||||
|
||||
public function setCenter(?Point $center): self
|
||||
{
|
||||
$this->center = $center;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set code.
|
||||
*
|
||||
* @param string $code
|
||||
*
|
||||
@@ -162,23 +180,13 @@ class PostalCode
|
||||
}
|
||||
|
||||
/**
|
||||
* Get code
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getCode()
|
||||
{
|
||||
return $this->code;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set country
|
||||
* Set country.
|
||||
*
|
||||
* @param Country $country
|
||||
*
|
||||
* @return PostalCode
|
||||
*/
|
||||
public function setCountry(Country $country = null)
|
||||
public function setCountry(?Country $country = null)
|
||||
{
|
||||
$this->country = $country;
|
||||
|
||||
@@ -186,30 +194,31 @@ class PostalCode
|
||||
}
|
||||
|
||||
/**
|
||||
* Get country
|
||||
* Set name.
|
||||
*
|
||||
* @return Country
|
||||
* @param string $name
|
||||
*
|
||||
* @return PostalCode
|
||||
*/
|
||||
public function getCountry()
|
||||
public function setName($name)
|
||||
{
|
||||
return $this->country;
|
||||
}
|
||||
|
||||
public function getRefPostalCodeId(): ?string
|
||||
{
|
||||
return $this->refPostalCodeId;
|
||||
}
|
||||
|
||||
public function setRefPostalCodeId(?string $refPostalCodeId): self
|
||||
{
|
||||
$this->refPostalCodeId = $refPostalCodeId;
|
||||
$this->name = $name;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getPostalCodeSource(): ?string
|
||||
/**
|
||||
* Set origin.
|
||||
*
|
||||
* @param int $origin
|
||||
*
|
||||
* @return PostalCode
|
||||
*/
|
||||
public function setOrigin($origin)
|
||||
{
|
||||
return $this->postalCodeSource;
|
||||
$this->origin = $origin;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setPostalCodeSource(?string $postalCodeSource): self
|
||||
@@ -219,16 +228,10 @@ class PostalCode
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getCenter(): ?Point
|
||||
public function setRefPostalCodeId(?string $refPostalCodeId): self
|
||||
{
|
||||
return $this->center;
|
||||
}
|
||||
|
||||
public function setCenter(?Point $center): self
|
||||
{
|
||||
$this->center = $center;
|
||||
$this->refPostalCodeId = $refPostalCodeId;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -1,12 +1,19 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\MainBundle\Entity;
|
||||
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
/**
|
||||
* @ORM\Entity
|
||||
@@ -22,6 +29,15 @@ class RoleScope
|
||||
*/
|
||||
private ?int $id = null;
|
||||
|
||||
/**
|
||||
* @var Collection
|
||||
*
|
||||
* @ORM\ManyToMany(
|
||||
* targetEntity="Chill\MainBundle\Entity\PermissionsGroup",
|
||||
* mappedBy="roleScopes")
|
||||
*/
|
||||
private $permissionsGroups;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="string", length=255)
|
||||
*/
|
||||
@@ -30,22 +46,14 @@ class RoleScope
|
||||
/**
|
||||
* @ORM\ManyToOne(
|
||||
* targetEntity="Chill\MainBundle\Entity\Scope",
|
||||
* inversedBy="roleScopes")
|
||||
* inversedBy="roleScopes")
|
||||
* @ORM\JoinColumn(nullable=true, name="scope_id")
|
||||
* @ORM\Cache(usage="NONSTRICT_READ_WRITE")
|
||||
*/
|
||||
private ?Scope $scope = null;
|
||||
|
||||
/**
|
||||
* @var Collection
|
||||
*
|
||||
* @ORM\ManyToMany(
|
||||
* targetEntity="Chill\MainBundle\Entity\PermissionsGroup",
|
||||
* mappedBy="roleScopes")
|
||||
*/
|
||||
private $permissionsGroups;
|
||||
|
||||
public function __construct() {
|
||||
public function __construct()
|
||||
{
|
||||
$this->permissionsGroups = new ArrayCollection();
|
||||
}
|
||||
|
||||
|
@@ -1,44 +1,32 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Chill is a suite of a modules, Chill is a software for social workers
|
||||
* Copyright (C) 2014, Champs Libres Cooperative SCRLFS, <http://www.champs-libres.coop>
|
||||
/**
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Chill\MainBundle\Entity;
|
||||
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Chill\MainBundle\Entity\RoleScope;
|
||||
use Symfony\Component\Serializer\Annotation\Groups;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Component\Serializer\Annotation\DiscriminatorMap;
|
||||
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
|
||||
* "scope": Scope::class
|
||||
* })
|
||||
*/
|
||||
class Scope
|
||||
{
|
||||
/**
|
||||
* @var integer
|
||||
* @var int
|
||||
*
|
||||
* @ORM\Id
|
||||
* @ORM\Column(name="id", type="integer")
|
||||
@@ -48,7 +36,7 @@ class Scope
|
||||
private $id;
|
||||
|
||||
/**
|
||||
* translatable names
|
||||
* translatable names.
|
||||
*
|
||||
* @var array
|
||||
*
|
||||
@@ -62,12 +50,11 @@ class Scope
|
||||
*
|
||||
* @ORM\OneToMany(
|
||||
* targetEntity="Chill\MainBundle\Entity\RoleScope",
|
||||
* mappedBy="scope")
|
||||
* mappedBy="scope")
|
||||
* @ORM\Cache(usage="NONSTRICT_READ_WRITE")
|
||||
*/
|
||||
private $roleScopes;
|
||||
|
||||
|
||||
/**
|
||||
* Scope constructor.
|
||||
*/
|
||||
@@ -76,6 +63,11 @@ class Scope
|
||||
$this->roleScopes = new ArrayCollection();
|
||||
}
|
||||
|
||||
public function addRoleScope(RoleScope $roleScope)
|
||||
{
|
||||
$this->roleScopes->add($roleScope);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
@@ -92,16 +84,6 @@ class Scope
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $name
|
||||
* @return $this
|
||||
*/
|
||||
public function setName($name)
|
||||
{
|
||||
$this->name = $name;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection
|
||||
*/
|
||||
@@ -111,10 +93,14 @@ class Scope
|
||||
}
|
||||
|
||||
/**
|
||||
* @param RoleScope $roleScope
|
||||
* @param $name
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function addRoleScope(RoleScope $roleScope)
|
||||
public function setName($name)
|
||||
{
|
||||
$this->roleScopes->add($roleScope);
|
||||
$this->name = $name;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
@@ -1,30 +1,36 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Chill\MainBundle\Entity;
|
||||
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Chill\MainBundle\Entity\UserJob;
|
||||
use Chill\MainBundle\Entity\Location;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use RuntimeException;
|
||||
use Symfony\Component\Security\Core\User\AdvancedUserInterface;
|
||||
use Symfony\Component\Validator\Context\ExecutionContextInterface;
|
||||
use Symfony\Component\Serializer\Annotation as Serializer;
|
||||
use Symfony\Component\Validator\Context\ExecutionContextInterface;
|
||||
|
||||
/**
|
||||
* User
|
||||
* 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
|
||||
* "user": User::class
|
||||
* })
|
||||
*/
|
||||
class User implements AdvancedUserInterface {
|
||||
|
||||
class User implements AdvancedUserInterface
|
||||
{
|
||||
/**
|
||||
* @var integer
|
||||
* @var int
|
||||
*
|
||||
* @ORM\Id
|
||||
* @ORM\Column(name="id", type="integer")
|
||||
@@ -33,28 +39,18 @@ class User implements AdvancedUserInterface {
|
||||
protected $id;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
* Array where SAML attributes's data are stored.
|
||||
*
|
||||
* @ORM\Column(type="string", length=80)
|
||||
* @var array
|
||||
*
|
||||
* @ORM\Column(type="json", nullable=true)
|
||||
*/
|
||||
private $username;
|
||||
private $attributes;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*
|
||||
* @ORM\Column(
|
||||
* type="string",
|
||||
* length=80,
|
||||
* unique=true,
|
||||
* nullable=true)
|
||||
* @ORM\ManyToOne(targetEntity=Location::class)
|
||||
*/
|
||||
private $usernameCanonical;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="string", length=200)
|
||||
* @Serializer\Groups({"docgen:read"})
|
||||
*/
|
||||
private string $label = '';
|
||||
private ?Location $currentLocation = null;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
@@ -71,35 +67,12 @@ class User implements AdvancedUserInterface {
|
||||
* type="string",
|
||||
* length=150,
|
||||
* nullable=true,
|
||||
* unique=true)
|
||||
* unique=true)
|
||||
*/
|
||||
private $emailCanonical;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*
|
||||
* @ORM\Column(type="string", length=255)
|
||||
*/
|
||||
private $password;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
* @internal must be set to null if we use bcrypt
|
||||
*
|
||||
* @ORM\Column(type="string", length=255, nullable=true)
|
||||
*/
|
||||
private $salt = null;
|
||||
|
||||
/**
|
||||
* @var boolean
|
||||
*
|
||||
* @ORM\Column(type="boolean")
|
||||
* sf4 check: in yml was false by default !?
|
||||
*/
|
||||
private $locked = true;
|
||||
|
||||
/**
|
||||
* @var boolean
|
||||
* @var bool
|
||||
*
|
||||
* @ORM\Column(type="boolean")
|
||||
*/
|
||||
@@ -110,43 +83,74 @@ class User implements AdvancedUserInterface {
|
||||
*
|
||||
* @ORM\ManyToMany(
|
||||
* targetEntity="Chill\MainBundle\Entity\GroupCenter",
|
||||
* inversedBy="users")
|
||||
* inversedBy="users")
|
||||
* @ORM\Cache(usage="NONSTRICT_READ_WRITE")
|
||||
*/
|
||||
private $groupCenters;
|
||||
|
||||
/**
|
||||
* Array where SAML attributes's data are stored
|
||||
* @var array
|
||||
*
|
||||
* @ORM\Column(type="json", nullable=true)
|
||||
* @ORM\Column(type="string", length=200)
|
||||
* @Serializer\Groups({"docgen:read"})
|
||||
*/
|
||||
private $attributes;
|
||||
private string $label = '';
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*
|
||||
* @ORM\Column(type="boolean")
|
||||
* sf4 check: in yml was false by default !?
|
||||
*/
|
||||
private $locked = true;
|
||||
|
||||
/**
|
||||
* @var Center|null
|
||||
* @ORM\ManyToOne(targetEntity=Center::class)
|
||||
* @Serializer\Groups({"docgen:read"})
|
||||
*/
|
||||
private ?Center $mainCenter = null;
|
||||
|
||||
/**
|
||||
* @var Scope|null
|
||||
* @ORM\ManyToOne(targetEntity=Scope::class)
|
||||
*/
|
||||
private ?Scope $mainScope = null;
|
||||
|
||||
/**
|
||||
* @var UserJob|null
|
||||
* @var string
|
||||
*
|
||||
* @ORM\Column(type="string", length=255)
|
||||
*/
|
||||
private $password;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*
|
||||
* @internal must be set to null if we use bcrypt
|
||||
*
|
||||
* @ORM\Column(type="string", length=255, nullable=true)
|
||||
*/
|
||||
private $salt;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity=UserJob::class)
|
||||
*/
|
||||
private ?UserJob $userJob = null;
|
||||
|
||||
/**
|
||||
* @var Location|null
|
||||
* @ORM\ManyToOne(targetEntity=Location::class)
|
||||
* @var string
|
||||
*
|
||||
* @ORM\Column(type="string", length=80)
|
||||
*/
|
||||
private ?Location $currentLocation = null;
|
||||
private $username;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*
|
||||
* @ORM\Column(
|
||||
* type="string",
|
||||
* length=80,
|
||||
* unique=true,
|
||||
* nullable=true)
|
||||
*/
|
||||
private $usernameCanonical;
|
||||
|
||||
/**
|
||||
* User constructor.
|
||||
@@ -165,85 +169,38 @@ class User implements AdvancedUserInterface {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get id
|
||||
* @param \Chill\MainBundle\Entity\GroupCenter $groupCenter
|
||||
*
|
||||
* @return integer
|
||||
* @return \Chill\MainBundle\Entity\User
|
||||
*/
|
||||
public function getId()
|
||||
public function addGroupCenter(GroupCenter $groupCenter)
|
||||
{
|
||||
$this->groupCenters->add($groupCenter);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function eraseCredentials()
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set username
|
||||
* Get attributes.
|
||||
*
|
||||
* @param string $name
|
||||
* @return Agent
|
||||
* @return array
|
||||
*/
|
||||
public function setUsername($name)
|
||||
public function getAttributes()
|
||||
{
|
||||
$this->username = $name;
|
||||
|
||||
if (empty($this->getLabel())) {
|
||||
$this->setLabel($name);
|
||||
if (null === $this->attributes) {
|
||||
$this->attributes = [];
|
||||
}
|
||||
|
||||
return $this;
|
||||
return $this->attributes;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getUsername()
|
||||
public function getCurrentLocation(): ?Location
|
||||
{
|
||||
return $this->username;
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
public function eraseCredentials() {}
|
||||
|
||||
public function getRoles(): array
|
||||
{
|
||||
return ['ROLE_USER'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return null|string
|
||||
*/
|
||||
public function getSalt()
|
||||
{
|
||||
return $this->salt;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $usernameCanonical
|
||||
* @return $this
|
||||
*/
|
||||
public function setUsernameCanonical($usernameCanonical)
|
||||
{
|
||||
$this->usernameCanonical = $usernameCanonical;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getUsernameCanonical()
|
||||
{
|
||||
return $this->usernameCanonical;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $email
|
||||
* @return $this
|
||||
*/
|
||||
public function setEmail($email)
|
||||
{
|
||||
$this->email = $email;
|
||||
|
||||
return $this;
|
||||
return $this->currentLocation;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -254,17 +211,6 @@ class User implements AdvancedUserInterface {
|
||||
return $this->email;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $emailCanonical
|
||||
* @return $this
|
||||
*/
|
||||
public function setEmailCanonical($emailCanonical)
|
||||
{
|
||||
$this->emailCanonical = $emailCanonical;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
@@ -274,14 +220,36 @@ class User implements AdvancedUserInterface {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $password
|
||||
* @return $this
|
||||
* @return GroupCenter
|
||||
*/
|
||||
function setPassword($password)
|
||||
public function getGroupCenters()
|
||||
{
|
||||
$this->password = $password;
|
||||
return $this->groupCenters;
|
||||
}
|
||||
|
||||
return $this;
|
||||
/**
|
||||
* Get id.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getId()
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getLabel(): string
|
||||
{
|
||||
return $this->label;
|
||||
}
|
||||
|
||||
public function getMainCenter(): ?Center
|
||||
{
|
||||
return $this->mainCenter;
|
||||
}
|
||||
|
||||
public function getMainScope(): ?Scope
|
||||
{
|
||||
return $this->mainScope;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -292,14 +260,38 @@ class User implements AdvancedUserInterface {
|
||||
return $this->password;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $salt
|
||||
* @return $this
|
||||
*/
|
||||
function setSalt($salt)
|
||||
public function getRoles(): array
|
||||
{
|
||||
$this->salt = $salt;
|
||||
return $this;
|
||||
return ['ROLE_USER'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
public function getSalt()
|
||||
{
|
||||
return $this->salt;
|
||||
}
|
||||
|
||||
public function getUserJob(): ?UserJob
|
||||
{
|
||||
return $this->userJob;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getUsername()
|
||||
{
|
||||
return $this->username;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getUsernameCanonical()
|
||||
{
|
||||
return $this->usernameCanonical;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -334,46 +326,6 @@ class User implements AdvancedUserInterface {
|
||||
return $this->enabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $enabled
|
||||
*/
|
||||
public function setEnabled($enabled)
|
||||
{
|
||||
$this->enabled = $enabled;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return GroupCenter
|
||||
*/
|
||||
public function getGroupCenters()
|
||||
{
|
||||
return $this->groupCenters;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Chill\MainBundle\Entity\GroupCenter $groupCenter
|
||||
* @return \Chill\MainBundle\Entity\User
|
||||
*/
|
||||
public function addGroupCenter(GroupCenter $groupCenter)
|
||||
{
|
||||
$this->groupCenters->add($groupCenter);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Chill\MainBundle\Entity\GroupCenter $groupCenter
|
||||
* @throws \RuntimeException if the groupCenter is not in the collection
|
||||
*/
|
||||
public function removeGroupCenter(GroupCenter $groupCenter)
|
||||
{
|
||||
if ($this->groupCenters->removeElement($groupCenter) === FALSE) {
|
||||
throw new \RuntimeException(sprintf("The groupCenter could not be removed, "
|
||||
. "it seems not to be associated with the user. Aborting."));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This function check that groupCenter are present only once. The validator
|
||||
* use this function to avoid a user to be associated to the same groupCenter
|
||||
@@ -381,12 +333,12 @@ class User implements AdvancedUserInterface {
|
||||
*/
|
||||
public function isGroupCenterPresentOnce(ExecutionContextInterface $context)
|
||||
{
|
||||
$groupCentersIds = array();
|
||||
$groupCentersIds = [];
|
||||
|
||||
foreach ($this->getGroupCenters() as $groupCenter) {
|
||||
if (in_array($groupCenter->getId(), $groupCentersIds)) {
|
||||
$context->buildViolation("The user has already those permissions")
|
||||
->addViolation();
|
||||
|
||||
$context->buildViolation('The user has already those permissions')
|
||||
->addViolation();
|
||||
} else {
|
||||
$groupCentersIds[] = $groupCenter->getId();
|
||||
}
|
||||
@@ -394,7 +346,20 @@ class User implements AdvancedUserInterface {
|
||||
}
|
||||
|
||||
/**
|
||||
* Set attributes
|
||||
* @param \Chill\MainBundle\Entity\GroupCenter $groupCenter
|
||||
*
|
||||
* @throws RuntimeException if the groupCenter is not in the collection
|
||||
*/
|
||||
public function removeGroupCenter(GroupCenter $groupCenter)
|
||||
{
|
||||
if ($this->groupCenters->removeElement($groupCenter) === false) {
|
||||
throw new RuntimeException(sprintf('The groupCenter could not be removed, '
|
||||
. 'it seems not to be associated with the user. Aborting.'));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set attributes.
|
||||
*
|
||||
* @param array $attributes
|
||||
*
|
||||
@@ -407,107 +372,126 @@ class User implements AdvancedUserInterface {
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get attributes
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getAttributes()
|
||||
{
|
||||
if ($this->attributes === null) {
|
||||
$this->attributes = [];
|
||||
}
|
||||
|
||||
return $this->attributes;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getLabel(): string
|
||||
{
|
||||
return $this->label;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $label
|
||||
* @return User
|
||||
*/
|
||||
public function setLabel(string $label): User
|
||||
{
|
||||
$this->label = $label;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Center|null
|
||||
*/
|
||||
public function getMainCenter(): ?Center
|
||||
{
|
||||
return $this->mainCenter;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Center|null $mainCenter
|
||||
* @return User
|
||||
*/
|
||||
public function setMainCenter(?Center $mainCenter): User
|
||||
{
|
||||
$this->mainCenter = $mainCenter;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Scope|null
|
||||
*/
|
||||
public function getMainScope(): ?Scope
|
||||
{
|
||||
return $this->mainScope;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Scope|null $mainScope
|
||||
* @return User
|
||||
*/
|
||||
public function setMainScope(?Scope $mainScope): User
|
||||
{
|
||||
$this->mainScope = $mainScope;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return UserJob|null
|
||||
*/
|
||||
public function getUserJob(): ?UserJob
|
||||
{
|
||||
return $this->userJob;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param UserJob|null $userJob
|
||||
* @return User
|
||||
*/
|
||||
public function setUserJob(?UserJob $userJob): User
|
||||
{
|
||||
$this->userJob = $userJob;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Location|null
|
||||
*/
|
||||
public function getCurrentLocation(): ?Location
|
||||
{
|
||||
return $this->currentLocation;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Location|null $location
|
||||
* @return User
|
||||
*/
|
||||
public function setCurrentLocation(?Location $currentLocation): User
|
||||
{
|
||||
$this->currentLocation = $currentLocation;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $email
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setEmail($email)
|
||||
{
|
||||
$this->email = $email;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $emailCanonical
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setEmailCanonical($emailCanonical)
|
||||
{
|
||||
$this->emailCanonical = $emailCanonical;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $enabled
|
||||
*/
|
||||
public function setEnabled($enabled)
|
||||
{
|
||||
$this->enabled = $enabled;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setLabel(string $label): User
|
||||
{
|
||||
$this->label = $label;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setMainCenter(?Center $mainCenter): User
|
||||
{
|
||||
$this->mainCenter = $mainCenter;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setMainScope(?Scope $mainScope): User
|
||||
{
|
||||
$this->mainScope = $mainScope;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $password
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setPassword($password)
|
||||
{
|
||||
$this->password = $password;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $salt
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setSalt($salt)
|
||||
{
|
||||
$this->salt = $salt;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setUserJob(?UserJob $userJob): User
|
||||
{
|
||||
$this->userJob = $userJob;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set username.
|
||||
*
|
||||
* @param string $name
|
||||
*
|
||||
* @return Agent
|
||||
*/
|
||||
public function setUsername($name)
|
||||
{
|
||||
$this->username = $name;
|
||||
|
||||
if (empty($this->getLabel())) {
|
||||
$this->setLabel($name);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $usernameCanonical
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setUsernameCanonical($usernameCanonical)
|
||||
{
|
||||
$this->usernameCanonical = $usernameCanonical;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
@@ -1,5 +1,12 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Chill\MainBundle\Entity;
|
||||
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
@@ -9,11 +16,15 @@ use Symfony\Component\Serializer\Annotation as Serializer;
|
||||
* @ORM\Entity
|
||||
* @ORM\Table("chill_main_user_job")
|
||||
* @Serializer\DiscriminatorMap(typeProperty="type", mapping={
|
||||
* "user_job"=UserJob::class
|
||||
* })
|
||||
* "user_job": UserJob::class
|
||||
* })
|
||||
*/
|
||||
class UserJob
|
||||
{
|
||||
/**
|
||||
* @ORM\Column(name="active", type="boolean")
|
||||
*/
|
||||
protected bool $active = true;
|
||||
|
||||
/**
|
||||
* @ORM\Id
|
||||
@@ -30,15 +41,6 @@ class UserJob
|
||||
*/
|
||||
protected array $label = [];
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
* @ORM\Column(name="active", type="boolean")
|
||||
*/
|
||||
protected bool $active = true;
|
||||
|
||||
/**
|
||||
* @return int|null
|
||||
*/
|
||||
public function getId(): ?int
|
||||
{
|
||||
return $this->id;
|
||||
@@ -52,31 +54,25 @@ class UserJob
|
||||
return $this->label;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array|string[] $label
|
||||
* @return UserJob
|
||||
*/
|
||||
public function setLabel(array $label): UserJob
|
||||
{
|
||||
$this->label = $label;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isActive(): bool
|
||||
{
|
||||
return $this->active;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $active
|
||||
* @return UserJob
|
||||
*/
|
||||
public function setActive(bool $active): UserJob
|
||||
{
|
||||
$this->active = $active;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array|string[] $label
|
||||
*/
|
||||
public function setLabel(array $label): UserJob
|
||||
{
|
||||
$this->label = $label;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user