Browse Source

Evolution #780: Lien permanent

Bastien Sevajol 11 years ago
parent
commit
6935c806d5

+ 18 - 0
src/Muzich/CoreBundle/Command/MigrationUpgradeCommand.php View File

8
 use Symfony\Component\Console\Input\InputOption;
8
 use Symfony\Component\Console\Input\InputOption;
9
 use Symfony\Component\Console\Output\OutputInterface;
9
 use Symfony\Component\Console\Output\OutputInterface;
10
 //use Muzich\CoreBundle\Managers\CommentsManager;
10
 //use Muzich\CoreBundle\Managers\CommentsManager;
11
+use Muzich\CoreBundle\Util\StrictCanonicalizer;
11
 
12
 
12
 class MigrationUpgradeCommand extends ContainerAwareCommand
13
 class MigrationUpgradeCommand extends ContainerAwareCommand
13
 {
14
 {
63
       $output->writeln('<info>Terminé !</info>');
64
       $output->writeln('<info>Terminé !</info>');
64
     }
65
     }
65
     
66
     
67
+    if ($input->getArgument('from') == '0.9.8.1' && $input->getArgument('to') == '0.9.8.2')
68
+    {
69
+      $proceeded = true;
70
+      $canonicalizer = new StrictCanonicalizer();
71
+      $elements = $em->getRepository('MuzichCoreBundle:Element')->findAll();
72
+      foreach ($elements as $element)
73
+      {
74
+        $element->setSlug($canonicalizer->canonicalize_stricter($element->getName()));
75
+        $output->write('.');
76
+        $em->persist($element);
77
+      }
78
+      
79
+      $output->writeln('<info>Save in Database ...</info>');
80
+      $em->flush();
81
+      $output->writeln('<info>Terminé !</info>');
82
+    }
83
+    
66
     if (!$proceeded)
84
     if (!$proceeded)
67
     {
85
     {
68
       $output->writeln('<error>Versions saisies non prises en charges</error>');
86
       $output->writeln('<error>Versions saisies non prises en charges</error>');

+ 16 - 0
src/Muzich/CoreBundle/Entity/Element.php View File

194
   protected $name;
194
   protected $name;
195
   
195
   
196
   /**
196
   /**
197
+   * @Gedmo\Slug(fields={"name"})
198
+   * @ORM\Column(length=128, unique=false)
199
+   */
200
+  protected $slug;
201
+  
202
+  /**
197
    * Code d'embed
203
    * Code d'embed
198
    * 
204
    * 
199
    * @ORM\Column(type="text", nullable=true)
205
    * @ORM\Column(type="text", nullable=true)
1036
     return $url;
1042
     return $url;
1037
   }
1043
   }
1038
   
1044
   
1045
+  public function getSlug()
1046
+  {
1047
+    return $this->slug;
1048
+  }
1049
+  
1050
+  public function setSlug($slug)
1051
+  {
1052
+    $this->slug = $slug;
1053
+  }
1054
+  
1039
 }
1055
 }