Advertisement
sheperson

Untitled

Feb 17th, 2012
395
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.36 KB | None | 0 0
  1. class Item
  2. {
  3.     /**
  4.      * @ORM\ManyToMany(targetEntity="Category", inversedBy="items", cascade={"persist"})
  5.      * @ORM\JoinTable(name="item_category",
  6.      * joinColumns={@ORM\JoinColumn(name="item_id", referencedColumnName="id")},
  7.      * inverseJoinColumns={@ORM\JoinColumn(name="category_id", referencedColumnName="id")}
  8.      * )
  9.      */
  10.     private $categories;
  11.  
  12.     /**
  13.      * Add categories
  14.      *
  15.      * @param Ako\StoreBundle\Entity\Category $categories
  16.      */
  17.     public function addCategories(\Ako\StoreBundle\Entity\Category $categories)
  18.     {
  19.         $this->categories[] = $categories;
  20.     }
  21.  
  22.     /**
  23.      * Get categories
  24.      *
  25.      * @return Doctrine\Common\Collections\Collection
  26.      */
  27.     public function getCategories()
  28.     {
  29.         return $this->categories;
  30.     }
  31. }
  32.  
  33. class Category implements ChoiceListInterface
  34. {
  35.     /**
  36.      * @ORM\ManyToMany(targetEntity="Item", mappedBy="categories", cascade={"persist"})
  37.      */
  38.     private $items;
  39.  
  40.     /**
  41.      * Add items
  42.      *
  43.      * @param Ako\StoreBundle\Entity\Item $items
  44.      */
  45.     public function addItems(\Ako\StoreBundle\Entity\Item $items)
  46.     {
  47.         $this->items[] = $items;
  48.     }
  49.  
  50.     /**
  51.      * Get items
  52.      *
  53.      * @return Doctrine\Common\Collections\Collection
  54.      */    
  55.     public function getItems()
  56.     {
  57.         return $this->items;
  58.     }
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement