sf-api-example/src/AppBundle/Entity/Book.php
2016-11-23 16:10:52 +01:00

235 lines
4.1 KiB
PHP

<?php
namespace AppBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\ArrayCollection;
/**
* Book.
*
* @ORM\Table(name="book")
* @ORM\Entity(repositoryClass="AppBundle\Repository\BookRepository")
*/
class Book
{
/**
* @var int
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @var string
*
* @ORM\Column(name="title", type="string", length=255)
*/
private $title;
/**
* @var int
*
* @ORM\Column(name="pages", type="integer")
*/
private $pages;
/**
* @var \DateTime
*
* @ORM\Column(name="publishedAt", type="date")
*/
private $publishedAt;
/**
* @var \Doctrine\Common\Collections\Collection
*
* @ORM\ManyToMany(
* targetEntity="Category",
* cascade={"persist"}
* )
* @ORM\JoinTable(
* name="book_has_category",
* joinColumns={
* @ORM\JoinColumn(
* name="book_id",
* referencedColumnName="id"
* )
* },
* inverseJoinColumns={
* @ORM\JoinColumn(
* name="category_id",
* referencedColumnName="id",
* unique=true
* )
* }
* )
*/
private $categories;
/**
* @var Author
*
* @ORM\ManyToOne(
* targetEntity="Author",
* inversedBy="books",
* cascade={"persist", "remove", "merge"}
* )
* @ORM\JoinColumn(
* name="author_id",
* referencedColumnName="id"
* )
*/
private $author;
/**
* Constructor.
*/
public function __construct()
{
$this->categories = new \Doctrine\Common\Collections\ArrayCollection();
}
/**
* Get id.
*
* @return int
*/
public function getId()
{
return $this->id;
}
/**
* Set title.
*
* @param string $title
*
* @return Book
*/
public function setTitle($title)
{
$this->title = $title;
return $this;
}
/**
* Get title.
*
* @return string
*/
public function getTitle()
{
return $this->title;
}
/**
* Set pages.
*
* @param int $pages
*
* @return Book
*/
public function setPages($pages)
{
$this->pages = $pages;
return $this;
}
/**
* Get pages.
*
* @return int
*/
public function getPages()
{
return $this->pages;
}
/**
* Set publishedAt.
*
* @param \DateTime $publishedAt
*
* @return Book
*/
public function setPublishedAt($publishedAt)
{
$this->publishedAt = $publishedAt;
return $this;
}
/**
* Get publishedAt.
*
* @return \DateTime
*/
public function getPublishedAt()
{
return $this->publishedAt;
}
/**
* Add category
*
* @param \AppBundle\Entity\Category $category
*
* @return Book
*/
public function addCategory(\AppBundle\Entity\Category $category)
{
$this->categories[] = $category;
return $this;
}
/**
* Remove category
*
* @param \AppBundle\Entity\Category $category
*/
public function removeCategory(\AppBundle\Entity\Category $category)
{
$this->categories->removeElement($category);
}
/**
* Get categories
*
* @return \Doctrine\Common\Collections\Collection
*/
public function getCategories()
{
return $this->categories;
}
/**
* Set author
*
* @param \AppBundle\Entity\Author $author
*
* @return Book
*/
public function setAuthor(\AppBundle\Entity\Author $author = null)
{
$this->author = $author;
return $this;
}
/**
* Get author
*
* @return \AppBundle\Entity\Author
*/
public function getAuthor()
{
return $this->author;
}
}