Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- use Doctrine\Common\Collections\Collection;
- use Doctrine\Common\Collections\ArrayCollection;
- /**
- * @Entity
- */
- class Book
- {
- /**
- * @var integer
- * @Column(type="integer")
- */
- private $id;
- /**
- * @var string
- * @Column(type="string")
- */
- private $title;
- /**
- * @var string
- * @Column(type="string")
- */
- private $genre;
- /**
- * @var Collection
- * @ManyToMany(targetEntity="Option")
- * @JoinTable(name="books_options", joinColumns={@JoinColumn(name="option_id", referencedColumnName="id"), unique=TRUE}, inverseJoinColumns={@JoinColumn(name="book_id", referencedColumnName="id")})
- */
- private $options;
- public function __construct()
- {
- $this->options = new ArrayCollection();
- }
- /**
- * @return integer
- */
- public function getId()
- {
- return $this->id;
- }
- /**
- * @param integer $id
- * @return Book
- */
- public function setId($id)
- {
- $this->id = $id;
- return $this;
- }
- /**
- * @return string
- */
- public function getTitle()
- {
- return $this->title;
- }
- /**
- * @param string $title
- * @return Book
- */
- public function setTitle($title)
- {
- $this->title = $title;
- return $this;
- }
- /**
- * @return string
- */
- public function getGenre()
- {
- return $this->genre;
- }
- /**
- * @param string $genre
- * @return Book
- */
- public function setGenre($genre)
- {
- $this->genre = $genre;
- return $this;
- }
- /**
- * @param Option $option
- * @return Book
- */
- public function addOption(Option $option)
- {
- $this->options->add($option);
- return $this;
- }
- /**
- * @param Option $option
- * @return Book
- */
- public function removeOption(Option $option)
- {
- $this->options->removeElement($option);
- return $this;
- }
- /**
- * @return array
- */
- public function getOptions()
- {
- return $this->options->toArray();
- }
- }
- <?php
- /**
- * @Entity
- */
- class Option
- {
- /**
- * @var integer
- * @Column(type="integer")
- */
- private $id;
- /**
- * @var string
- * @Column(type="string")
- */
- private $description;
- /**
- * @return integer
- */
- public function getId()
- {
- return $this->id;
- }
- /**
- * @param integer $id
- * @return Option
- */
- public function setId($id)
- {
- $this->id = $id;
- return $this;
- }
- /**
- * @return string
- */
- public function getDescription()
- {
- return $this->description;
- }
- /**
- * @param string $description
- * @return Option
- */
- public function setDescription($description)
- {
- $this->description = $description;
- return $this;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment