Sfoglia il codice sorgente

admin pour tag, group.

bastien 13 anni fa
parent
commit
078f3f3d47

+ 56 - 0
src/Muzich/AdminBundle/Admin/GroupAdmin.php Vedi File

@@ -0,0 +1,56 @@
1
+<?php
2
+
3
+namespace Muzich\AdminBundle\Admin;
4
+
5
+use Sonata\AdminBundle\Admin\Admin;
6
+use Sonata\AdminBundle\Form\FormMapper;
7
+use Sonata\AdminBundle\Datagrid\DatagridMapper;
8
+use Sonata\AdminBundle\Datagrid\ListMapper;
9
+
10
+class GroupAdmin extends Admin
11
+{
12
+  
13
+  protected function configureListFields(ListMapper $listMapper)
14
+  {
15
+    $listMapper
16
+      ->addIdentifier('name')
17
+      ->add('open')
18
+      ->add('owner', 'many_to_one')
19
+      ->add('tags')
20
+      ->add('_action', 'actions', array(
21
+        'actions' => array(
22
+          'view' => array(),
23
+          'edit' => array(),
24
+        )
25
+      ))
26
+    ;
27
+  }
28
+  
29
+  protected function configureDatagridFilters(DatagridMapper $datagrid)
30
+  {
31
+    $datagrid
32
+      ->add('name')
33
+      ->add('tags')
34
+    ;
35
+  }
36
+  
37
+  protected function configureFormFields(FormMapper $formMapper)
38
+  {
39
+    $formMapper
40
+      ->add('name')
41
+      ->add('description')
42
+      ->add('open', null, array('required' => false))
43
+      ->add('owner', 'sonata_type_model', array(), array('edit' => 'list'))
44
+      // Attention, il semble que le lien pointe vers des records de la table de relation
45
+      // il faudra utiliser le many to many, quand j'y arriverai ...
46
+      //->add('tags', null, array('required' => false))
47
+      
48
+    ;
49
+  }
50
+
51
+//  public function validate(ErrorElement $errorElement, $object)
52
+//  {
53
+//     
54
+//  }
55
+  
56
+}

+ 46 - 0
src/Muzich/AdminBundle/Admin/TagAdmin.php Vedi File

@@ -0,0 +1,46 @@
1
+<?php
2
+
3
+namespace Muzich\AdminBundle\Admin;
4
+
5
+use Sonata\AdminBundle\Admin\Admin;
6
+use Sonata\AdminBundle\Form\FormMapper;
7
+use Sonata\AdminBundle\Datagrid\DatagridMapper;
8
+use Sonata\AdminBundle\Datagrid\ListMapper;
9
+
10
+class TagAdmin extends Admin
11
+{
12
+  
13
+  protected function configureListFields(ListMapper $listMapper)
14
+  {
15
+    $listMapper
16
+      ->addIdentifier('id')
17
+      ->addIdentifier('name')
18
+      ->add('_action', 'actions', array(
19
+        'actions' => array(
20
+          'view' => array(),
21
+          'edit' => array(),
22
+        )
23
+      ))
24
+    ;
25
+  }
26
+  
27
+  protected function configureDatagridFilters(DatagridMapper $datagrid)
28
+  {
29
+    $datagrid
30
+      ->add('name')
31
+    ;
32
+  }
33
+  
34
+  protected function configureFormFields(FormMapper $formMapper)
35
+  {
36
+    $formMapper
37
+      ->add('name')
38
+    ;
39
+  }
40
+
41
+//  public function validate(ErrorElement $errorElement, $object)
42
+//  {
43
+//     
44
+//  }
45
+  
46
+}

+ 9 - 0
src/Muzich/AdminBundle/Controller/GroupAdminController.php Vedi File

@@ -0,0 +1,9 @@
1
+<?php
2
+
3
+namespace Muzich\AdminBundle\Controller;
4
+
5
+use Sonata\AdminBundle\Controller\CRUDController as Controller;
6
+
7
+class GroupAdminController extends Controller
8
+{
9
+}

+ 9 - 0
src/Muzich/AdminBundle/Controller/TagAdminController.php Vedi File

@@ -0,0 +1,9 @@
1
+<?php
2
+
3
+namespace Muzich\AdminBundle\Controller;
4
+
5
+use Sonata\AdminBundle\Controller\CRUDController as Controller;
6
+
7
+class TagAdminController extends Controller
8
+{
9
+}

+ 5 - 0
src/Muzich/CoreBundle/Entity/Group.php Vedi File

@@ -98,6 +98,11 @@ class Group
98 98
     $this->followers = new ArrayCollection();
99 99
   }
100 100
   
101
+  public function __toString()
102
+  {
103
+    return $this->getName();
104
+  }
105
+  
101 106
   /**
102 107
    * Get id
103 108
    *

+ 4 - 0
src/Muzich/CoreBundle/Entity/GroupsTagsFavorites.php Vedi File

@@ -47,6 +47,10 @@ class GroupsTagsFavorites
47 47
    */
48 48
   protected $position;
49 49
     
50
+  public function __toString()
51
+  {
52
+    return $this->getTag()->getName();
53
+  }
50 54
 
51 55
   /**
52 56
    * Set position