<?php
namespace Company\BaseBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\ArrayCollection;
/**
* Company\BaseBundle\Entity\Document
*
* @ORM\Table()
* @ORM\Entity(repositoryClass="Company\BaseBundle\Entity\DocumentRepository")
*/
class Document
{
/**
* @var integer $id
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @var string $title
*
* @ORM\Column(name="title", type="string", length=255)
*/
private $title;
/**
* @var text $description
*
* @ORM\Column(name="description", type="text")
*/
private $description;
/**
* @ORM\ManyToMany(targetEntity="Category")
* @ORM\JoinTable(name="documents_categories",
* joinColumns={@ORM\JoinColumn(name="document_id", referencedColumnName="id")},
* inverseJoinColumns={@ORM\JoinColumn(name="category_id", referencedColumnName="id")}
* )
* @ORM\OrderBy({"name" = "ASC"})
*
* @var \Doctrine\Common\Collections\ArrayCollection
*/
private $categories;
/**
* Get id
*
* @return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set title
*
* @param string $title
*/
public function setTitle($title)
{
$this->title = $title;
}
/**
* Get title
*
* @return string
*/
public function getTitle()
{
return $this->title;
}
/**
* Set description
*
* @param text $description
*/
public function setDescription($description)
{
$this->description = $description;
}
/**
* Get description
*
* @return text
*/
public function getDescription()
{
return $this->description;
}
/**
* Get categories list
*
* @return \Doctrine\Common\Collections\ArrayCollection
*/
public function getCategories()
{
return $this->categories;
}
/**
* get the list of categories as string
*
*/
public function getCategoriesStr()
{
$res = array();
foreach($this->getCategories() as $cat) {
$res[] = $cat->getName();
}
return implode(",", $res);
}
public function __construct() {
$this->categories = new \Doctrine\Common\Collections\ArrayCollection();
}
}