Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- MariaDB [minhqh_rbacflatrole]> desc user;
- +----------+-------------+------+-----+---------+----------------+
- | Field | Type | Null | Key | Default | Extra |
- +----------+-------------+------+-----+---------+----------------+
- | id | int(11) | NO | PRI | NULL | auto_increment |
- | username | varchar(50) | NO | | NULL | |
- | password | varchar(50) | NO | | NULL | |
- +----------+-------------+------+-----+---------+----------------+
- 3 rows in set (0.01 sec)
- MariaDB [minhqh_rbacflatrole]> desc role;
- +-------+--------------+------+-----+---------+----------------+
- | Field | Type | Null | Key | Default | Extra |
- +-------+--------------+------+-----+---------+----------------+
- | id | int(11) | NO | PRI | NULL | auto_increment |
- | name | varchar(100) | NO | | NULL | |
- +-------+--------------+------+-----+---------+----------------+
- 2 rows in set (0.00 sec)
- MariaDB [minhqh_rbacflatrole]> desc user_role;
- +---------+---------+------+-----+---------+----------------+
- | Field | Type | Null | Key | Default | Extra |
- +---------+---------+------+-----+---------+----------------+
- | id | int(11) | NO | PRI | NULL | auto_increment |
- | user_id | int(11) | NO | MUL | NULL | |
- | role_id | int(11) | NO | MUL | NULL | |
- +---------+---------+------+-----+---------+----------------+
- <?php
- namespace Application\Entity;
- use Doctrine\ORM\Mapping as ORM;
- /**
- * User
- *
- * @ORM\Table(name="user")
- * @ORM\Entity
- */
- class User implements \ZfcRbac\Identity\IdentityInterface {
- /**
- * @var integer
- *
- * @ORM\Column(name="id", type="integer", nullable=false)
- * @ORM\Id
- * @ORM\GeneratedValue(strategy="IDENTITY")
- */
- private $id;
- /**
- * @var string
- *
- * @ORM\Column(name="username", type="string", length=50, nullable=false)
- */
- private $username;
- /**
- * @var string
- *
- * @ORM\Column(name="password", type="string", length=50, nullable=false)
- */
- private $password;
- /**
- * @ORM\OneToMany(targetEntity="UserRole", mappedBy="User")
- * @return \Doctrine\Common\Collections\ArrayCollection
- */
- private $userRole;
- public function __construct() {
- $this->userRole = new \Doctrine\Common\Collections\ArrayCollection();
- }
- /**
- * Get id
- *
- * @return integer
- */
- public function getId() {
- return $this->id;
- }
- /**
- * Set username
- *
- * @param string $username
- *
- * @return User
- */
- public function setUsername($username) {
- $this->username = $username;
- return $this;
- }
- /**
- * Get username
- *
- * @return string
- */
- public function getUsername() {
- return $this->username;
- }
- /**
- * Set password
- *
- * @param string $password
- *
- * @return User
- */
- public function setPassword($password) {
- $this->password = $password;
- return $this;
- }
- /**
- * Get password
- *
- * @return string
- */
- public function getPassword() {
- return $this->password;
- }
- /**
- * Get the list of roles of this identity
- *
- * @return string[]|\Rbac\Role\RoleInterface[]
- */
- public function getRoles() {
- return array('admin');
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement