mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-20 22:53:49 +00:00
Handle parent deletion in associated tables (ThirdPartyBundle)
This commit is contained in:
@@ -32,9 +32,9 @@ use Symfony\Component\Serializer\Annotation\DiscriminatorMap;
|
||||
|
||||
/**
|
||||
* ThirdParty is a party recorded in the database.
|
||||
*
|
||||
* A party may be attached to multiple centers. Being attach to a center allow
|
||||
* all users with the right 'CHILL_3PARTY_3PARTY_SEE', 'CHILL_3PARTY_3 to see, select and edit parties for this
|
||||
*
|
||||
* A party may be attached to multiple centers. Being attach to a center allow
|
||||
* all users with the right 'CHILL_3PARTY_3PARTY_SEE', 'CHILL_3PARTY_3 to see, select and edit parties for this
|
||||
* center.
|
||||
*
|
||||
* @ORM\Table(name="chill_3party.third_party")
|
||||
@@ -66,7 +66,7 @@ class ThirdParty
|
||||
* @var string|null
|
||||
*
|
||||
* @ORM\Column(name="telephone", type="string", length=64, nullable=true)
|
||||
* @Assert\Regex("/^([\+{1}])([0-9\s*]{4,20})$/",
|
||||
* @Assert\Regex("/^([\+{1}])([0-9\s*]{4,20})$/",
|
||||
* message="Invalid phone number: it should begin with the international prefix starting with ""+"", hold only digits and be smaller than 20 characters. Ex: +33123456789"
|
||||
* )
|
||||
*/
|
||||
@@ -94,13 +94,13 @@ class ThirdParty
|
||||
* @Assert\Count(min=1)
|
||||
*/
|
||||
private $type;
|
||||
|
||||
|
||||
/**
|
||||
* @var boolean
|
||||
* @ORM\Column(name="active", type="boolean", options={"defaut": true})
|
||||
*/
|
||||
private $active = true;
|
||||
|
||||
|
||||
/**
|
||||
* @var Collection instances of Center
|
||||
* @ORM\ManyToMany(targetEntity="\Chill\MainBundle\Entity\Center")
|
||||
@@ -108,14 +108,15 @@ class ThirdParty
|
||||
* @Assert\Count(min=1)
|
||||
*/
|
||||
private $centers;
|
||||
|
||||
|
||||
/**
|
||||
* @var Address|null
|
||||
* @ORM\ManyToOne(targetEntity="\Chill\MainBundle\Entity\Address",
|
||||
* cascade={"persist", "remove"})
|
||||
* @ORM\JoinColumn(nullable=true, onDelete="SET NULL")
|
||||
*/
|
||||
private $address;
|
||||
|
||||
|
||||
/**
|
||||
* ThirdParty constructor.
|
||||
*/
|
||||
@@ -249,7 +250,7 @@ class ThirdParty
|
||||
{
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
@@ -257,7 +258,7 @@ class ThirdParty
|
||||
{
|
||||
return $this->active;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return Collection
|
||||
*/
|
||||
@@ -265,7 +266,7 @@ class ThirdParty
|
||||
{
|
||||
return $this->centers;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param bool $active
|
||||
* @return $this
|
||||
@@ -275,7 +276,7 @@ class ThirdParty
|
||||
$this->active = $active;
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Center $center
|
||||
*/
|
||||
@@ -285,7 +286,7 @@ class ThirdParty
|
||||
$this->centers->add($center);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Center $center
|
||||
*/
|
||||
@@ -295,7 +296,7 @@ class ThirdParty
|
||||
$this->centers->removeElement($center);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Collection $centers
|
||||
* @return $this
|
||||
@@ -305,16 +306,16 @@ class ThirdParty
|
||||
foreach ($centers as $center) {
|
||||
$this->addCenter($center);
|
||||
}
|
||||
|
||||
|
||||
foreach ($this->centers as $center) {
|
||||
if (FALSE === $centers->contains($center)) {
|
||||
$this->removeCenter($center);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return Address|null
|
||||
*/
|
||||
@@ -322,7 +323,7 @@ class ThirdParty
|
||||
{
|
||||
return $this->address;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Address $address
|
||||
* @return $this
|
||||
@@ -330,10 +331,10 @@ class ThirdParty
|
||||
public function setAddress(Address $address)
|
||||
{
|
||||
$this->address = $address;
|
||||
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
|
Reference in New Issue
Block a user