sf-api-example/src/AppBundle/Entity/Author.php

201 lines
3.6 KiB
PHP

<?php
namespace AppBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* Author.
*
* @ORM\Table(name="author")
* @ORM\Entity(repositoryClass="AppBundle\Repository\AuthorRepository")
*/
class Author
{
/**
* @var int
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @var string
*
* @ORM\Column(name="firstname", type="string", length=255)
*/
private $firstname;
/**
* @var string
*
* @ORM\Column(name="lastname", type="string", length=255)
*/
private $lastname;
/**
* @var \Doctrine\Common\Collections\Collection
*
* @ORM\OneToMany(targetEntity="Book", mappedBy="author", cascade={"persist"})
*/
private $books;
/**
* Constructor.
*/
public function __construct()
{
$this->books = new \Doctrine\Common\Collections\ArrayCollection();
}
/**
* Get id.
*
* @return int
*/
public function getId()
{
return $this->id;
}
/**
* Set firstname.
*
* @param string $firstname
*
* @return Author
*/
public function setFirstname($firstname)
{
$this->firstname = $firstname;
return $this;
}
/**
* Get firstname.
*
* @return string
*/
public function getFirstname()
{
return $this->firstname;
}
/**
* Set lastname.
*
* @param string $lastname
*
* @return Author
*/
public function setLastname($lastname)
{
$this->lastname = $lastname;
return $this;
}
/**
* Get lastname.
*
* @return string
*/
public function getLastname()
{
return $this->lastname;
}
/**
* Add book.
*
* @param \AppBundle\Entity\Book $book
*
* @return Author
*/
public function addBook(\AppBundle\Entity\Book $book)
{
$this->books[] = $book;
return $this;
}
/**
* Remove book.
*
* @param \AppBundle\Entity\Book $book
*/
public function removeBook(\AppBundle\Entity\Book $book)
{
$this->books->removeElement($book);
}
/**
* Get books.
*
* @return \Doctrine\Common\Collections\Collection
*/
public function getBooks()
{
return $this->books;
}
/**
* Rest: get id.
*
* @JMS\Serializer\Annotation\SerializedName("id")
* @JMS\Serializer\Annotation\Groups({"all"})
* @JMS\Serializer\Annotation\VirtualProperty
*
* @return int
*/
public function getRestId()
{
return $this->getId();
}
/**
* Rest: get lastname.
*
* @JMS\Serializer\Annotation\SerializedName("lastname")
* @JMS\Serializer\Annotation\Groups({"all"})
* @JMS\Serializer\Annotation\VirtualProperty
*
* @return string
*/
public function getRestLastname()
{
return $this->getLastname();
}
/**
* Rest: get firstname.
*
* @JMS\Serializer\Annotation\SerializedName("firstname")
* @JMS\Serializer\Annotation\Groups({"all"})
* @JMS\Serializer\Annotation\VirtualProperty
*
* @return string
*/
public function getRestFirstname()
{
return $this->getFirstname();
}
/**
* Rest: get books.
*
* @JMS\Serializer\Annotation\SerializedName("books")
* @JMS\Serializer\Annotation\Groups({"all"})
* @JMS\Serializer\Annotation\VirtualProperty
*
* @return ArrayCollection
*/
public function getRestBooks()
{
return $this->getBooks();
}
}