Skip to content

Instantly share code, notes, and snippets.

@sveneisenschmidt
Created June 15, 2011 19:49
Show Gist options
  • Save sveneisenschmidt/1027938 to your computer and use it in GitHub Desktop.
Save sveneisenschmidt/1027938 to your computer and use it in GitHub Desktop.
Expose Entities via annotations
namespace MyCompany\MyBundle\Entity;
use Hahaitsfate\ApiBundle\Mapping\Annotations as Api;
/**
* @API\Collection(name="products")
* @ORM\Table(name="products")
* @ORM\Entity
*/
class Product
{
/**
* @API\Expose(name="id", access="readonly")
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @API\Expose
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $title;
/**
* @API\Expose(name="category_id")
* @ORM\ManyToOne(
* targetEntity="MyCompany\MyBundle\Entity\ProductCategory",
* inversedBy="products"
* )
*/
private $category;
public function getId()
{
return $this->id;
}
public function setTitle($title)
{
$this->title = $title;
}
public function getTitle()
{
return $this->title;
}
}
hahaitsfate_api:
mappings:
MyCompanyMyBundle:
dir: Entity/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment