Bonjour,
je suis entrain de chipoter avec mongoDB dans SF2. Tout se passe bien juste qu'a l'édition d'une category ou il me sort une erreur que je n'ai jamais vu avec les entities :
Voici mon Document Category :Neither the property "name" nor one of the methods "getName()", "isName()", "hasName()", "__get()" or "__call()" exist and have public access in class "Doctrine\ODM\MongoDB\LoggableCursor".
mon Document Product :
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 <?php namespace Site\StoreBundle\Document; use Doctrine\ODM\MongoDB\Mapping\Annotations as MongoDB; /** * @MongoDB\Document */ class Category { /** * @MongoDB\Id */ protected $id; /** * @MongoDB\String */ protected $name; /** * @MongoDB\ReferenceMany(targetDocument="Product") */ private $products = array(); public function __contructor() { $this->products = new \Doctrine\Common\Collections\ArrayCollection(); } /** * Get id * * @return id $id */ public function getId() { return $this->id; } /** * Set name * * @param string $name * @return self */ public function setName($name) { $this->name = $name; return $this; } /** * Get name * * @return string $name */ public function getName() { return $this->name; } public function getProducts() { return $this->products; } public function __construct() { $this->products = new \Doctrine\Common\Collections\ArrayCollection(); } /** * Add product * * @param Site\StoreBundle\Document\Product $product */ public function addProduct(\Site\StoreBundle\Document\Product $product) { $this->products[] = $product; } /** * Remove product * * @param Site\StoreBundle\Document\Product $product */ public function removeProduct(\Site\StoreBundle\Document\Product $product) { $this->products->removeElement($product); } }
Et l'action edit :
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107 <?php namespace Site\StoreBundle\Document; use Doctrine\ODM\MongoDB\Mapping\Annotations as MongoDB; /** * @MongoDB\Document */ class Product { /** * @MongoDB\Id */ protected $id; /** * @MongoDB\String */ protected $name; /** * @MongoDB\Float */ protected $price; /** * @MongoDB\ReferenceOne(targetDocument="Category") */ private $category; /** * Get id * * @return id $id */ public function getId() { return $this->id; } /** * Set name * * @param string $name * @return self */ public function setName($name) { $this->name = $name; return $this; } /** * Get name * * @return string $name */ public function getName() { return $this->name; } /** * Set price * * @param float $price * @return self */ public function setPrice($price) { $this->price = $price; return $this; } /** * Get price * * @return float $price */ public function getPrice() { return $this->price; } /** * Set category * * @param Site\StoreBundle\Document\Category $category * @return self */ public function setCategory(\Site\StoreBundle\Document\Category $category) { $this->category = $category; return $this; } /** * Get category * * @return Site\StoreBundle\Document\Category $category */ public function getCategory() { return $this->category; } }
C'est surement tout con, mais je ne vois vraiment pas.
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 public function editCategoryAction($id) { $category = $this->get('doctrine_mongodb')->getManager()->getRepository('SiteStoreBundle:Category')->findById($id); $form = $this->createFormBuilder($category) ->add('name') ->getForm(); $request = $this->get('request'); if($request->isMethod('POST')) { $form->bind($request); if ($form->isValid()) { $update = $this->get('doctrine_mongodb')->getManager(); $update->persist($category); $update->flush(); return $this->redirect($this->generateUrl('home')); } } return $this->render('SiteStoreBundle:Default:editCategory.html.twig', array( 'form' => $form->createView(), 'category' => $category )); }
Merci à vous
Partager