Преглед на файлове

Evolution #780: Lien permanent

Bastien Sevajol преди 11 години
родител
ревизия
6935c806d5
променени са 2 файла, в които са добавени 34 реда и са изтрити 0 реда
  1. 18 0
      src/Muzich/CoreBundle/Command/MigrationUpgradeCommand.php
  2. 16 0
      src/Muzich/CoreBundle/Entity/Element.php

+ 18 - 0
src/Muzich/CoreBundle/Command/MigrationUpgradeCommand.php Целия файл

@@ -8,6 +8,7 @@ use Symfony\Component\Console\Input\InputInterface;
8 8
 use Symfony\Component\Console\Input\InputOption;
9 9
 use Symfony\Component\Console\Output\OutputInterface;
10 10
 //use Muzich\CoreBundle\Managers\CommentsManager;
11
+use Muzich\CoreBundle\Util\StrictCanonicalizer;
11 12
 
12 13
 class MigrationUpgradeCommand extends ContainerAwareCommand
13 14
 {
@@ -63,6 +64,23 @@ class MigrationUpgradeCommand extends ContainerAwareCommand
63 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 84
     if (!$proceeded)
67 85
     {
68 86
       $output->writeln('<error>Versions saisies non prises en charges</error>');

+ 16 - 0
src/Muzich/CoreBundle/Entity/Element.php Целия файл

@@ -194,6 +194,12 @@ class Element
194 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 203
    * Code d'embed
198 204
    * 
199 205
    * @ORM\Column(type="text", nullable=true)
@@ -1036,4 +1042,14 @@ class Element
1036 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
 }