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\Partner\Partner;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Sylius\Component\Core\Model\AdminUser as BaseAdminUser;
  8. use Sylius\RbacPlugin\Entity\AdministrationRoleAwareInterface;
  9. use Sylius\RbacPlugin\Entity\AdministrationRoleAwareTrait;
  10. use Sylius\RbacPlugin\Entity\AdministrationRoleInterface;
  11. /**
  12.  * @ORM\Entity
  13.  * @ORM\Table(name="sylius_admin_user")
  14.  */
  15. class AdminUser extends BaseAdminUser implements AdministrationRoleAwareInterface
  16. {
  17.     use AdministrationRoleAwareTrait;
  18.     /**
  19.      * @var Partner
  20.      *
  21.      * @ORM\ManyToOne(targetEntity="App\Entity\Partner\Partner")
  22.      * @ORM\JoinColumn(name="partner_id", referencedColumnName="id")
  23.      */
  24.     private $partner;
  25.     /**
  26.      * @var CustomRoleRule
  27.      *
  28.      * @ORM\ManyToOne(targetEntity="App\Entity\User\CustomRoleRule")
  29.      * @ORM\JoinColumn(name="custom_role_rule_id", referencedColumnName="id")
  30.      */
  31.     private $customRoleRule;
  32.     /**
  33.      * @var Collection
  34.      * @ORM\OneToMany(targetEntity="App\Entity\Reports\ReportOrderProductsLog", mappedBy="adminUser")
  35.      * @ORM\JoinColumn(name="id", referencedColumnName="admin_user_id")
  36.      */
  37.     private $reportOrderProductsLogs;
  38.     public function getAdministrationRole(): ?AdministrationRoleInterface
  39.     {
  40.         return $this->administrationRole;
  41.     }
  42.     public function setAdministrationRole(?AdministrationRoleInterface $administrationRole): void
  43.     {
  44.         $this->administrationRole $administrationRole;
  45.     }
  46.     public function hasPermission(string $type): bool
  47.     {
  48.         $permissions $this->getAdministrationRole()->getPermissions();
  49.         foreach ($permissions as $permission) {
  50.             if ($permission->type() === $type) {
  51.                 return true;
  52.             }
  53.         }
  54.         return false;
  55.     }
  56.     public function getPartner(): ?Partner
  57.     {
  58.         return $this->partner;
  59.     }
  60.     public function setPartner(?Partner $partner): self
  61.     {
  62.         $this->partner $partner;
  63.         return $this;
  64.     }
  65.     public function getCustomRoleRule(): ?CustomRoleRule
  66.     {
  67.         return $this->customRoleRule;
  68.     }
  69.     public function setCustomRoleRule(?CustomRoleRule $customRoleRule): self
  70.     {
  71.         $this->customRoleRule $customRoleRule;
  72.         return $this;
  73.     }
  74. }