Advertisement
Puzo

Untitled

Jan 21st, 2012
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.97 KB | None | 0 0
  1. <?php
  2. namespace Entities;
  3. use \Doctrine\ORM\Mapping as ORM;
  4. use \Doctrine\Common\Collections\ArrayCollection as ArrayCollection;
  5.  
  6.  
  7. /**
  8.  * @ORM\HasLifeCycleCallbacks
  9.  * @ORM\Entity
  10.  * @ORM\Table(name="player")
  11.  */
  12. class Player {
  13.     /**
  14.      * @ORM\Id
  15.      * @ORM\Column(type="integer", nullable=false)
  16.      * @ORM\GeneratedValue(strategy="AUTO")
  17.      */
  18.     protected $id;
  19.    
  20.     /**
  21.      * @ORM\Column(type="string", length="255", nullable=false)
  22.      */
  23.     protected $name;
  24.    
  25.     /**
  26.      * @ORM\Column(type="integer", length="1", nullable=false)
  27.      */
  28.     protected $is_gk = 0;
  29.    
  30.     /**
  31.      * @ORM\Column(type="datetime", nullable=false)
  32.      */
  33.     protected $cdate;
  34.    
  35.     /**
  36.      * @ORM\Column(type="datetime", nullable=false)
  37.      */
  38.     protected $mdate;
  39.      
  40.     /**
  41.      * @ORM\ManyToOne(targetEntity="Club", inversedBy="players")
  42.      * @ORM\JoinColumn(name="club_id", referencedColumnName="id")
  43.      * @var Club
  44.      */
  45.     protected $club;
  46.    
  47.    
  48.    
  49.     public function __construct()
  50.     {
  51.         $this->club = new ArrayCollection();
  52.        
  53.         $this->cdate = new DateTime();
  54.     }
  55.    
  56.    
  57.     // GETTERS & SETTERS
  58.     public function getId()
  59.     {
  60.         return $this->id;
  61.     }
  62.    
  63.     public function setName($name) {
  64.         $this->name = $name;
  65.     }
  66.      
  67.     public function getName() {
  68.         return $this->name;
  69.     }
  70.    
  71.     public function setGk($is_gk) {
  72.         $this->is_gk = (int)$is_gk;
  73.     }
  74.      
  75.     public function getGk() {
  76.         return $this->is_gk;
  77.     }
  78.    
  79.     /** @PrePersist */
  80.     public function setCdate()
  81.     {
  82.         $this->cdate = new DateTime("now");
  83.     }
  84.      
  85.     public function getCdate() {
  86.         return $this->cdate;
  87.     }
  88.    
  89.     public function setMdate($date) {
  90.         $this->mdate = $date;
  91.     }
  92.      
  93.     public function getMdate() {
  94.         return $this->mdate;
  95.     }
  96.    
  97.     public function setClub(Club $club)
  98.     {
  99.         if( $club === null || $club instanceof Club ) {
  100.             $this->club = $club;
  101.         } else {
  102.             throw new InvalidArgumentException($club . ' must be instance of Entity\Club or null');
  103.         }
  104.     }
  105.    
  106.     public function getClub()
  107.     {
  108.         return $this->club;
  109.     }
  110. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement