<?php
declare(strict_types=1);
namespace App\Entity\User;
use App\Entity\Customer\CustomerNoteInterface;
use App\Entity\Order\OrderNoteInterface;
use DH\SyliusAccessControlPlugin\Entity\AdministrationGroupAwareTrait;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Sylius\Component\Core\Model\AdminUser as BaseAdminUser;
/**
* @ORM\Entity
* @ORM\Table(name="sylius_admin_user")
*/
class AdminUser extends BaseAdminUser
{
use AdministrationGroupAwareTrait;
/**
* @ORM\OneToMany(
* targetEntity="App\Entity\Order\OrderNote",
* mappedBy="author",
* cascade={"persist"},
* orphanRemoval=true
* )
* @ORM\JoinColumn(
* onDelete="CASCADE",
* nullable=false
* )
*/
protected $orderNotes;
/**
* @ORM\OneToMany(
* targetEntity="App\Entity\Customer\CustomerNote",
* mappedBy="author",
* cascade={"persist"},
* orphanRemoval=true
* )
* @ORM\JoinColumn(
* onDelete="CASCADE",
* nullable=false
* )
*/
protected $customerNotes;
/**
* @ORM\OneToMany(
* targetEntity="App\Entity\Order\Order",
* mappedBy="adminUser",
* cascade={"persist"}
* )
* @ORM\JoinColumn(
* nullable=true
* )
*/
protected $orders;
public function __construct()
{
parent::__construct();
$this->orderNotes = new ArrayCollection();
$this->customerNotes = new ArrayCollection();
$this->orders = new ArrayCollection();
}
public function getOrderNotes(): Collection
{
return $this->orderNotes;
}
public function addOrderNote(OrderNoteInterface $orderNote): self
{
if (!$this->hasOrderNote($orderNote)) {
$orderNote->setAuthor($this);
$this->orderNotes->add($orderNote);
}
return $this;
}
public function removeOrderNote(OrderNoteInterface $orderNote): self
{
if ($this->hasOrderNote($orderNote)) {
$this->orderNotes->removeElement($orderNote);
$orderNote->setAuthor(null);
}
return $this;
}
public function hasOrderNote(OrderNoteInterface $orderNote): bool
{
return $this->orderNotes->contains($orderNote);
}
public function getCustomerNotes(): Collection
{
return $this->customerNotes;
}
public function addCustomerNote(CustomerNoteInterface $customerNote): self
{
if (!$this->hasCustomerNote($customerNote)) {
$customerNote->setAuthor($this);
$this->customerNotes->add($customerNote);
}
return $this;
}
public function removeCustomerNote(CustomerNoteInterface $customerNote): self
{
if ($this->hasCustomerNote($customerNote)) {
$this->customerNotes->removeElement($customerNote);
$customerNote->setAuthor(null);
}
return $this;
}
public function hasCustomerNote(CustomerNoteInterface $customerNote): bool
{
return $this->customerNotes->contains($customerNote);
}
public function getOrders(): Collection
{
return $this->orders;
}
}