Advertisement
Guest User

Untitled

a guest
May 18th, 2017
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.95 KB | None | 0 0
  1. namespace Models;
  2.  
  3. /** @Entity @Table(name="user") */
  4. class User extends \My\Model\AbstractModel implements \Zend_Acl_Role_Interface
  5. {
  6.     /**
  7.      * @Id @Column(type="integer")
  8.      * @GeneratedValue(strategy="AUTO")
  9.      */
  10.     protected $id;
  11.    
  12.     /** @Column(type="integer", unsigned=true) */
  13.     protected $role_id;
  14.    
  15.     /** @Column(type="string") */
  16.     protected $username;
  17.    
  18.     /** @Column(type="string") */
  19.     protected $password;
  20.    
  21.     /** @Column(type="string") */
  22.     protected $email;
  23.    
  24.     /** @Column(type="string") */
  25.     protected $date_format;
  26.    
  27.     /** @Column(type="string") */
  28.     protected $time_format;
  29.    
  30.     /** @Column(type="boolean") */
  31.     protected $calendar_start;
  32.    
  33.     /** @Column(type="datetime") */
  34.     protected $created;
  35.    
  36.     /** @Column(type="datetime") */
  37.     protected $updated;
  38.    
  39.     /**
  40.      * @OneToOne(targetEntity="Role")
  41.      * @JoinColumn(name="role_id", referencedColumnName="id")
  42.      */
  43.     protected $role;
  44.    
  45.     /**
  46.      * Initialization
  47.      */
  48.     public function init()
  49.     {
  50.         $this->created = $this->updated = new \DateTime('now');
  51.     }
  52.    
  53.     /**
  54.      * @PreUpdate
  55.      */
  56.     public function updated()
  57.     {
  58.         $this->updated = new \DateTime('now');
  59.     }
  60.    
  61.     /**
  62.      * @return the $id
  63.      */
  64.     public function getId()
  65.     {
  66.         return $this->id;
  67.     }
  68.    
  69.     /**
  70.      * @return the $username
  71.      */
  72.     public function getUsername()
  73.     {
  74.         return $this->username;
  75.     }
  76.    
  77.     /**
  78.      * @return the $password
  79.      */
  80.     public function getPassword()
  81.     {
  82.         return $this->password;
  83.     }
  84.    
  85.     /**
  86.      * @return the $email
  87.      */
  88.     public function getEmail()
  89.     {
  90.         return $this->email;
  91.     }
  92.    
  93.     /**
  94.      * @return the $calendar_start
  95.      */
  96.     public function getCalendarStart()
  97.     {
  98.         return $this->calendar_start;
  99.     }
  100.    
  101.     /**
  102.      * @return $role_id
  103.      */
  104.     public function getRoleId()
  105.     {
  106.         return $this->role->getName();
  107.     }
  108.    
  109.     /**
  110.      * @return the $role
  111.      */
  112.     public function getRole()
  113.     {
  114.         return $this->role;
  115.     }
  116.    
  117.     /**
  118.      * @param $id the $id to set
  119.      */
  120.     public function setId($id)
  121.     {
  122.         $this->id = $id;
  123.         return $this;
  124.     }
  125.    
  126.     /**
  127.      * @param $username the $username to set
  128.      */
  129.     public function setUsername($username)
  130.     {
  131.         $this->username = $username;
  132.         return $this;
  133.     }
  134.    
  135.     /**
  136.      * @param $password the $password to set
  137.      */
  138.     public function setPassword($password)
  139.     {
  140.         $this->password = $password;
  141.         return $this;
  142.     }
  143.    
  144.     /**
  145.      * @param $email the $email to set
  146.      */
  147.     public function setEmail($email)
  148.     {
  149.         $this->email = $email;
  150.         return $this;
  151.     }
  152.    
  153.     /**
  154.      * @param $calendar_start the $calendar_start to set
  155.      */
  156.     public function setCalendarStart($calendar_start)
  157.     {
  158.         $this->calendar_start = $calendar_start;
  159.         return $this;
  160.     }
  161.    
  162.     /**
  163.      * @param $role the $role to set
  164.      */
  165.     public function setRole($role)
  166.     {
  167.         $this->role = $role;
  168.         return $this;
  169.     }
  170.    
  171.     /**
  172.      * Callback for determining if role is valid
  173.      *
  174.      * @param mixed $value
  175.      * @return true if $value is an instance of \Models\Role
  176.      */
  177.     public function cbIsRole($value)
  178.     {
  179.         return $value instanceof Role;
  180.     }
  181. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement