Browse Source

Ajout des bundles permettant l'utilisation des slugs. Ajout des champs slugs a User et Group.

bastien 13 years ago
parent
commit
1f68208a13

+ 6 - 0
.gitmodules View File

1
+[submodule "vendor/gedmo-doctrine-extensions"]
2
+	path = vendor/gedmo-doctrine-extensions
3
+	url = git://github.com/l3pp4rd/DoctrineExtensions.git
4
+[submodule "vendor/bundles/Stof/DoctrineExtensionsBundle"]
5
+	path = vendor/bundles/Stof/DoctrineExtensionsBundle
6
+	url = git://github.com/stof/StofDoctrineExtensionsBundle.git

+ 1 - 0
app/AppKernel.php View File

19
             new JMS\SecurityExtraBundle\JMSSecurityExtraBundle(),
19
             new JMS\SecurityExtraBundle\JMSSecurityExtraBundle(),
20
             new FOS\UserBundle\FOSUserBundle(),
20
             new FOS\UserBundle\FOSUserBundle(),
21
             new Symfony\Bundle\DoctrineFixturesBundle\DoctrineFixturesBundle(),
21
             new Symfony\Bundle\DoctrineFixturesBundle\DoctrineFixturesBundle(),
22
+            new Stof\DoctrineExtensionsBundle\StofDoctrineExtensionsBundle(),
22
             new Muzich\CoreBundle\MuzichCoreBundle(),
23
             new Muzich\CoreBundle\MuzichCoreBundle(),
23
             new Muzich\UserBundle\MuzichUserBundle(),
24
             new Muzich\UserBundle\MuzichUserBundle(),
24
             new Muzich\IndexBundle\MuzichIndexBundle(),
25
             new Muzich\IndexBundle\MuzichIndexBundle(),

+ 2 - 0
app/autoload.php View File

18
     //'Muzich'           => __DIR__.'/../vendor/src',
18
     //'Muzich'           => __DIR__.'/../vendor/src',
19
     'Doctrine\\Common\\DataFixtures' => __DIR__.'/../vendor/doctrine-fixtures/lib',
19
     'Doctrine\\Common\\DataFixtures' => __DIR__.'/../vendor/doctrine-fixtures/lib',
20
     'Doctrine\\Common' => __DIR__.'/../vendor/doctrine-common/lib',
20
     'Doctrine\\Common' => __DIR__.'/../vendor/doctrine-common/lib',
21
+    'Stof'  => __DIR__.'/../vendor/bundles',
22
+    'Gedmo' => __DIR__.'/../vendor/gedmo-doctrine-extensions/lib',
21
 ));
23
 ));
22
 $loader->registerPrefixes(array(
24
 $loader->registerPrefixes(array(
23
     'Twig_Extensions_' => __DIR__.'/../vendor/twig-extensions/lib',
25
     'Twig_Extensions_' => __DIR__.'/../vendor/twig-extensions/lib',

+ 8 - 0
src/Muzich/CoreBundle/DataFixtures/ORM/LoadGroupData.php View File

79
   {
79
   {
80
     $this->entity_manager = $entity_manager;
80
     $this->entity_manager = $entity_manager;
81
 
81
 
82
+    // Slug stuff
83
+    $evm = new \Doctrine\Common\EventManager();
84
+    // ORM and ODM
85
+    $sluggableListener = new \Gedmo\Sluggable\SluggableListener();
86
+    $evm->addEventSubscriber($sluggableListener);
87
+    // now this event manager should be passed to entity manager constructor
88
+    $entity_manager->getEventManager()->addEventSubscriber($sluggableListener);
89
+    
82
     // Création des groupes
90
     // Création des groupes
83
     
91
     
84
     $group_dudeldrum = $this->createGroup('dudeldrum', 'DUDELDRUM', 
92
     $group_dudeldrum = $this->createGroup('dudeldrum', 'DUDELDRUM', 

+ 7 - 0
src/Muzich/CoreBundle/Entity/Group.php View File

4
 
4
 
5
 use Doctrine\ORM\Mapping as ORM;
5
 use Doctrine\ORM\Mapping as ORM;
6
 use \Doctrine\Common\Collections\ArrayCollection;
6
 use \Doctrine\Common\Collections\ArrayCollection;
7
+use Gedmo\Mapping\Annotation as Gedmo;
7
 
8
 
8
 /**
9
 /**
9
  * Le groupe est une sorte de liste de diffusion, a laquelle les
10
  * Le groupe est une sorte de liste de diffusion, a laquelle les
34
   protected $name;
35
   protected $name;
35
   
36
   
36
   /**
37
   /**
38
+   * @Gedmo\Slug(fields={"name"})
39
+   * @ORM\Column(length=128, unique=true)
40
+   */
41
+  protected $slug;
42
+  
43
+  /**
37
    * Description
44
    * Description
38
    * 
45
    * 
39
    * @ORM\Column(type="text")
46
    * @ORM\Column(type="text")

+ 17 - 0
src/Muzich/CoreBundle/Entity/User.php View File

5
 use FOS\UserBundle\Entity\User as BaseUser;
5
 use FOS\UserBundle\Entity\User as BaseUser;
6
 use Doctrine\ORM\Mapping as ORM;
6
 use Doctrine\ORM\Mapping as ORM;
7
 use \Doctrine\Common\Collections\ArrayCollection;
7
 use \Doctrine\Common\Collections\ArrayCollection;
8
+use Gedmo\Mapping\Annotation as Gedmo;
8
 
9
 
9
 /**
10
 /**
10
  * Cet entité est l'utilisateur ayant effectué la requête.
11
  * Cet entité est l'utilisateur ayant effectué la requête.
24
   protected $id;
25
   protected $id;
25
   
26
   
26
   /**
27
   /**
28
+   * @Gedmo\Slug(fields={"username"})
29
+   * @ORM\Column(length=128, unique=true)
30
+   */
31
+  protected $slug;
32
+  
33
+  /**
27
    * Cet attribut contient les enregistrements UsersTagsFavorites lié 
34
    * Cet attribut contient les enregistrements UsersTagsFavorites lié 
28
    * a cet utilisateur dans le cadre des Tags Favoris.
35
    * a cet utilisateur dans le cadre des Tags Favoris.
29
    * 
36
    * 
230
     return $this->groups;
237
     return $this->groups;
231
   }
238
   }
232
   
239
   
240
+  public function getSlug()
241
+  {
242
+    return $this->slug;
243
+  }
244
+  
245
+  public function setSlug($slug)
246
+  {
247
+    $this->slug = $slug;
248
+  }
249
+  
233
   /*
250
   /*
234
    * 
251
    * 
235
    * 
252
    * 

+ 10 - 0
src/Muzich/UserBundle/DataFixtures/ORM/LoadUserData.php View File

67
   
67
   
68
   public function load($entity_manager)
68
   public function load($entity_manager)
69
   {
69
   {
70
+    
70
     $this->entity_manager = $entity_manager;
71
     $this->entity_manager = $entity_manager;
71
     $this->user_manager = $this->container->get('fos_user.user_manager');
72
     $this->user_manager = $this->container->get('fos_user.user_manager');
72
     
73
     
74
+    // Slug stuff
75
+    $evm = new \Doctrine\Common\EventManager();
76
+    // ORM and ODM
77
+    $sluggableListener = new \Gedmo\Sluggable\SluggableListener();
78
+    $evm->addEventSubscriber($sluggableListener);
79
+    // now this event manager should be passed to entity manager constructor
80
+    $entity_manager->getEventManager()->addEventSubscriber($sluggableListener);
81
+    
82
+    
73
     // Création des Users
83
     // Création des Users
74
     $admin  = $this->createUser('admin', 'admin@root', 'toor');
84
     $admin  = $this->createUser('admin', 'admin@root', 'toor');
75
     $bux    = $this->createUser('bux', 'bux@root', 'toor');
85
     $bux    = $this->createUser('bux', 'bux@root', 'toor');

+ 1 - 0
vendor/bundles/Stof/DoctrineExtensionsBundle

1
+Subproject commit a82ae9a667dc95aa64865512566aeac9cbe515c1

+ 1 - 0
vendor/gedmo-doctrine-extensions

1
+Subproject commit a4e25dcf884b1e8a7d92d4e6bddfc8aadf362f7f