Browse Source

Correction des nomages des relations Entre User, Tags ...

bastien 13 years ago
parent
commit
267123f3e4

File diff suppressed because it is too large
+ 6550 - 0
app/logs/dev.log


+ 35 - 42
src/Muzich/CoreBundle/Entity/Tag.php View File

12
 {
12
 {
13
   
13
   
14
   /**
14
   /**
15
-   * @ORM\ManyToMany(targetEntity="Tag", mappedBy="tags")
15
+   * @ORM\ManyToMany(targetEntity="Element", mappedBy="tags")
16
    */
16
    */
17
   protected $elements;
17
   protected $elements;
18
   
18
   
19
   /**
19
   /**
20
-   * @ORM\OneToMany(targetEntity="Muzich\CoreBundle\Entity\UsersTagsFavorites", mappedBy="tags_favorites")
20
+   * @ORM\OneToMany(targetEntity="UsersTagsFavorites", mappedBy="tag")
21
    */
21
    */
22
   protected $users_favorites;
22
   protected $users_favorites;
23
   
23
   
35
    */
35
    */
36
   protected $name;
36
   protected $name;
37
   
37
   
38
+  /**
39
+   * 
40
+   */
38
   public function __construct()
41
   public function __construct()
39
   {
42
   {
40
     $this->users_favorites = new \Doctrine\Common\Collections\ArrayCollection();
43
     $this->users_favorites = new \Doctrine\Common\Collections\ArrayCollection();
72
       return $this->name;
75
       return $this->name;
73
   }
76
   }
74
 
77
 
75
-  /**
76
-   * Add elements
77
-   *
78
-   * @param Muzich\CoreBundle\Entity\Tag $elements
79
-   */
80
-  public function addTag(Muzich\CoreBundle\Entity\Tag $elements)
81
-  {
82
-      $this->elements[] = $elements;
83
-  }
84
-
85
-  /**
86
-   * Get elements
87
-   *
88
-   * @return Doctrine\Common\Collections\Collection 
89
-   */
90
-  public function getElements()
91
-  {
92
-      return $this->elements;
93
-  }
94
 
78
 
95
-  /**
96
-   * Add users_favorites
97
-   *
98
-   * @param Muzich\UserBundle\Entity\User $usersFavorites
99
-   */
100
-  public function addUser(Muzich\UserBundle\Entity\User $usersFavorites)
101
-  {
102
-      $this->users_favorites[] = $usersFavorites;
103
-  }
79
+    /**
80
+     * Add elements
81
+     *
82
+     * @param Element $elements
83
+     */
84
+    public function addElement(Element $elements)
85
+    {
86
+        $this->elements[] = $elements;
87
+    }
104
 
88
 
105
-  /**
106
-   * Get users_favorites
107
-   *
108
-   * @return Doctrine\Common\Collections\Collection 
109
-   */
110
-  public function getUsersFavorites()
111
-  {
112
-      return $this->users_favorites;
113
-  }
114
-    
89
+    /**
90
+     * Get elements
91
+     *
92
+     * @return Doctrine\Common\Collections\Collection 
93
+     */
94
+    public function getElements()
95
+    {
96
+        return $this->elements;
97
+    }
115
 
98
 
116
     /**
99
     /**
117
      * Add users_favorites
100
      * Add users_favorites
118
      *
101
      *
119
-     * @param Muzich\CoreBundle\Entity\UsersTagsFavorites $usersFavorites
102
+     * @param UsersTagsFavorites $usersFavorites
120
      */
103
      */
121
-    public function addUsersTagsFavorites(Muzich\CoreBundle\Entity\UsersTagsFavorites $usersFavorites)
104
+    public function addUsersTagsFavorites(UsersTagsFavorites $usersFavorites)
122
     {
105
     {
123
         $this->users_favorites[] = $usersFavorites;
106
         $this->users_favorites[] = $usersFavorites;
124
     }
107
     }
108
+
109
+    /**
110
+     * Get users_favorites
111
+     *
112
+     * @return Doctrine\Common\Collections\Collection 
113
+     */
114
+    public function getUsersFavorites()
115
+    {
116
+        return $this->users_favorites;
117
+    }
125
 }
118
 }

+ 42 - 40
src/Muzich/CoreBundle/Entity/UsersTagsFavorites.php View File

12
 {
12
 {
13
   
13
   
14
   /**
14
   /**
15
-   * @ORM\ManyToOne(targetEntity="Muzich\UserBundle\Entity\User", inversedBy="tags_favorites")
15
+   * @ORM\ManyToOne(targetEntity="Muzich\UserBundle\Entity\User", inversedBy="tags")
16
    * @ORM\JoinColumn(name="user_id", referencedColumnName="id")
16
    * @ORM\JoinColumn(name="user_id", referencedColumnName="id")
17
    */
17
    */
18
-  protected $users_favorites;
18
+  protected $user;
19
   
19
   
20
   /**
20
   /**
21
-   * @ORM\ManyToOne(targetEntity="Muzich\CoreBundle\Entity\Tag", inversedBy="users_favorites")
21
+   * @ORM\ManyToOne(targetEntity="Tag", inversedBy="users")
22
    * @ORM\JoinColumn(name="tag_id", referencedColumnName="id")
22
    * @ORM\JoinColumn(name="tag_id", referencedColumnName="id")
23
    */
23
    */
24
-  protected $tags_favorites;
24
+  protected $tag;
25
   
25
   
26
   
26
   
27
   /**
27
   /**
58
   {
58
   {
59
       return $this->position;
59
       return $this->position;
60
   }
60
   }
61
+  
61
 
62
 
62
   /**
63
   /**
63
-   * Set users_favorites
64
+   * Get id
64
    *
65
    *
65
-   * @param Muzich\UserBundle\Entity\User $usersFavorites
66
+   * @return integer 
66
    */
67
    */
67
-  public function setUsersFavorites(Muzich\UserBundle\Entity\User $usersFavorites)
68
+  public function getId()
68
   {
69
   {
69
-      $this->users_favorites = $usersFavorites;
70
+      return $this->id;
70
   }
71
   }
71
 
72
 
72
-  /**
73
-   * Get users_favorites
74
-   *
75
-   * @return \Muzich\UserBundle\Entity\User 
76
-   */
77
-  public function getUsersFavorites()
78
-  {
79
-      return $this->users_favorites;
80
-  }
81
 
73
 
82
-  /**
83
-   * Set tags_favorites
84
-   *
85
-   * @param Muzich\CoreBundle\Entity\Tag $tagsFavorites
86
-   */
87
-  public function setTagsFavorites(Muzich\CoreBundle\Entity\Tag $tagsFavorites)
88
-  {
89
-      $this->tags_favorites = $tagsFavorites;
90
-  }
91
 
74
 
92
-  /**
93
-   * Get tags_favorites
94
-   *
95
-   * @return Muzich\CoreBundle\Entity\Tag 
96
-   */
97
-  public function getTagsFavorites()
98
-  {
99
-      return $this->tags_favorites;
100
-  }
101
-  
75
+    /**
76
+     * Set user
77
+     *
78
+     * @param Muzich\UserBundle\Entity\User $user
79
+     */
80
+    public function setUser(Muzich\UserBundle\Entity\User $user)
81
+    {
82
+        $this->user = $user;
83
+    }
84
+
85
+    /**
86
+     * Get user
87
+     *
88
+     * @return Muzich\UserBundle\Entity\User 
89
+     */
90
+    public function getUser()
91
+    {
92
+        return $this->user;
93
+    }
94
+
95
+    /**
96
+     * Set tag
97
+     *
98
+     * @param Muzich\CoreBundle\Entity\Tag $tag
99
+     */
100
+    public function setTag(Muzich\CoreBundle\Entity\Tag $tag)
101
+    {
102
+        $this->tag = $tag;
103
+    }
102
 
104
 
103
     /**
105
     /**
104
-     * Get id
106
+     * Get tag
105
      *
107
      *
106
-     * @return integer 
108
+     * @return Muzich\CoreBundle\Entity\Tag 
107
      */
109
      */
108
-    public function getId()
110
+    public function getTag()
109
     {
111
     {
110
-        return $this->id;
112
+        return $this->tag;
111
     }
113
     }
112
 }
114
 }

+ 93 - 3
src/Muzich/IndexBundle/Controller/IndexController.php View File

2
 
2
 
3
 namespace Muzich\IndexBundle\Controller;
3
 namespace Muzich\IndexBundle\Controller;
4
 
4
 
5
-use Symfony\Component\HttpFoundation\Response;
5
+//use Symfony\Component\HttpFoundation\Response;
6
+use Symfony\Bundle\FrameworkBundle\Controller\Controller;
7
+use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
6
 
8
 
7
-class IndexController
9
+use Muzich\CoreBundle\Entity\Tag;
10
+use Muzich\CoreBundle\Entity\UsersTagsFavorites;
11
+use Muzich\UserBundle\Entity\User;
12
+
13
+class IndexController extends Controller
8
 {
14
 {
15
+  /**
16
+   *
17
+   * @Template()
18
+   */
9
   public function indexAction()
19
   public function indexAction()
10
   {
20
   {
11
-    return new Response('<html><body>Hello!</body></html>');
21
+    $em = $this->getDoctrine()->getEntityManager();
22
+    
23
+    $bux = $em
24
+      ->getRepository('MuzichUserBundle:User')
25
+      ->findOneByUsername('bux')
26
+    ;
27
+    
28
+//    $tag_hardtek = $em
29
+//      ->getRepository('MuzichCoreBundle:Tag')
30
+//      ->findOneByName('Hardtek')
31
+//    ;
32
+//    
33
+//    if (!$tag_hardtek)
34
+//    {
35
+//      $tag_hardtek = new Tag();
36
+//      $tag_hardtek->setName('Hardtek');
37
+//      $em->persist($tag_hardtek);
38
+//    }
39
+//    
40
+//    $tag_tribe = $em
41
+//      ->getRepository('MuzichCoreBundle:Tag')
42
+//      ->findOneByName('Tribe')
43
+//    ;
44
+//    
45
+//    if (!$tag_tribe)
46
+//    {
47
+//      $tag_tribe = new Tag();
48
+//      $tag_tribe->setName('Tribe');
49
+//      $em->persist($tag_tribe);
50
+//    }
51
+//    
52
+//    //
53
+//    
54
+//    $user_tag_favorite_bux_hardtek = $em
55
+//      ->getRepository('MuzichCoreBundle:UsersTagsFavorites')
56
+//      ->findOneBy(array(
57
+//        'tag' => $tag_hardtek->getId(),
58
+//        'user' => $bux->getId()
59
+//      ))
60
+//    ;
61
+//    
62
+//    if (!$user_tag_favorite_bux_hardtek)
63
+//    {
64
+//      $user_tag_favorite_bux_hardtek = new UsersTagsFavorites();
65
+//      $user_tag_favorite_bux_hardtek->setTagFavorite($tag_hardtek);
66
+//      $user_tag_favorite_bux_hardtek->setUserFavorite($bux);
67
+//      $user_tag_favorite_bux_hardtek->setPosition(0);
68
+//      $em->persist($user_tag_favorite_bux_hardtek);
69
+//    }
70
+//    
71
+//    $user_tag_favorite_bux_tribe = $em
72
+//      ->getRepository('MuzichCoreBundle:UsersTagsFavorites')
73
+//      ->findOneBy(array(
74
+//        'tag' => $tag_tribe->getId(),
75
+//        'user' => $bux->getId()
76
+//      ))
77
+//    ;
78
+//    
79
+//    if (!$user_tag_favorite_bux_tribe)
80
+//    {
81
+//      $user_tag_favorite_bux_tribe = new UsersTagsFavorites();
82
+//      $user_tag_favorite_bux_tribe->setTagFavorite($tag_tribe);
83
+//      $user_tag_favorite_bux_tribe->setUserFavorite($bux);
84
+//      $user_tag_favorite_bux_tribe->setPosition(0);
85
+//      $em->persist($user_tag_favorite_bux_tribe);
86
+//    }
87
+//    
88
+//    
89
+//    $em->flush();
90
+    
91
+    //$bux = new User();
92
+    //var_dump($bux->getTagsFavorites()->get(0)->getTag()->getName());
93
+    
94
+    foreach ($bux->getTagsFavorites() as $UserTagFavorite)
95
+    {
96
+      echo $UserTagFavorite->getTag()->getName().'<br />';
97
+    }
98
+    
99
+    die();
100
+        
101
+    return array('bux' => $bux);
12
   }
102
   }
13
 }
103
 }

+ 7 - 0
src/Muzich/IndexBundle/Resources/views/Index/index.html.twig View File

1
+{% extends "MuzichCoreBundle::layout.html.twig" %}
2
+
3
+{% block content %}
4
+    <h1>Hello {{ bux.username }}!</h1>
5
+{% endblock %}
6
+
7
+{% set code = code(_self) %}

+ 2 - 2
src/Muzich/UserBundle/Entity/User.php View File

13
 {
13
 {
14
   
14
   
15
   /**
15
   /**
16
-   * @ORM\OneToMany(targetEntity="Muzich\CoreBundle\Entity\UsersTagsFavorites", mappedBy="users_favorites")
16
+   * @ORM\OneToMany(targetEntity="Muzich\CoreBundle\Entity\UsersTagsFavorites", mappedBy="user")
17
    */
17
    */
18
   private $tags_favorites;
18
   private $tags_favorites;
19
   
19
   
26
 
26
 
27
   public function __construct()
27
   public function __construct()
28
   {
28
   {
29
-    $this->tags_favorites = new Doctrine\Common\Collections\ArrayCollection();
29
+    $this->tags_favorites = new \Doctrine\Common\Collections\ArrayCollection();
30
     parent::__construct();
30
     parent::__construct();
31
   }
31
   }
32
 
32