From 0f112feabe863f3f51025fd64ccfd333520c9264 Mon Sep 17 00:00:00 2001 From: "Gergely Polonkai (W00d5t0ck)" Date: Thu, 13 Sep 2012 12:08:29 +0200 Subject: [PATCH] Ability to assign documents to groups. Signed-off-by: Gergely Polonkai (W00d5t0ck) --- src/KekRozsak/FrontBundle/Entity/Document.php | 9 +++++++-- src/KekRozsak/FrontBundle/Entity/Group.php | 7 +------ .../FrontBundle/Form/Type/DocumentType.php | 13 +++++++++---- 3 files changed, 17 insertions(+), 12 deletions(-) diff --git a/src/KekRozsak/FrontBundle/Entity/Document.php b/src/KekRozsak/FrontBundle/Entity/Document.php index 20b6053..93eaf22 100644 --- a/src/KekRozsak/FrontBundle/Entity/Document.php +++ b/src/KekRozsak/FrontBundle/Entity/Document.php @@ -210,7 +210,12 @@ class Document /** * @var Doctrine\Common\Collections\ArrayCollection $groups - * @ORM\ManyToMany(targetEntity="KekRozsak\FrontBundle\Entity\Group", mappedBy="documents") + * @ORM\ManyToMany(targetEntity="KekRozsak\FrontBundle\Entity\Group", inversedBy="documents") + * @ORM\JoinTable(name="group_document", joinColumns={ + * @ORM\JoinColumn(name="document_id", referencedColumnName="id"), + * }, inverseJoinColumns={ + * @ORM\JoinColumn(name="group_id", referencedColumnName="id") + * }) */ protected $groups; @@ -234,7 +239,7 @@ class Document */ public function getGroups() { - return $this->group; + return $this->groups; } /** diff --git a/src/KekRozsak/FrontBundle/Entity/Group.php b/src/KekRozsak/FrontBundle/Entity/Group.php index 07389d0..f522b85 100644 --- a/src/KekRozsak/FrontBundle/Entity/Group.php +++ b/src/KekRozsak/FrontBundle/Entity/Group.php @@ -354,12 +354,7 @@ class Group * * @var Doctrine\Common\Collections\ArrayCollection $documents * - * @ORM\ManyToMany(targetEntity="Document", inversedBy="groups", fetch="LAZY") - * @ORM\JoinTable(name="group_document", inverseJoinColumns={ - * @ORM\JoinColumn(name="document_id", referencedColumnName="id"), - * }, joinColumns={ - * @ORM\JoinColumn(name="group_id", referencedColumnName="id") - * }) + * @ORM\ManyToMany(targetEntity="Document", mappedBy="groups", fetch="LAZY") */ protected $documents; diff --git a/src/KekRozsak/FrontBundle/Form/Type/DocumentType.php b/src/KekRozsak/FrontBundle/Form/Type/DocumentType.php index fa60527..1cc564d 100644 --- a/src/KekRozsak/FrontBundle/Form/Type/DocumentType.php +++ b/src/KekRozsak/FrontBundle/Form/Type/DocumentType.php @@ -12,14 +12,19 @@ class DocumentType extends AbstractType $builder->add('title', null, array( 'label' => 'A dokumentum címe', ) - ); + ) - $builder->add('content', 'ckeditor', array( + ->add('groups', null, array( + 'label' => 'Csoportok', + 'property' => 'name', + 'required' => true, + ) + ) + + ->add('content', 'ckeditor', array( 'label' => ' ', ) ); - - // TODO: possibility to add to other groups! } public function getName()