--- a/src/Company/BaseBundle/Entity/Document.php Wed Dec 14 23:55:33 2011 +0100
+++ b/src/Company/BaseBundle/Entity/Document.php Mon Dec 19 17:50:05 2011 +0100
@@ -3,7 +3,7 @@
namespace Company\BaseBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
-use IRI\Bundle\WikiTagBundle\Model\DocumentInterface;
+use Doctrine\Common\Collections\ArrayCollection;
/**
* Company\BaseBundle\Entity\Document
@@ -36,6 +36,18 @@
* @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;
/**
@@ -88,4 +100,33 @@
{
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();
+ }
+
}
\ No newline at end of file