|
- <?php
-
- namespace Lc\CaracoleBundle\Model\User;
-
- use Doctrine\Common\Collections\ArrayCollection;
- use Doctrine\Common\Collections\Collection;
- use Doctrine\ORM\Mapping as ORM;
- use Lc\CaracoleBundle\Doctrine\Extension\FilterMerchantInterface;
- use Lc\CaracoleBundle\Model\Merchant\MerchantInterface;
- use Lc\CaracoleBundle\Model\Section\OpeningInterface;
- use Lc\SovBundle\Model\User\GroupUserModel as SovGroupUserModel;
-
- /**
- * @ORM\MappedSuperclass()
- */
- abstract class GroupUserModel extends SovGroupUserModel implements FilterMerchantInterface
- {
- /**
- * @ORM\ManyToOne(targetEntity="Lc\CaracoleBundle\Model\Merchant\MerchantInterface", inversedBy="groupUsers")
- * @ORM\JoinColumn(nullable=false)
- */
- protected $merchant;
-
- /**
- * @ORM\OneToMany(targetEntity="Lc\CaracoleBundle\Model\Section\OpeningInterface", mappedBy="groupUser")
- */
- protected $openings;
-
- public function __construct()
- {
- parent::__construct();
- $this->openings = new ArrayCollection();
- }
-
- public function getMerchant(): MerchantInterface
- {
- return $this->merchant;
- }
-
- public function setMerchant(MerchantInterface $merchant): self
- {
- $this->merchant = $merchant;
-
- return $this;
- }
-
- /**
- * @return Collection|OpeningInterface[]
- */
- public function getOpenings(): Collection
- {
- return $this->openings;
- }
-
- public function addOpening(OpeningInterface $opening): self
- {
- if (!$this->openings->contains($opening)) {
- $this->openings[] = $opening;
- $opening->setGroupUser($this);
- }
-
- return $this;
- }
-
- public function removeOpening(OpeningInterface $opening): self
- {
- if ($this->openings->removeElement($opening)) {
- // set the owning side to null (unless already changed)
- if ($opening->getGroupUser() === $this) {
- $opening->setGroupUser(null);
- }
- }
-
- return $this;
- }
-
- }
|