瀏覽代碼

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

bastien 12 年之前
父節點
當前提交
1f68208a13

+ 6 - 0
.gitmodules 查看文件

@@ -0,0 +1,6 @@
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 查看文件

@@ -19,6 +19,7 @@ class AppKernel extends Kernel
19 19
             new JMS\SecurityExtraBundle\JMSSecurityExtraBundle(),
20 20
             new FOS\UserBundle\FOSUserBundle(),
21 21
             new Symfony\Bundle\DoctrineFixturesBundle\DoctrineFixturesBundle(),
22
+            new Stof\DoctrineExtensionsBundle\StofDoctrineExtensionsBundle(),
22 23
             new Muzich\CoreBundle\MuzichCoreBundle(),
23 24
             new Muzich\UserBundle\MuzichUserBundle(),
24 25
             new Muzich\IndexBundle\MuzichIndexBundle(),

+ 2 - 0
app/autoload.php 查看文件

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

+ 8 - 0
src/Muzich/CoreBundle/DataFixtures/ORM/LoadGroupData.php 查看文件

@@ -79,6 +79,14 @@ class LoadGroupData  extends AbstractFixture implements OrderedFixtureInterface,
79 79
   {
80 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 90
     // Création des groupes
83 91
     
84 92
     $group_dudeldrum = $this->createGroup('dudeldrum', 'DUDELDRUM', 

+ 7 - 0
src/Muzich/CoreBundle/Entity/Group.php 查看文件

@@ -4,6 +4,7 @@ namespace Muzich\CoreBundle\Entity;
4 4
 
5 5
 use Doctrine\ORM\Mapping as ORM;
6 6
 use \Doctrine\Common\Collections\ArrayCollection;
7
+use Gedmo\Mapping\Annotation as Gedmo;
7 8
 
8 9
 /**
9 10
  * Le groupe est une sorte de liste de diffusion, a laquelle les
@@ -34,6 +35,12 @@ class Group
34 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 44
    * Description
38 45
    * 
39 46
    * @ORM\Column(type="text")

+ 17 - 0
src/Muzich/CoreBundle/Entity/User.php 查看文件

@@ -5,6 +5,7 @@ namespace Muzich\CoreBundle\Entity;
5 5
 use FOS\UserBundle\Entity\User as BaseUser;
6 6
 use Doctrine\ORM\Mapping as ORM;
7 7
 use \Doctrine\Common\Collections\ArrayCollection;
8
+use Gedmo\Mapping\Annotation as Gedmo;
8 9
 
9 10
 /**
10 11
  * Cet entité est l'utilisateur ayant effectué la requête.
@@ -24,6 +25,12 @@ class User extends BaseUser
24 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 34
    * Cet attribut contient les enregistrements UsersTagsFavorites lié 
28 35
    * a cet utilisateur dans le cadre des Tags Favoris.
29 36
    * 
@@ -230,6 +237,16 @@ class User extends BaseUser
230 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 查看文件

@@ -67,9 +67,19 @@ class LoadUserData extends AbstractFixture implements OrderedFixtureInterface, C
67 67
   
68 68
   public function load($entity_manager)
69 69
   {
70
+    
70 71
     $this->entity_manager = $entity_manager;
71 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 83
     // Création des Users
74 84
     $admin  = $this->createUser('admin', 'admin@root', 'toor');
75 85
     $bux    = $this->createUser('bux', 'bux@root', 'toor');

+ 1 - 0
vendor/bundles/Stof/DoctrineExtensionsBundle

@@ -0,0 +1 @@
1
+Subproject commit a82ae9a667dc95aa64865512566aeac9cbe515c1

+ 1 - 0
vendor/gedmo-doctrine-extensions

@@ -0,0 +1 @@
1
+Subproject commit a4e25dcf884b1e8a7d92d4e6bddfc8aadf362f7f