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.     const ROLE_ACCESS_ANALYTICS 'ROLE_ACCESS_ANALYTICS';
  25.     #[ORM\Id]
  26.     #[ORM\Column(name'id'type'integer')]
  27.     #[ORM\GeneratedValue(strategy'AUTO')]
  28.     protected int $id;
  29.     #[ORM\Column(name'email'type'string'length64uniquetrue)]
  30.     protected string $email;
  31.     #[ORM\Column(name'encrypted_password'type'string'length64)]
  32.     protected string $encryptedPassword;
  33.     #[ORM\Column(name'permissions'type'simple_array')]
  34.     protected array $permissions;
  35.     public function __construct(string $emailstring $encryptedPassword, array $permissions = [])
  36.     {
  37.         $this->email $email;
  38.         $this->encryptedPassword $encryptedPassword;
  39.         $this->permissions $permissions;
  40.     }
  41.     /**
  42.      * @inheritDoc
  43.      */
  44.     public function getRoles()
  45.     {
  46.         $permissions $this->permissions;
  47.         $permissions[] = self::ROLE_MINIMUM;
  48.         return array_unique($permissions);
  49.     }
  50.     public function getId(): int
  51.     {
  52.         return $this->id;
  53.     }
  54.     public function getEmail(): string
  55.     {
  56.         return $this->email;
  57.     }
  58.     /**
  59.      * @inheritDoc
  60.      */
  61.     public function getPassword()
  62.     {
  63.         return $this->encryptedPassword;
  64.     }
  65.     /**
  66.      * @inheritDoc
  67.      */
  68.     public function getSalt()
  69.     {
  70.         return null;
  71.     }
  72.     /**
  73.      * @inheritDoc
  74.      */
  75.     public function getUsername()
  76.     {
  77.         return $this->email;
  78.     }
  79.     /**
  80.      * @inheritDoc
  81.      */
  82.     public function eraseCredentials()
  83.     {
  84.     }
  85. }