aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/GroupBundle
diff options
context:
space:
mode:
Diffstat (limited to 'src/Wallabag/GroupBundle')
-rw-r--r--src/Wallabag/GroupBundle/Entity/Group.php37
-rw-r--r--src/Wallabag/GroupBundle/Form/GroupType.php7
-rw-r--r--src/Wallabag/GroupBundle/Resources/views/Manage/edit.html.twig8
3 files changed, 52 insertions, 0 deletions
diff --git a/src/Wallabag/GroupBundle/Entity/Group.php b/src/Wallabag/GroupBundle/Entity/Group.php
index 57dc16d1..e889f74e 100644
--- a/src/Wallabag/GroupBundle/Entity/Group.php
+++ b/src/Wallabag/GroupBundle/Entity/Group.php
@@ -4,6 +4,7 @@ namespace Wallabag\GroupBundle\Entity;
4 4
5use FOS\UserBundle\Model\Group as BaseGroup; 5use FOS\UserBundle\Model\Group as BaseGroup;
6use Doctrine\ORM\Mapping as ORM; 6use Doctrine\ORM\Mapping as ORM;
7use Wallabag\UserBundle\Entity\User;
7 8
8/** 9/**
9 * @ORM\Entity 10 * @ORM\Entity
@@ -17,4 +18,40 @@ class Group extends BaseGroup
17 * @ORM\GeneratedValue(strategy="AUTO") 18 * @ORM\GeneratedValue(strategy="AUTO")
18 */ 19 */
19 protected $id; 20 protected $id;
21
22 /**
23 * @ORM\ManyToMany(targetEntity="Wallabag\UserBundle\Entity\User", mappedBy="groups", cascade={"persist"})
24 */
25 protected $users;
26
27 public function getUsers()
28 {
29 return $this->users ?: $this->users = new ArrayCollection();
30 }
31
32 public function addUser(User $user)
33 {
34 if (!$this->getUsers()->contains($user)) {
35 $this->getUsers()->add($user);
36 }
37
38 return $this;
39 }
40
41 /**
42 * {@inheritdoc}
43 */
44 public function removeUser(User $user)
45 {
46 if ($this->getUsers()->contains($user)) {
47 $this->getUsers()->removeElement($user);
48 }
49
50 return $this;
51 }
52
53 public function __toString()
54 {
55 return $this->getName();
56 }
20} 57}
diff --git a/src/Wallabag/GroupBundle/Form/GroupType.php b/src/Wallabag/GroupBundle/Form/GroupType.php
index c2ad764b..749c15e9 100644
--- a/src/Wallabag/GroupBundle/Form/GroupType.php
+++ b/src/Wallabag/GroupBundle/Form/GroupType.php
@@ -2,6 +2,7 @@
2 2
3namespace Wallabag\GroupBundle\Form; 3namespace Wallabag\GroupBundle\Form;
4 4
5use Symfony\Bridge\Doctrine\Form\Type\EntityType;
5use Symfony\Component\Form\AbstractType; 6use Symfony\Component\Form\AbstractType;
6use Symfony\Component\Form\FormBuilderInterface; 7use Symfony\Component\Form\FormBuilderInterface;
7use Symfony\Component\OptionsResolver\OptionsResolver; 8use Symfony\Component\OptionsResolver\OptionsResolver;
@@ -21,6 +22,12 @@ class GroupType extends AbstractType
21 'required' => false, 22 'required' => false,
22 'label' => 'group.form.name_label', 23 'label' => 'group.form.name_label',
23 ]) 24 ])
25 ->add('users', EntityType::class, array(
26 'class' => 'WallabagUserBundle:User',
27 'choice_label' => 'username',
28 'multiple' => true,
29 'expanded' => true,
30 ))
24 ->add('save', SubmitType::class, [ 31 ->add('save', SubmitType::class, [
25 'label' => 'group.form.save', 32 'label' => 'group.form.save',
26 ]) 33 ])
diff --git a/src/Wallabag/GroupBundle/Resources/views/Manage/edit.html.twig b/src/Wallabag/GroupBundle/Resources/views/Manage/edit.html.twig
index 7de68c35..791a7a18 100644
--- a/src/Wallabag/GroupBundle/Resources/views/Manage/edit.html.twig
+++ b/src/Wallabag/GroupBundle/Resources/views/Manage/edit.html.twig
@@ -23,6 +23,14 @@
23 </div> 23 </div>
24 </div> 24 </div>
25 25
26 <div class="row">
27 <div class="input-field col s12">
28 {{ form_label(edit_form.users) }}
29 {{ form_errors(edit_form.users) }}
30 {{ form_widget(edit_form.users) }}
31 </div>
32 </div>
33
26 <br/> 34 <br/>
27 35
28 {{ form_widget(edit_form.save, {'attr': {'class': 'btn waves-effect waves-light'}}) }} 36 {{ form_widget(edit_form.save, {'attr': {'class': 'btn waves-effect waves-light'}}) }}