bonjour,
j'ai deux class un UrlContent qui est relier a Content.
Dans Content j'aimerai que la protected $refId s'auto increment en même temp que le reste.
voici les entity:

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
 
<?php
/**
 * Created by PhpStorm.
 * User: nicolaslefebvre
 * Date: 03/09/2016
 * Time: 21:15
 */
 
namespace Acme\ContentBundle\Entity;
 
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM;
use Cz\ManagerBundle\Entity\AbstractEntity;
use Acme\ContentBundle\Entity\Content;
/**
 * Content
 *
 * @ORM\Table(name="content_urls")
 * @ORM\Entity()
 */
class UrlContents
{
    /**
     * @var int
     *
     * @ORM\Column(name="id", type="integer")
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    private $id;
 
    /**
     * Unidirectional - Many users have marked many comments as read
     *
     * @ORM\ManyToMany(targetEntity="Acme\ContentBundle\Entity\Content", cascade={"persist", "remove"})
     */
    private $content;
 
 
    public function __construct()
    {
        $this->content = new ArrayCollection();
    }
 
    /**
     * @return mixed
     */
    public function getId()
    {
        return $this->id;
    }
 
    /**
     * @param mixed $id
     */
    public function setId($id)
    {
        $this->id = $id;
 
    }
    /**
     * @param mixed $id
     */
    public function setRefs(Content $ref)
    {
        $ref->setRef($this);
 
    }
 
 
 
    /**
     * Add content
     *
     * @param \Acme\ContentBundle\Entity\Content $content
     *
     * @return UrlContents
     */
    public function addContent(\Acme\ContentBundle\Entity\Content $content)
    {
        if (!$this->content->contains($content)) {
            $this->content->add($content);
        }
    }
 
    /**
     * Remove content
     *
     * @param \Acme\ContentBundle\Entity\Content $content
     */
    public function removeContent(\Acme\ContentBundle\Entity\Content $content)
    {
        $this->content->removeElement($content);
    }
 
    /**
     * Get content
     *
     * @return \Doctrine\Common\Collections\Collection
     */
    public function getContent()
    {
        return $this->content;
    }
}
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
<?php
 
namespace Acme\ContentBundle\Entity;
 
use Cz\ManagerBundle\Entity\AbstractEntity;
use Cz\ManagerBundle\Entity\HasNodeInterface;
use Cz\ManagerBundle\Helper\Utils\ClassLookup;
use Cz\PagesPartBundle\Helper\HasPageTemplateInterface;
use Cz\PagesPartBundle\PagePartAdmin\PagePartAdminConfiguratorInterface;
use Cz\PagesPartBundle\PageTemplate\PageTemplateInterface;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
use Doctrine\ORM\EntityManager;
use Gedmo\Mapping\Annotation as Gedmo;
/**
 * Content
 * @ORM\Table(name="content_url", indexes={@ORM\Index(name="idx_node_version_lookup", columns={"ref_id", "ref_entity_name"})})
 * @ORM\Entity(repositoryClass="Acme\ContentBundle\Repository\ContentRepository")
 *
 */
class Content
{
    /**
     * @var int
     *
     * @ORM\Column(name="id", type="integer")
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    private $id;
    /**
     * Bidirectional - Many comments are favorited by many users (INVERSE SIDE)
     *
     * @ORM\ManyToMany(targetEntity="Acme\ContentBundle\Entity\UrlContents", mappedBy="content")
     */
    private $urlcontent;
 
    /**
     * @var string
     *
     * @ORM\Column(type="string")
     */
    protected $lang;
 
    /**
     * @var bool
     *
     * @ORM\Column(type="boolean")
     */
    protected $online = false;
 
    /**
     * @var string
     *
     * @ORM\Column(type="string")
     */
    protected $title;
 
    /**
     * @var string
     *
     * @ORM\Column(type="string", nullable=true)
     * @Gedmo\Slug(fields={"title"})
     * @Assert\Regex("/^[a-zA-Z0-9\-_\/]+$/")
     */
    protected $slug;
 
    /**
     * @var string
     *
     * @ORM\Column(type="string", nullable=true)
     */
    protected $url;
 
    /**
     * @var string
     *
     * @ORM\Column(type="string", name="ref_entity_name")
     */
    protected $refEntityName;
    /**
     * @var int
     *
     * @ORM\Column(type="bigint", name="ref_id")
     *
     */
    protected $refId;
 
 
 
    public function __construct(UrlContents $urlContents = null)
    {
        $this->urlcontent = $urlContents;
        $this->refEntityName = 'Acme\ContentBundle\Entity\Content';
 
 
 
    }
 
    /**
     * @return mixed
     */
    public function getId()
    {
 
        return $this->id;
    }
 
    /**
     * @param mixed $id
     */
    public function setId($id)
    {
        $this->id = $id;
 
 
    }
 
 
    /**
     * @return string
     */
    public function getLang()
    {
        return $this->lang;
    }
 
    /**
     * @param string $lang
     */
    public function setLang($lang)
    {
        $this->lang = $lang;
    }
 
    /**
     * @return boolean
     */
    public function isOnline()
    {
        return $this->online;
    }
 
    /**
     * @param boolean $online
     */
    public function setOnline($online)
    {
        $this->online = $online;
    }
 
    /**
     * @return string
     */
    public function getTitle()
    {
        return $this->title;
    }
 
    /**
     * @param string $title
     */
    public function setTitle($title)
    {
        $this->title = $title;
    }
 
    /**
     * @return string
     */
    public function getSlug()
    {
        return $this->slug;
    }
 
    /**
     * @param string $slug
     */
    public function setSlug($slug)
    {
        $this->slug = $slug;
    }
 
    /**
     * @return string
     */
    public function getUrl()
    {
        return $this->url;
    }
 
    /**
     * @param string $url
     */
    public function setUrl($url)
    {
        $this->url = $url;
    }
 
    /**
     * @return string
     */
    public function getDefaultView()
    {
        return 'AcmeContentBundle:Pages\HomePage:view.html.twig';
    }
 
 
    /**
     * Set reference entity name
     *
     * @param string $refEntityName
     *
     * @return NodeVersion
     */
    protected function setRefEntityName($refEntityName)
    {
        $this->refEntityName = $refEntityName;
 
        return $this;
    }
 
    /**
     * Get reference entity name
     *
     * @return string
     */
    public function getRefEntityName()
    {
        return $this->refEntityName;
    }
 
    /**
     * @return null
     */
    public function getDefaultAdminType()
    {
        return null;
    }
 
 
    public function getPageEntity()
    {
 
    }
 
 
 
    /**
     * Get online
     *
     * @return boolean
     */
    public function getOnline()
    {
        return $this->online;
    }
    /**
     * Get refId
     *
     * @return int
     */
    public function getRefId()
    {
        return $this->refId;
    }
 
    /**
     * Set refId
     *
     * @param int $refId
     *
     * @return NodeVersion
     */
    protected function setRefId($refId)
    {
        $this->refId = $refId;
 
        return $this;
    }
 
 
 
 
 
    public function setRef($nb)
    {
 
        $this->setRefId($nb);
 
 
        return $this;
    }
 
    /**
     * @param EntityManager $em
     *
     * @return HasNodeInterface
     */
    public function getRef(EntityManager $em)
    {
        return $em->getRepository($this->getRefEntityName())->find($this->getRefId());
    }
 
 
 
    /**
     * Add urlcontent
     *
     * @param \Acme\ContentBundle\Entity\UrlContents $urlcontent
     *
     * @return Content
     */
    public function addUrlcontent(\Acme\ContentBundle\Entity\UrlContents $urlcontent)
    {
        $this->urlcontent[] = $urlcontent;
 
        return $this;
    }
    public function setUrlContent(\Acme\ContentBundle\Entity\UrlContents $urlcontent)
    {
        $this->urlcontent[] = $urlcontent;
 
        return $this;
    }
 
    /**
     * Remove urlcontent
     *
     * @param \Acme\ContentBundle\Entity\UrlContents $urlcontent
     */
    public function removeUrlcontent(\Acme\ContentBundle\Entity\UrlContents $urlcontent)
    {
        $this->urlcontent->removeElement($urlcontent);
    }
 
    /**
     * Get urlcontent
     *
     * @return \Doctrine\Common\Collections\Collection
     */
    public function getUrlcontent()
    {
        return $this->urlcontent;
    }
}
merci pour votre aide