src/Entity/User/AdminUser.php line 19

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace App\Entity\User;
  4. use App\Entity\Customer\CustomerNoteInterface;
  5. use App\Entity\Order\OrderNoteInterface;
  6. use DH\SyliusAccessControlPlugin\Entity\AdministrationGroupAwareTrait;
  7. use Doctrine\Common\Collections\ArrayCollection;
  8. use Doctrine\Common\Collections\Collection;
  9. use Doctrine\ORM\Mapping as ORM;
  10. use Sylius\Component\Core\Model\AdminUser as BaseAdminUser;
  11. /**
  12.  * @ORM\Entity
  13.  * @ORM\Table(name="sylius_admin_user")
  14.  */
  15. class AdminUser extends BaseAdminUser
  16. {
  17.     use AdministrationGroupAwareTrait;
  18.     /**
  19.      * @ORM\OneToMany(
  20.      *     targetEntity="App\Entity\Order\OrderNote",
  21.      *     mappedBy="author",
  22.      *     cascade={"persist"},
  23.      *     orphanRemoval=true
  24.      * )
  25.      * @ORM\JoinColumn(
  26.      *     onDelete="CASCADE",
  27.      *     nullable=false
  28.      * )
  29.      */
  30.     protected $orderNotes;
  31.     /**
  32.      * @ORM\OneToMany(
  33.      *     targetEntity="App\Entity\Customer\CustomerNote",
  34.      *     mappedBy="author",
  35.      *     cascade={"persist"},
  36.      *     orphanRemoval=true
  37.      * )
  38.      * @ORM\JoinColumn(
  39.      *     onDelete="CASCADE",
  40.      *     nullable=false
  41.      * )
  42.      */
  43.     protected $customerNotes;
  44.     /**
  45.      * @ORM\OneToMany(
  46.      *     targetEntity="App\Entity\Order\Order",
  47.      *     mappedBy="adminUser",
  48.      *     cascade={"persist"}
  49.      * )
  50.      * @ORM\JoinColumn(
  51.      *     nullable=true
  52.      * )
  53.      */
  54.     protected $orders;
  55.     public function __construct()
  56.     {
  57.         parent::__construct();
  58.         $this->orderNotes = new ArrayCollection();
  59.         $this->customerNotes = new ArrayCollection();
  60.         $this->orders = new ArrayCollection();
  61.     }
  62.     public function getOrderNotes(): Collection
  63.     {
  64.         return $this->orderNotes;
  65.     }
  66.     public function addOrderNote(OrderNoteInterface $orderNote): self
  67.     {
  68.         if (!$this->hasOrderNote($orderNote)) {
  69.             $orderNote->setAuthor($this);
  70.             $this->orderNotes->add($orderNote);
  71.         }
  72.         return $this;
  73.     }
  74.     public function removeOrderNote(OrderNoteInterface $orderNote): self
  75.     {
  76.         if ($this->hasOrderNote($orderNote)) {
  77.             $this->orderNotes->removeElement($orderNote);
  78.             $orderNote->setAuthor(null);
  79.         }
  80.         return $this;
  81.     }
  82.     public function hasOrderNote(OrderNoteInterface $orderNote): bool
  83.     {
  84.         return $this->orderNotes->contains($orderNote);
  85.     }
  86.     public function getCustomerNotes(): Collection
  87.     {
  88.         return $this->customerNotes;
  89.     }
  90.     public function addCustomerNote(CustomerNoteInterface $customerNote): self
  91.     {
  92.         if (!$this->hasCustomerNote($customerNote)) {
  93.             $customerNote->setAuthor($this);
  94.             $this->customerNotes->add($customerNote);
  95.         }
  96.         return $this;
  97.     }
  98.     public function removeCustomerNote(CustomerNoteInterface $customerNote): self
  99.     {
  100.         if ($this->hasCustomerNote($customerNote)) {
  101.             $this->customerNotes->removeElement($customerNote);
  102.             $customerNote->setAuthor(null);
  103.         }
  104.         return $this;
  105.     }
  106.     public function hasCustomerNote(CustomerNoteInterface $customerNote): bool
  107.     {
  108.         return $this->customerNotes->contains($customerNote);
  109.     }
  110.     public function getOrders(): Collection
  111.     {
  112.         return $this->orders;
  113.     }
  114. }