1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<?php
namespace App\Entity;
use App\Flux\AccountableInterface;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
/**
* @ORM\Entity()
* @ORM\Table(name="account_adherent", uniqueConstraints={@ORM\UniqueConstraint(name="adherentcurrency", columns={"adherent_id", "currency"})})
* @ORM\HasLifecycleCallbacks()
* @UniqueEntity(
* fields={"adherent", "currency"},
* errorPath="adherent",
* message="Le compte de l'adherent existe déjà."
* )
*/
class AccountAdherent extends Account
{
/**
* @ORM\ManyToOne(targetEntity=Adherent::class, inversedBy="accounts", cascade={"persist", "remove"})
* @ORM\JoinColumn(name="adherent_id", referencedColumnName="id", nullable=false)
*/
private $adherent;
/**
* @var ArrayCollection|OperationAdherent[]
* @ORM\OneToMany(targetEntity=OperationAdherent::class, mappedBy="account")
*/
protected $operations;
public function __construct()
{
$this->operations = new ArrayCollection();
}
public function getAdherent(): ?Adherent
{
return $this->adherent;
}
public function setAdherent(Adherent $adherent): self
{
$this->adherent = $adherent;
return $this;
}
public function setAccountableObject(AccountableInterface $object): self
{
return $this->setAdherent($object);
}
public function getAccountableObject(): AccountableInterface
{
return $this->getAdherent();
}
public function __toString(): string
{
return 'AccountAdherent ' . $this->getAdherent();
}
}