Browse Source

Merge branch 'unstable' into feature/home

bastien 13 years ago
parent
commit
32d9f20568

+ 132 - 0
src/Muzich/CoreBundle/DataFixtures/ORM/LoadElementData.php View File

@@ -0,0 +1,132 @@
1
+<?php
2
+
3
+namespace Muzich\UserBundle\DataFixtures\ORM;
4
+
5
+use Doctrine\Common\DataFixtures\AbstractFixture;
6
+use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
7
+use Symfony\Component\DependencyInjection\ContainerAwareInterface;
8
+use Symfony\Component\DependencyInjection\ContainerInterface;
9
+use Muzich\CoreBundle\Entity\Element;
10
+
11
+class LoadElementData  extends AbstractFixture implements OrderedFixtureInterface, ContainerAwareInterface
12
+{
13
+  
14
+  private $container;
15
+  private $entity_manager;
16
+  
17
+  public function setContainer(ContainerInterface $container = null)
18
+  {
19
+    $this->container = $container;
20
+  }
21
+  
22
+  public function getOrder()
23
+  {
24
+    return 4;
25
+  }
26
+  
27
+  protected function getArrayOfTag($names)
28
+  {
29
+    $tags = array();
30
+    foreach ($names as $name)
31
+    {
32
+      $tags[] = $this->entity_manager->merge($this->getReference('tag_'.$name));
33
+    }
34
+    return $tags;
35
+  }
36
+  
37
+  /**
38
+   *  
39
+   */
40
+  protected function createElement($reference_id, $name, $url, $tags, $type, $owner, $date = null)
41
+  {
42
+    if (!$date)
43
+    {
44
+      $date = new \DateTime();
45
+    }
46
+    
47
+    $element = new Element();
48
+    $element->setName(ucfirst($name));
49
+    $element->setUrl($url);
50
+    $element->setType($type);
51
+    $element->setOwner($owner);
52
+    $element->setDateAdded($date);
53
+    $this->addReference('element_'.$reference_id, $element);
54
+    
55
+    foreach ($tags as $tag)
56
+    {
57
+      $element->addTag($tag);
58
+    }
59
+    
60
+    $this->entity_manager->persist($element);
61
+  }
62
+  
63
+  public function load($entity_manager)
64
+  {
65
+    $this->entity_manager = $entity_manager;
66
+
67
+    $bux  = $this->entity_manager->merge($this->getReference('user_bux'));
68
+    $jean = $this->entity_manager->merge($this->getReference('user_jean'));
69
+    $paul = $this->entity_manager->merge($this->getReference('user_paul'));
70
+    $bob  = $this->entity_manager->merge($this->getReference('user_bob'));
71
+
72
+    // 'youtube', 'soundclound', 'son2teuf', 'jamendo'
73
+    $youtube     = $this->entity_manager->merge($this->getReference('element_type_youtube'));
74
+    $soundclound = $this->entity_manager->merge($this->getReference('element_type_soundclound'));
75
+    $son2teuf    = $this->entity_manager->merge($this->getReference('element_type_son2teuf'));
76
+    $jamendo     = $this->entity_manager->merge($this->getReference('element_type_jamendo'));
77
+    
78
+    $this->createElement('youtube_heretik_1', 'Heretik System Popof - Resistance', 
79
+      'http://www.youtube.com/watch?v=tq4DjQK7nsM',
80
+      $this->getArrayOfTag(array('hardtek')),
81
+    $youtube, $bux);
82
+    
83
+    $this->createElement('youtube_dtc_passdrop', 'dtc che passdrop', 
84
+      'http://www.youtube.com/watch?v=2A4buFCp7qM', 
85
+      $this->getArrayOfTag(array('hardtek')),
86
+    $youtube, $bux);
87
+    
88
+    $this->createElement('youtube_antroppod_1', 'Antropod - Polakatek', 
89
+      'http://www.youtube.com/watch?v=VvpF3lCh1hk&NR=1', 
90
+      $this->getArrayOfTag(array('hardtek')),
91
+    $youtube, $bux);
92
+    
93
+    $this->createElement('youtube_koinkoin_1', 'koinkOin - H5N1', 
94
+      'http://www.son2teuf.org/Voir-details/Sons/Lives/Hardtek-_-Tribe/koinkOin-_-H5N1', 
95
+      $this->getArrayOfTag(array('hardtek', 'electro')),
96
+    $youtube, $bux);
97
+    
98
+    
99
+    $this->createElement('youtube_djfab_1', 'DJ FAB', 
100
+      'http://www.jamendo.com/fr/album/42567', 
101
+      $this->getArrayOfTag(array('hardtek')),
102
+    $jamendo, $jean);
103
+    
104
+    $this->createElement('youtube_djantoine_1', 'dj antoine', 
105
+      'http://www.jamendo.com/fr/album/75206', 
106
+      $this->getArrayOfTag(array('hardtek', 'tribe')),
107
+    $jamendo, $jean);
108
+    
109
+    $this->createElement('youtube_acroyek_1', 'Acrotek Hardtek G01', 
110
+      'http://www.jamendo.com/fr/album/3409', 
111
+      $this->getArrayOfTag(array('hardtek')),
112
+    $jamendo, $jean);
113
+    
114
+    
115
+    $this->createElement('jamendo_caio_1', 'All Is Full Of Pain', 
116
+      'http://soundcloud.com/keytek/all-is-full-of-pain', 
117
+      $this->getArrayOfTag(array('tribe', 'hardtek')),
118
+    $soundclound, $jean);
119
+    
120
+    $this->createElement('jamendo_reverb_1', 'RE-FUCK (ReVeRB_FBC) mix.', 
121
+      'http://soundcloud.com/reverb-2/re-fuck-reverb_fbc-mix', 
122
+      $this->getArrayOfTag(array('tribe')),
123
+    $soundclound, $jean);
124
+    
125
+    $this->createElement('jamendo_cardio_1', 'CardioT3K - Juggernaut Trap', 
126
+      'http://soundcloud.com/cardiot3k/cardiot3k-juggernaut-trap', 
127
+      $this->getArrayOfTag(array('tribe')),
128
+    $soundclound, $jean);
129
+
130
+    $this->entity_manager->flush();
131
+  }
132
+}

+ 53 - 0
src/Muzich/CoreBundle/DataFixtures/ORM/LoadElementTypeData.php View File

@@ -0,0 +1,53 @@
1
+<?php
2
+
3
+namespace Muzich\UserBundle\DataFixtures\ORM;
4
+
5
+use Doctrine\Common\DataFixtures\AbstractFixture;
6
+use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
7
+use Symfony\Component\DependencyInjection\ContainerAwareInterface;
8
+use Symfony\Component\DependencyInjection\ContainerInterface;
9
+use Muzich\CoreBundle\Entity\ElementType;
10
+
11
+class LoadElementTypeData  extends AbstractFixture implements OrderedFixtureInterface, ContainerAwareInterface
12
+{
13
+  
14
+  private $container;
15
+  private $entity_manager;
16
+  
17
+  public function setContainer(ContainerInterface $container = null)
18
+  {
19
+    $this->container = $container;
20
+  }
21
+  
22
+  public function getOrder()
23
+  {
24
+    return 3; // the order in which fixtures will be loaded
25
+  }
26
+  
27
+  /**
28
+   *  
29
+   */
30
+  protected function createElementType($id, $name)
31
+  {
32
+    $elementType = new ElementType();
33
+    $elementType->setId($id);
34
+    $elementType->setName(ucfirst($name));
35
+    $this->entity_manager->persist($elementType);
36
+    $this->addReference('element_type_'.$id, $elementType);
37
+  }
38
+  
39
+  public function load($entity_manager)
40
+  {
41
+    $this->entity_manager = $entity_manager;
42
+
43
+    foreach (array(
44
+      'youtube' => 'Youtube', 'soundclound' => 'SoundCloud', 
45
+      'son2teuf' => 'Son2Teuf', 'jamendo' => 'jamendo'
46
+      ) as $id => $name)
47
+    {
48
+      $this->createElementType($id, $name);
49
+    }
50
+
51
+    $this->entity_manager->flush();
52
+  }
53
+}

+ 1 - 0
src/Muzich/CoreBundle/Entity/ElementType.php View File

@@ -3,6 +3,7 @@
3 3
 namespace Muzich\CoreBundle\Entity;
4 4
 
5 5
 use Doctrine\ORM\Mapping as ORM;
6
+use \Doctrine\Common\Collections\ArrayCollection;
6 7
 
7 8
 /**
8 9
  * Type d'element