Bonsoir,
Je tourne un peu en rond, j'ai une première question:
Comment reproduire un var_dump() sur une entité symfony2.
Mon problème est que je recherche à lire les info d'une partie de mon entité et que je n'arrive pas a comprendre son organisation.
Je poste mon entité:
Mon controleur:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93 <?php namespace SB\UserBundle\Entity; use Doctrine\ORM\Mapping as ORM; /** * UzerCarac * * @ORM\Table() * @ORM\Entity(repositoryClass="SB\UserBundle\Repository\UzerCaracRepository") */ class UzerCarac { /** * @ORM\ManyToOne(targetEntity="SB\UserBundle\Entity\UzerCateg") * @ORM\JoinColumn(nullable=false) */ private $uzercateg; /** * @var integer * * @ORM\Column(name="id", type="integer") * @ORM\Id * @ORM\GeneratedValue(strategy="AUTO") */ private $id; /** * @var string * * @ORM\Column(name="title", type="string", length=255) */ private $title; /** * Get id * * @return integer */ public function getId() { return $this->id; } /** * Set title * * @param string $title * @return UzerCarac */ public function setTitle($title) { $this->title = $title; return $this; } /** * Get title * * @return string */ public function getTitle() { return $this->title; } /** * Set uzercateg * * @param \SB\UserBundle\Entity\UzerCateg $uzercateg * @return UzerCarac */ public function setUzercateg(\SB\UserBundle\Entity\UzerCateg $uzercateg) { $this->uzercateg = $uzercateg; return $this; } /** * Get uzercateg * * @return \SB\UserBundle\Entity\UzerCateg */ public function getUzercateg() { return $this->uzercateg; } }
ma vue:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12 public function allAction() { $repository = $this->getDoctrine() ->getManager() ->getRepository('SBUserBundle:UzerCarac'); $carac = $repository->findAll(); if($carac === null) { throw $this->createNotFoundException('Vous n\'avez pas encore ajouté d\'utilisateur'); } return $this->render('SBUserBundle:UzerAdmin/UzerCarac:allcarac.html.twig', array('carac'=>$carac)); }
Je souhaiterai réorganiser dans ma vue mes caractéristiques et mes catégories, Les caractéristiques sont liées à certaines catégories(une seule catégorie par caractéristique)
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 {% extends '::base.html.twig' %} {% block body %} <div class="row-fluid"> <!-- Main hero unit for a primary marketing message or call to action --> <div class="hero-unit"> <p><h2>Toutes les caractéristiques</h2> <ul> {% for categorie in carac %} <h4>{{ categorie.title }}</h4> {% endfor %} </p> </div><!--/.class hero unit --> <a class="btn btn-info btn" href="#">modifier la recherche</a> </div> <!-- /row-fluid --> {% endblock %}
Partager