HosipLan

Untitled

Aug 5th, 2011
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.62 KB | None | 0 0
  1. <?php
  2.  
  3.  
  4. use Doctrine\Common\Collections\Collection;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6.  
  7.  
  8.  
  9. /**
  10.  * @Entity
  11.  */
  12. class Book
  13. {
  14.     /**
  15.      * @var integer
  16.      * @Column(type="integer")
  17.      */
  18.     private $id;
  19.  
  20.     /**
  21.      * @var string
  22.      * @Column(type="string")
  23.      */
  24.     private $title;
  25.  
  26.     /**
  27.      * @var string
  28.      * @Column(type="string")
  29.      */
  30.     private $genre;
  31.  
  32.     /**
  33.      * @var Collection
  34.      * @ManyToMany(targetEntity="Option")
  35.      * @JoinTable(name="books_options", joinColumns={@JoinColumn(name="option_id", referencedColumnName="id"), unique=TRUE}, inverseJoinColumns={@JoinColumn(name="book_id", referencedColumnName="id")})
  36.      */
  37.     private $options;
  38.  
  39.  
  40.  
  41.     public function __construct()
  42.     {
  43.         $this->options = new ArrayCollection();
  44.     }
  45.  
  46.  
  47.  
  48.     /**
  49.      * @return integer
  50.      */
  51.     public function getId()
  52.     {
  53.         return $this->id;
  54.     }
  55.  
  56.  
  57.  
  58.     /**
  59.      * @param integer $id
  60.      * @return Book
  61.      */
  62.     public function setId($id)
  63.     {
  64.         $this->id = $id;
  65.         return $this;
  66.     }
  67.  
  68.  
  69.  
  70.     /**
  71.      * @return string
  72.      */
  73.     public function getTitle()
  74.     {
  75.         return $this->title;
  76.     }
  77.  
  78.  
  79.  
  80.     /**
  81.      * @param string $title
  82.      * @return Book
  83.      */
  84.     public function setTitle($title)
  85.     {
  86.         $this->title = $title;
  87.         return $this;
  88.     }
  89.  
  90.  
  91.  
  92.     /**
  93.      * @return string
  94.      */
  95.     public function getGenre()
  96.     {
  97.         return $this->genre;
  98.     }
  99.  
  100.  
  101.  
  102.     /**
  103.      * @param string $genre
  104.      * @return Book
  105.      */
  106.     public function setGenre($genre)
  107.     {
  108.         $this->genre = $genre;
  109.         return $this;
  110.     }
  111.  
  112.  
  113.  
  114.     /**
  115.      * @param Option $option
  116.      * @return Book
  117.      */
  118.     public function addOption(Option $option)
  119.     {
  120.         $this->options->add($option);
  121.         return $this;
  122.     }
  123.  
  124.  
  125.  
  126.     /**
  127.      * @param Option $option
  128.      * @return Book
  129.      */
  130.     public function removeOption(Option $option)
  131.     {
  132.         $this->options->removeElement($option);
  133.         return $this;
  134.     }
  135.  
  136.  
  137.  
  138.     /**
  139.      * @return array
  140.      */
  141.     public function getOptions()
  142.     {
  143.         return $this->options->toArray();
  144.     }
  145.  
  146. }
  147.  
  148.  
  149.  
  150. <?php
  151.  
  152.  
  153.  
  154.  
  155.  
  156. /**
  157.  * @Entity
  158.  */
  159. class Option
  160. {
  161.     /**
  162.      * @var integer
  163.      * @Column(type="integer")
  164.      */
  165.     private $id;
  166.  
  167.     /**
  168.      * @var string
  169.      * @Column(type="string")
  170.      */
  171.     private $description;
  172.  
  173.  
  174.  
  175.     /**
  176.      * @return integer
  177.      */
  178.     public function getId()
  179.     {
  180.         return $this->id;
  181.     }
  182.  
  183.  
  184.  
  185.     /**
  186.      * @param integer $id
  187.      * @return Option
  188.      */
  189.     public function setId($id)
  190.     {
  191.         $this->id = $id;
  192.         return $this;
  193.     }
  194.  
  195.  
  196.  
  197.     /**
  198.      * @return string
  199.      */
  200.     public function getDescription()
  201.     {
  202.         return $this->description;
  203.     }
  204.  
  205.  
  206.  
  207.     /**
  208.      * @param string $description
  209.      * @return Option
  210.      */
  211.     public function setDescription($description)
  212.     {
  213.         $this->description = $description;
  214.         return $this;
  215.     }
  216.  
  217. }
Advertisement
Add Comment
Please, Sign In to add comment