Bonjour à tous,

J'ai une petite question..... dont hélas je n'ai pas trouvé la réponse

Le contexte fonctionnel :
- J'ai une liste de type de comités.
- J'ai une liste de types de projet qui peuvent être liés à 1 ou n type de comités.
- Quand un type de projet est supprimé, les liaisons le sont aussi
- Quand un type de comité est supprimé, s'il est utilisé alors une erreur apparaît.

Actuellement, mon type de comité et mon type de projet sont techniquement la même table. J'ai donc le code suivant :

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
 
<?php
/**
 * PHP version 5.3
 * 
 * @category   Gdp
 * @package    Gdp\Entity
 * @version    SVN:$Id: SystemValue.php 28 2013-03-28 16:04:44Z 16660 $
 * @author     16660
 */
 
namespace Gdp\Entity;
 
use Doctrine\ORM\Mapping as ORM;
 
/**
 * SystemValue
 *
 * @category   Gdp
 * @package    Gdp\Entity
 * @author     16660
 * @version    Release:1.0
 *
 * @ORM\Table(name="system_value")
 * @ORM\Entity(repositoryClass="Gdp\Repository\SystemValue")
 * @ORM\InheritanceType("SINGLE_TABLE")
 * @ORM\DiscriminatorColumn(name="type", type="string")
 * @ORM\DiscriminatorMap({"system" = "SystemValue", 
 * 	"system_locale" = "Gdp\Entity\SystemValue\Locale", 
 * 	"system_translation" = "Gdp\Entity\SystemValue\Translation",
 *  "domain" = "Gdp\Entity\SystemValue\Domain",
 *  "gdp_object_type" = "Gdp\Entity\SystemValue\GdpObjectType",
 *  "document_type" = "Gdp\Entity\SystemValue\DocumentType",
 *  "event_type" = "Gdp\Entity\SystemValue\EventType",
 *  "status" = "Gdp\Entity\SystemValue\Status",
 *  "committee_type" = "Gdp\Entity\SystemValue\CommitteeType",
 *  "project_type" = "Gdp\Entity\SystemValue\ProjectType",
 *  "project_review_type" = "Gdp\Entity\SystemValue\ReviewType\Project",
 *  "risk_analysis_review_type" = "Gdp\Entity\SystemValue\ReviewType\RiskAnalysis"
 * })
 * 
 * 
 */
class SystemValue extends MappedSuperclassBase
{
    /**
     * @var string
     *
     * @ORM\Column(name="code", type="string", length=255, nullable=false)
     */
    protected $code;
 
    /**
     * @var integer
     *
     * @ORM\Column(name="`order`", type="integer", nullable=true)
     */
    protected $order;
 
    /**
     * @var boolean
     *
     * @ORM\Column(name="status", type="boolean", nullable=false)
     */
    protected $status;
 
    /**
     * @var \Gdp\Entity\SystemValue\Domain
     *
     * @ORM\ManyToOne(targetEntity="\Gdp\Entity\SystemValue\Domain")
     * @ORM\JoinColumns({
     *   @ORM\JoinColumn(name="domain_id", referencedColumnName="id")
     * })
     */
    private $domain;
 
    /**
     * Bidirectional - One-To-Many (INVERSE SIDE)
     *
     * @ORM\OneToMany(targetEntity="Translation", mappedBy="systemValue", cascade={"persist", "remove"})
     */
    protected $translations;
 
    /**
     * @var \Doctrine\Common\Collections\Collection
     *
     * @ORM\ManyToMany(targetEntity="SystemValue", inversedBy="systemValue", cascade={"persist"})
     * @ORM\JoinTable(name="system_value_has_system_value",
     *   joinColumns={
     *     @ORM\JoinColumn(name="system_value_id", referencedColumnName="id")
     *   },
     *   inverseJoinColumns={
     *     @ORM\JoinColumn(name="linked_system_value_id", referencedColumnName="id")
     *   }
     * )
     */
    private $linkedSystemValue;
 
    /**
     * Constructor
     * 
     */
    public function SystemValue()
    {
    	$this->translations = new \Doctrine\Common\Collections\ArrayCollection();
    	$this->linkedSystemValue = new \Doctrine\Common\Collections\ArrayCollection();
    }
 
    /**
     * Set code
     *
     * @param string $code Code
     * @return SystemValue
     */
    public function setCode($code)
    {
        $this->code = $code;
 
        return $this;
    }
 
    /**
     * Get code
     *
     * @return string 
     */
    public function getCode()
    {
        return $this->code;
    }
 
    /**
     * Set order
     *
     * @param integer $order Order
     * @return SystemValue
     */
    public function setOrder($order)
    {
        $this->order = $order;
 
        return $this;
    }
 
    /**
     * Get order
     *
     * @return integer 
     */
    public function getOrder()
    {
        return $this->order;
    }
 
    /**
     * Set status
     *
     * @param boolean $status Status
     * @return SystemValue
     */
    public function setStatus($status)
    {
        $this->status = $status;
 
        return $this;
    }
 
    /**
     * Get status
     *
     * @return string
     */
    public function getStatus()
    {
    	return $this->status;
    }
 
    /**
     * Get domain
     *
     * @return boolean 
     */
    public function getDomain()
    {
        return $this->domain;
    }
 
    /**
     * Set domain
     *
     * @param \Gdp\Entity\SystemValue\Domain $domain Domain
     * @return SystemValue
     */
    public function setDomain(\Gdp\Entity\SystemValue\Domain $domain = null)
    {
    	$this->domain = $domain;
 
    	return $this;
    }
 
    /**
     * Add secondReviewTypeHasSection
     *
     * @param \Gdp\Entity\Translation $translation translation
     * @return LocalizedValue
     */
    public function addTranslation(\Gdp\Entity\Translation $translation)
    {
    	$this->translations[] = $translation;
 
    	return $this;
    }
 
    /**
     * Remove secondReviewTypeHasSection
     *
     * @param \Gdp\Entity\Translation $translation Translation
     * @return void
     */
    public function removeTranslation(\Gdp\Entity\Translation $translation)
    {
    	$this->translations->removeElement($translation);
    }
 
    /**
     * 
     * @return \Doctrine\Common\Collections\ArrayCollection
     */
    public function getTranslations() {
    	return $this->translations;
    }
 
    /**
     * Add linkedSystemValue
     *
     * @param \Gdp\Entity\SystemValue $linkedSystemValue Linked System Value
     * @return SystemValue
     */
    public function addLinkedSystemValue(\Gdp\Entity\SystemValue $linkedSystemValue)
    {
    	$this->linkedSystemValue[] = $linkedSystemValue;
 
    	return $this;
    }
 
    /**
     * Remove linkedSystemValue
     *
     * @param \Gdp\Entity\SystemValue $linkedSystemValue Linked 
	 * @return SystemValue
     */
    public function removeLinkedSystemValue(\Gdp\Entity\SystemValue $linkedSystemValue)
    {
    	$this->linkedSystemValue->removeElement($linkedSystemValue);
 
    	return $this;
    }
 
    /**
     * Get linkedSystemValue
     *
     * @return \Doctrine\Common\Collections\Collection
     */
    public function getLinkedSystemValue()
    {
    	return $this->linkedSystemValue;
    }
}
Avec cette configuration, quand un type de comité ou un type de projet est supprimé, les liaisons sont elles aussi supprimées

Mon besoin serait que les "linked_system_value_id" génère une contrainte d'intégrité si elles sont utilisées. Hormis les évènement Doctrine (preRemove), y-a-t-il une solution automatique ?

Mercid 'avance pour votre aide/expertise