Jafix

Event.php (Model)

Mar 8th, 2013
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.89 KB | None | 0 0
  1. <?php
  2. namespace Jpg\Events\Domain\Model;
  3.  
  4. /*                                                                        *
  5.  * This script belongs to the TYPO3 Flow package "Jpg.Events".           *
  6.  *                                                                        *
  7.  *                                                                        */
  8.  
  9. use TYPO3\Flow\Annotations as Flow;
  10. use Doctrine\ORM\Mapping as ORM;
  11.  
  12. /**
  13.  * A Event
  14.  *
  15.  * @Flow\Entity
  16.  */
  17. class Event {
  18.  
  19.     /**
  20.      * The title
  21.      * @var string
  22.      * @Flow\Validate(type="NotEmpty")
  23.      * @Flow\Validate(type="String")
  24.      * @Flow\Validate(type="StringLength", options={ "minimum"=5, "maximum"=100 })
  25.      */
  26.     protected $title;
  27.  
  28.     /**
  29.     * @var \Jpg\Events\Domain\Model\Location
  30.     * @ORM\ManyToOne
  31.     */
  32.     protected $location;
  33.  
  34.     /**
  35.     * @var \Doctrine\Common\Collections\Collection<\Jpg\Events\Domain\Model\Person>
  36.     * @ORM\ManyToMany(inversedBy="events")
  37.     */
  38.     protected $persons;
  39.  
  40.     /**
  41.      * Constructs this event
  42.      */
  43.     public function __construct() {
  44.         //Only for properties which have a @var \Doctrine\Common\Collections\Collection<...> or non Standard Annotation ???
  45.         //$this->persons = new \Doctrine\Common\Collections\ArrayCollection();
  46.         $this->persons = new \Doctrine\Common\Collections\ArrayCollection();
  47.     }
  48.  
  49.     /**
  50.      * Get the Event's title
  51.      *
  52.      * @return string The Event's title
  53.      */
  54.     public function getTitle() {
  55.         return $this->title;
  56.     }
  57.  
  58.     /**
  59.      * Sets this Event's title
  60.      *
  61.      * @param string $title The Event's title
  62.      * @return void
  63.      */
  64.     public function setTitle($title) {
  65.         $this->title = $title;
  66.     }
  67.  
  68.     /**
  69.     * setter for location
  70.     *
  71.     * @param \Jpg\Events\Domain\Model\Location $location
  72.     * @return void
  73.     */
  74.     public function setLocation($location) {
  75.         $this->location = $location;
  76.     }
  77.  
  78.     /**
  79.     * getter for location
  80.     *
  81.     * @return \Jpg\Events\Domain\Model\Location
  82.     */
  83.     public function getLocation() {
  84.         return $this->location;
  85.     }
  86.  
  87.     /**
  88.      * Setter for person
  89.      *
  90.      * @param \Doctrine\Common\Collections\Collection<\Jpg\Events\Domain\Model\Person> $persons The attending persons
  91.      * @return void
  92.      */
  93.     public function setPersons(\Doctrine\Common\Collections\Collection $persons) {
  94.         $this->persons = clone $persons;
  95.     }
  96.  
  97.     /**
  98.      * Adds a person to this event
  99.      *
  100.      * @param \Jpg\Events\Domain\Model\Person $person
  101.      * @return void
  102.      */
  103.     public function addPerson(\Jpg\Events\Domain\Model\Person $person) {
  104.         $this->persons->add($person);
  105.     }
  106.  
  107.     /**
  108.      * Removes a person to this event
  109.      *
  110.      * @param \Jpg\Events\Domain\Model\Person $person
  111.      * @return void
  112.      */
  113.     public function removePerson(\Jpg\Events\Domain\Model\Person $person) {
  114.         $this->persons->remove($person);
  115.     }
  116.  
  117.     /**
  118.      * Getter for persons
  119.      *
  120.      * @return \Doctrine\Common\Collections\Collection<\Jpg\Events\Domain\Model\Person> The attending persons
  121.      */
  122.     public function getPersons() {
  123.         return clone $this->persons;
  124.     }
  125.  
  126. }
  127. ?>
Advertisement
Add Comment
Please, Sign In to add comment