src/Entity/Management/StaffAccount.php line 15

Open in your IDE?
  1. <?php
  2. /**
  3.  * Created by simpson <simpsonwork@gmail.com>
  4.  * Date: 2019-04-26
  5.  * Time: 11:14
  6.  */
  7. namespace App\Entity\Management;
  8. use Doctrine\ORM\Mapping as ORM;
  9. use Symfony\Component\Security\Core\User\UserInterface;
  10. #[ORM\Table(name'staff_accounts')]
  11. #[ORM\Entity]
  12. class StaffAccount implements UserInterface
  13. {
  14.     const ROLE_MINIMUM 'ROLE_ADMIN';
  15.     const ROLE_ACCESS_ALL 'ROLE_ADMIN_ACCESS_ALL';
  16.     const ROLE_ACCESS_ACCOUNTS 'ROLE_ADMIN_ACCESS_ACCOUNTS';
  17.     const ROLE_ACCESS_PROFILES 'ROLE_ADMIN_ACCESS_PROFILES';
  18.     const ROLE_ACCESS_SALES 'ROLE_ADMIN_ACCESS_SALES';
  19.     const ROLE_ACCESS_SEO 'ROLE_ADMIN_ACCESS_SEO';
  20.     const ROLE_ACCESS_LOCATION 'ROLE_ADMIN_ACCESS_LOCATION';
  21.     const ROLE_ACCESS_DELETED 'ROLE_ADMIN_ACCESS_DELETED';
  22.     const ROLE_ACCESS_OTHER 'ROLE_ADMIN_ACCESS_OTHER';
  23.     const ROLE_ACCESS_WALKER 'ROLE_ACCESS_WALKER';
  24.     #[ORM\Id]
  25.     #[ORM\Column(name'id'type'integer')]
  26.     #[ORM\GeneratedValue(strategy'AUTO')]
  27.     protected int $id;
  28.     #[ORM\Column(name'email'type'string'length64uniquetrue)]
  29.     protected string $email;
  30.     #[ORM\Column(name'encrypted_password'type'string'length64)]
  31.     protected string $encryptedPassword;
  32.     #[ORM\Column(name'permissions'type'simple_array')]
  33.     protected array $permissions;
  34.     public function __construct(string $emailstring $encryptedPassword, array $permissions = [])
  35.     {
  36.         $this->email $email;
  37.         $this->encryptedPassword $encryptedPassword;
  38.         $this->permissions $permissions;
  39.     }
  40.     /**
  41.      * @inheritDoc
  42.      */
  43.     public function getRoles()
  44.     {
  45.         $permissions $this->permissions;
  46.         $permissions[] = self::ROLE_MINIMUM;
  47.         return array_unique($permissions);
  48.     }
  49.     public function getId(): int
  50.     {
  51.         return $this->id;
  52.     }
  53.     public function getEmail(): string
  54.     {
  55.         return $this->email;
  56.     }
  57.     /**
  58.      * @inheritDoc
  59.      */
  60.     public function getPassword()
  61.     {
  62.         return $this->encryptedPassword;
  63.     }
  64.     /**
  65.      * @inheritDoc
  66.      */
  67.     public function getSalt()
  68.     {
  69.         return null;
  70.     }
  71.     /**
  72.      * @inheritDoc
  73.      */
  74.     public function getUsername()
  75.     {
  76.         return $this->email;
  77.     }
  78.     /**
  79.      * @inheritDoc
  80.      */
  81.     public function eraseCredentials()
  82.     {
  83.     }
  84. }