Complex classes like ClassMetadataInfo often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use ClassMetadataInfo, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
51 | class ClassMetadataInfo implements ClassMetadata |
||
52 | { |
||
53 | /* The inheritance mapping types */ |
||
54 | /** |
||
55 | * NONE means the class does not participate in an inheritance hierarchy |
||
56 | * and therefore does not need an inheritance mapping type. |
||
57 | */ |
||
58 | const INHERITANCE_TYPE_NONE = 1; |
||
59 | |||
60 | /** |
||
61 | * JOINED means the class will be persisted according to the rules of |
||
62 | * <tt>Class Table Inheritance</tt>. |
||
63 | */ |
||
64 | const INHERITANCE_TYPE_JOINED = 2; |
||
65 | |||
66 | /** |
||
67 | * SINGLE_TABLE means the class will be persisted according to the rules of |
||
68 | * <tt>Single Table Inheritance</tt>. |
||
69 | */ |
||
70 | const INHERITANCE_TYPE_SINGLE_TABLE = 3; |
||
71 | |||
72 | /** |
||
73 | * TABLE_PER_CLASS means the class will be persisted according to the rules |
||
74 | * of <tt>Concrete Table Inheritance</tt>. |
||
75 | */ |
||
76 | const INHERITANCE_TYPE_TABLE_PER_CLASS = 4; |
||
77 | |||
78 | /* The Id generator types. */ |
||
79 | /** |
||
80 | * AUTO means the generator type will depend on what the used platform prefers. |
||
81 | * Offers full portability. |
||
82 | */ |
||
83 | const GENERATOR_TYPE_AUTO = 1; |
||
84 | |||
85 | /** |
||
86 | * SEQUENCE means a separate sequence object will be used. Platforms that do |
||
87 | * not have native sequence support may emulate it. Full portability is currently |
||
88 | * not guaranteed. |
||
89 | */ |
||
90 | const GENERATOR_TYPE_SEQUENCE = 2; |
||
91 | |||
92 | /** |
||
93 | * TABLE means a separate table is used for id generation. |
||
94 | * Offers full portability. |
||
95 | */ |
||
96 | const GENERATOR_TYPE_TABLE = 3; |
||
97 | |||
98 | /** |
||
99 | * IDENTITY means an identity column is used for id generation. The database |
||
100 | * will fill in the id column on insertion. Platforms that do not support |
||
101 | * native identity columns may emulate them. Full portability is currently |
||
102 | * not guaranteed. |
||
103 | */ |
||
104 | const GENERATOR_TYPE_IDENTITY = 4; |
||
105 | |||
106 | /** |
||
107 | * NONE means the class does not have a generated id. That means the class |
||
108 | * must have a natural, manually assigned id. |
||
109 | */ |
||
110 | const GENERATOR_TYPE_NONE = 5; |
||
111 | |||
112 | /** |
||
113 | * UUID means that a UUID/GUID expression is used for id generation. Full |
||
114 | * portability is currently not guaranteed. |
||
115 | */ |
||
116 | const GENERATOR_TYPE_UUID = 6; |
||
117 | |||
118 | /** |
||
119 | * CUSTOM means that customer will use own ID generator that supposedly work |
||
120 | */ |
||
121 | const GENERATOR_TYPE_CUSTOM = 7; |
||
122 | |||
123 | /** |
||
124 | * DEFERRED_IMPLICIT means that changes of entities are calculated at commit-time |
||
125 | * by doing a property-by-property comparison with the original data. This will |
||
126 | * be done for all entities that are in MANAGED state at commit-time. |
||
127 | * |
||
128 | * This is the default change tracking policy. |
||
129 | */ |
||
130 | const CHANGETRACKING_DEFERRED_IMPLICIT = 1; |
||
131 | |||
132 | /** |
||
133 | * DEFERRED_EXPLICIT means that changes of entities are calculated at commit-time |
||
134 | * by doing a property-by-property comparison with the original data. This will |
||
135 | * be done only for entities that were explicitly saved (through persist() or a cascade). |
||
136 | */ |
||
137 | const CHANGETRACKING_DEFERRED_EXPLICIT = 2; |
||
138 | |||
139 | /** |
||
140 | * NOTIFY means that Doctrine relies on the entities sending out notifications |
||
141 | * when their properties change. Such entity classes must implement |
||
142 | * the <tt>NotifyPropertyChanged</tt> interface. |
||
143 | */ |
||
144 | const CHANGETRACKING_NOTIFY = 3; |
||
145 | |||
146 | /** |
||
147 | * Specifies that an association is to be fetched when it is first accessed. |
||
148 | */ |
||
149 | const FETCH_LAZY = 2; |
||
150 | |||
151 | /** |
||
152 | * Specifies that an association is to be fetched when the owner of the |
||
153 | * association is fetched. |
||
154 | */ |
||
155 | const FETCH_EAGER = 3; |
||
156 | |||
157 | /** |
||
158 | * Specifies that an association is to be fetched lazy (on first access) and that |
||
159 | * commands such as Collection#count, Collection#slice are issued directly against |
||
160 | * the database if the collection is not yet initialized. |
||
161 | */ |
||
162 | const FETCH_EXTRA_LAZY = 4; |
||
163 | |||
164 | /** |
||
165 | * Identifies a one-to-one association. |
||
166 | */ |
||
167 | const ONE_TO_ONE = 1; |
||
168 | |||
169 | /** |
||
170 | * Identifies a many-to-one association. |
||
171 | */ |
||
172 | const MANY_TO_ONE = 2; |
||
173 | |||
174 | /** |
||
175 | * Identifies a one-to-many association. |
||
176 | */ |
||
177 | const ONE_TO_MANY = 4; |
||
178 | |||
179 | /** |
||
180 | * Identifies a many-to-many association. |
||
181 | */ |
||
182 | const MANY_TO_MANY = 8; |
||
183 | |||
184 | /** |
||
185 | * Combined bitmask for to-one (single-valued) associations. |
||
186 | */ |
||
187 | const TO_ONE = 3; |
||
188 | |||
189 | /** |
||
190 | * Combined bitmask for to-many (collection-valued) associations. |
||
191 | */ |
||
192 | const TO_MANY = 12; |
||
193 | |||
194 | /** |
||
195 | * ReadOnly cache can do reads, inserts and deletes, cannot perform updates or employ any locks, |
||
196 | */ |
||
197 | const CACHE_USAGE_READ_ONLY = 1; |
||
198 | |||
199 | /** |
||
200 | * Nonstrict Read Write Cache doesn’t employ any locks but can do inserts, update and deletes. |
||
201 | */ |
||
202 | const CACHE_USAGE_NONSTRICT_READ_WRITE = 2; |
||
203 | |||
204 | /** |
||
205 | * Read Write Attempts to lock the entity before update/delete. |
||
206 | */ |
||
207 | const CACHE_USAGE_READ_WRITE = 3; |
||
208 | |||
209 | /** |
||
210 | * READ-ONLY: The name of the entity class. |
||
211 | * |
||
212 | * @var string |
||
213 | */ |
||
214 | public $name; |
||
215 | |||
216 | /** |
||
217 | * READ-ONLY: The namespace the entity class is contained in. |
||
218 | * |
||
219 | * @var string |
||
220 | * |
||
221 | * @todo Not really needed. Usage could be localized. |
||
222 | */ |
||
223 | public $namespace; |
||
224 | |||
225 | /** |
||
226 | * READ-ONLY: The name of the entity class that is at the root of the mapped entity inheritance |
||
227 | * hierarchy. If the entity is not part of a mapped inheritance hierarchy this is the same |
||
228 | * as {@link $name}. |
||
229 | * |
||
230 | * @var string |
||
231 | */ |
||
232 | public $rootEntityName; |
||
233 | |||
234 | /** |
||
235 | * READ-ONLY: The definition of custom generator. Only used for CUSTOM |
||
236 | * generator type |
||
237 | * |
||
238 | * The definition has the following structure: |
||
239 | * <code> |
||
240 | * array( |
||
241 | * 'class' => 'ClassName', |
||
242 | * ) |
||
243 | * </code> |
||
244 | * |
||
245 | * @var array |
||
246 | * |
||
247 | * @todo Merge with tableGeneratorDefinition into generic generatorDefinition |
||
248 | */ |
||
249 | public $customGeneratorDefinition; |
||
250 | |||
251 | /** |
||
252 | * The name of the custom repository class used for the entity class. |
||
253 | * (Optional). |
||
254 | * |
||
255 | * @var string |
||
256 | */ |
||
257 | public $customRepositoryClassName; |
||
258 | |||
259 | /** |
||
260 | * READ-ONLY: Whether this class describes the mapping of a mapped superclass. |
||
261 | * |
||
262 | * @var boolean |
||
263 | */ |
||
264 | public $isMappedSuperclass = false; |
||
265 | |||
266 | /** |
||
267 | * READ-ONLY: Whether this class describes the mapping of an embeddable class. |
||
268 | * |
||
269 | * @var boolean |
||
270 | */ |
||
271 | public $isEmbeddedClass = false; |
||
272 | |||
273 | /** |
||
274 | * READ-ONLY: The names of the parent classes (ancestors). |
||
275 | * |
||
276 | * @var array |
||
277 | */ |
||
278 | public $parentClasses = array(); |
||
279 | |||
280 | /** |
||
281 | * READ-ONLY: The names of all subclasses (descendants). |
||
282 | * |
||
283 | * @var array |
||
284 | */ |
||
285 | public $subClasses = array(); |
||
286 | |||
287 | /** |
||
288 | * READ-ONLY: The names of all embedded classes based on properties. |
||
289 | * |
||
290 | * @var array |
||
291 | */ |
||
292 | public $embeddedClasses = array(); |
||
293 | |||
294 | /** |
||
295 | * READ-ONLY: The named queries allowed to be called directly from Repository. |
||
296 | * |
||
297 | * @var array |
||
298 | */ |
||
299 | public $namedQueries = array(); |
||
300 | |||
301 | /** |
||
302 | * READ-ONLY: The named native queries allowed to be called directly from Repository. |
||
303 | * |
||
304 | * A native SQL named query definition has the following structure: |
||
305 | * <pre> |
||
306 | * array( |
||
307 | * 'name' => <query name>, |
||
308 | * 'query' => <sql query>, |
||
309 | * 'resultClass' => <class of the result>, |
||
310 | * 'resultSetMapping' => <name of a SqlResultSetMapping> |
||
311 | * ) |
||
312 | * </pre> |
||
313 | * |
||
314 | * @var array |
||
315 | */ |
||
316 | public $namedNativeQueries = array(); |
||
317 | |||
318 | /** |
||
319 | * READ-ONLY: The mappings of the results of native SQL queries. |
||
320 | * |
||
321 | * A native result mapping definition has the following structure: |
||
322 | * <pre> |
||
323 | * array( |
||
324 | * 'name' => <result name>, |
||
325 | * 'entities' => array(<entity result mapping>), |
||
326 | * 'columns' => array(<column result mapping>) |
||
327 | * ) |
||
328 | * </pre> |
||
329 | * |
||
330 | * @var array |
||
331 | */ |
||
332 | public $sqlResultSetMappings = array(); |
||
333 | |||
334 | /** |
||
335 | * READ-ONLY: The field names of all fields that are part of the identifier/primary key |
||
336 | * of the mapped entity class. |
||
337 | * |
||
338 | * @var array |
||
339 | */ |
||
340 | public $identifier = array(); |
||
341 | |||
342 | /** |
||
343 | * READ-ONLY: The inheritance mapping type used by the class. |
||
344 | * |
||
345 | * @var integer |
||
346 | */ |
||
347 | public $inheritanceType = self::INHERITANCE_TYPE_NONE; |
||
348 | |||
349 | /** |
||
350 | * READ-ONLY: The Id generator type used by the class. |
||
351 | * |
||
352 | * @var int |
||
353 | */ |
||
354 | public $generatorType = self::GENERATOR_TYPE_NONE; |
||
355 | |||
356 | /** |
||
357 | * READ-ONLY: The field mappings of the class. |
||
358 | * Keys are field names and values are mapping definitions. |
||
359 | * |
||
360 | * The mapping definition array has the following values: |
||
361 | * |
||
362 | * - <b>fieldName</b> (string) |
||
363 | * The name of the field in the Entity. |
||
364 | * |
||
365 | * - <b>type</b> (string) |
||
366 | * The type name of the mapped field. Can be one of Doctrine's mapping types |
||
367 | * or a custom mapping type. |
||
368 | * |
||
369 | * - <b>columnName</b> (string, optional) |
||
370 | * The column name. Optional. Defaults to the field name. |
||
371 | * |
||
372 | * - <b>length</b> (integer, optional) |
||
373 | * The database length of the column. Optional. Default value taken from |
||
374 | * the type. |
||
375 | * |
||
376 | * - <b>id</b> (boolean, optional) |
||
377 | * Marks the field as the primary key of the entity. Multiple fields of an |
||
378 | * entity can have the id attribute, forming a composite key. |
||
379 | * |
||
380 | * - <b>nullable</b> (boolean, optional) |
||
381 | * Whether the column is nullable. Defaults to FALSE. |
||
382 | * |
||
383 | * - <b>columnDefinition</b> (string, optional, schema-only) |
||
384 | * The SQL fragment that is used when generating the DDL for the column. |
||
385 | * |
||
386 | * - <b>precision</b> (integer, optional, schema-only) |
||
387 | * The precision of a decimal column. Only valid if the column type is decimal. |
||
388 | * |
||
389 | * - <b>scale</b> (integer, optional, schema-only) |
||
390 | * The scale of a decimal column. Only valid if the column type is decimal. |
||
391 | * |
||
392 | * - <b>'unique'</b> (string, optional, schema-only) |
||
393 | * Whether a unique constraint should be generated for the column. |
||
394 | * |
||
395 | * @var array |
||
396 | */ |
||
397 | public $fieldMappings = array(); |
||
398 | |||
399 | /** |
||
400 | * READ-ONLY: An array of field names. Used to look up field names from column names. |
||
401 | * Keys are column names and values are field names. |
||
402 | * |
||
403 | * @var array |
||
404 | */ |
||
405 | public $fieldNames = array(); |
||
406 | |||
407 | /** |
||
408 | * READ-ONLY: A map of field names to column names. Keys are field names and values column names. |
||
409 | * Used to look up column names from field names. |
||
410 | * This is the reverse lookup map of $_fieldNames. |
||
411 | * |
||
412 | * @var array |
||
413 | * |
||
414 | * @deprecated 3.0 Remove this. |
||
415 | */ |
||
416 | public $columnNames = array(); |
||
417 | |||
418 | /** |
||
419 | * READ-ONLY: The discriminator value of this class. |
||
420 | * |
||
421 | * <b>This does only apply to the JOINED and SINGLE_TABLE inheritance mapping strategies |
||
422 | * where a discriminator column is used.</b> |
||
423 | * |
||
424 | * @var mixed |
||
425 | * |
||
426 | * @see discriminatorColumn |
||
427 | */ |
||
428 | public $discriminatorValue; |
||
429 | |||
430 | /** |
||
431 | * READ-ONLY: The discriminator map of all mapped classes in the hierarchy. |
||
432 | * |
||
433 | * <b>This does only apply to the JOINED and SINGLE_TABLE inheritance mapping strategies |
||
434 | * where a discriminator column is used.</b> |
||
435 | * |
||
436 | * @var mixed |
||
437 | * |
||
438 | * @see discriminatorColumn |
||
439 | */ |
||
440 | public $discriminatorMap = array(); |
||
441 | |||
442 | /** |
||
443 | * READ-ONLY: The definition of the discriminator column used in JOINED and SINGLE_TABLE |
||
444 | * inheritance mappings. |
||
445 | * |
||
446 | * @var array |
||
447 | */ |
||
448 | public $discriminatorColumn; |
||
449 | |||
450 | /** |
||
451 | * READ-ONLY: The primary table definition. The definition is an array with the |
||
452 | * following entries: |
||
453 | * |
||
454 | * name => <tableName> |
||
455 | * schema => <schemaName> |
||
456 | * indexes => array |
||
457 | * uniqueConstraints => array |
||
458 | * |
||
459 | * @var array |
||
460 | */ |
||
461 | public $table; |
||
462 | |||
463 | /** |
||
464 | * READ-ONLY: The registered lifecycle callbacks for entities of this class. |
||
465 | * |
||
466 | * @var array |
||
467 | */ |
||
468 | public $lifecycleCallbacks = array(); |
||
469 | |||
470 | /** |
||
471 | * READ-ONLY: The registered entity listeners. |
||
472 | * |
||
473 | * @var array |
||
474 | */ |
||
475 | public $entityListeners = array(); |
||
476 | |||
477 | /** |
||
478 | * READ-ONLY: The association mappings of this class. |
||
479 | * |
||
480 | * The mapping definition array supports the following keys: |
||
481 | * |
||
482 | * - <b>fieldName</b> (string) |
||
483 | * The name of the field in the entity the association is mapped to. |
||
484 | * |
||
485 | * - <b>targetEntity</b> (string) |
||
486 | * The class name of the target entity. If it is fully-qualified it is used as is. |
||
487 | * If it is a simple, unqualified class name the namespace is assumed to be the same |
||
488 | * as the namespace of the source entity. |
||
489 | * |
||
490 | * - <b>mappedBy</b> (string, required for bidirectional associations) |
||
491 | * The name of the field that completes the bidirectional association on the owning side. |
||
492 | * This key must be specified on the inverse side of a bidirectional association. |
||
493 | * |
||
494 | * - <b>inversedBy</b> (string, required for bidirectional associations) |
||
495 | * The name of the field that completes the bidirectional association on the inverse side. |
||
496 | * This key must be specified on the owning side of a bidirectional association. |
||
497 | * |
||
498 | * - <b>cascade</b> (array, optional) |
||
499 | * The names of persistence operations to cascade on the association. The set of possible |
||
500 | * values are: "persist", "remove", "detach", "merge", "refresh", "all" (implies all others). |
||
501 | * |
||
502 | * - <b>orderBy</b> (array, one-to-many/many-to-many only) |
||
503 | * A map of field names (of the target entity) to sorting directions (ASC/DESC). |
||
504 | * Example: array('priority' => 'desc') |
||
505 | * |
||
506 | * - <b>fetch</b> (integer, optional) |
||
507 | * The fetching strategy to use for the association, usually defaults to FETCH_LAZY. |
||
508 | * Possible values are: ClassMetadata::FETCH_EAGER, ClassMetadata::FETCH_LAZY. |
||
509 | * |
||
510 | * - <b>joinTable</b> (array, optional, many-to-many only) |
||
511 | * Specification of the join table and its join columns (foreign keys). |
||
512 | * Only valid for many-to-many mappings. Note that one-to-many associations can be mapped |
||
513 | * through a join table by simply mapping the association as many-to-many with a unique |
||
514 | * constraint on the join table. |
||
515 | * |
||
516 | * - <b>indexBy</b> (string, optional, to-many only) |
||
517 | * Specification of a field on target-entity that is used to index the collection by. |
||
518 | * This field HAS to be either the primary key or a unique column. Otherwise the collection |
||
519 | * does not contain all the entities that are actually related. |
||
520 | * |
||
521 | * A join table definition has the following structure: |
||
522 | * <pre> |
||
523 | * array( |
||
524 | * 'name' => <join table name>, |
||
525 | * 'joinColumns' => array(<join column mapping from join table to source table>), |
||
526 | * 'inverseJoinColumns' => array(<join column mapping from join table to target table>) |
||
527 | * ) |
||
528 | * </pre> |
||
529 | * |
||
530 | * @var array |
||
531 | */ |
||
532 | public $associationMappings = array(); |
||
533 | |||
534 | /** |
||
535 | * READ-ONLY: Flag indicating whether the identifier/primary key of the class is composite. |
||
536 | * |
||
537 | * @var boolean |
||
538 | */ |
||
539 | public $isIdentifierComposite = false; |
||
540 | |||
541 | /** |
||
542 | * READ-ONLY: Flag indicating whether the identifier/primary key contains at least one foreign key association. |
||
543 | * |
||
544 | * This flag is necessary because some code blocks require special treatment of this cases. |
||
545 | * |
||
546 | * @var boolean |
||
547 | */ |
||
548 | public $containsForeignIdentifier = false; |
||
549 | |||
550 | /** |
||
551 | * READ-ONLY: The ID generator used for generating IDs for this class. |
||
552 | * |
||
553 | * @var \Doctrine\ORM\Id\AbstractIdGenerator |
||
554 | * |
||
555 | * @todo Remove! |
||
556 | */ |
||
557 | public $idGenerator; |
||
558 | |||
559 | /** |
||
560 | * READ-ONLY: The definition of the sequence generator of this class. Only used for the |
||
561 | * SEQUENCE generation strategy. |
||
562 | * |
||
563 | * The definition has the following structure: |
||
564 | * <code> |
||
565 | * array( |
||
566 | * 'sequenceName' => 'name', |
||
567 | * 'allocationSize' => 20, |
||
568 | * 'initialValue' => 1 |
||
569 | * ) |
||
570 | * </code> |
||
571 | * |
||
572 | * @var array |
||
573 | * |
||
574 | * @todo Merge with tableGeneratorDefinition into generic generatorDefinition |
||
575 | */ |
||
576 | public $sequenceGeneratorDefinition; |
||
577 | |||
578 | /** |
||
579 | * READ-ONLY: The definition of the table generator of this class. Only used for the |
||
580 | * TABLE generation strategy. |
||
581 | * |
||
582 | * @var array |
||
583 | * |
||
584 | * @todo Merge with tableGeneratorDefinition into generic generatorDefinition |
||
585 | */ |
||
586 | public $tableGeneratorDefinition; |
||
587 | |||
588 | /** |
||
589 | * READ-ONLY: The policy used for change-tracking on entities of this class. |
||
590 | * |
||
591 | * @var integer |
||
592 | */ |
||
593 | public $changeTrackingPolicy = self::CHANGETRACKING_DEFERRED_IMPLICIT; |
||
594 | |||
595 | /** |
||
596 | * READ-ONLY: A flag for whether or not instances of this class are to be versioned |
||
597 | * with optimistic locking. |
||
598 | * |
||
599 | * @var boolean |
||
600 | */ |
||
601 | public $isVersioned; |
||
602 | |||
603 | /** |
||
604 | * READ-ONLY: The name of the field which is used for versioning in optimistic locking (if any). |
||
605 | * |
||
606 | * @var mixed |
||
607 | */ |
||
608 | public $versionField; |
||
609 | |||
610 | /** |
||
611 | * @var array |
||
612 | */ |
||
613 | public $cache = null; |
||
614 | |||
615 | /** |
||
616 | * The ReflectionClass instance of the mapped class. |
||
617 | * |
||
618 | * @var ReflectionClass |
||
619 | */ |
||
620 | public $reflClass; |
||
621 | |||
622 | /** |
||
623 | * Is this entity marked as "read-only"? |
||
624 | * |
||
625 | * That means it is never considered for change-tracking in the UnitOfWork. It is a very helpful performance |
||
626 | * optimization for entities that are immutable, either in your domain or through the relation database |
||
627 | * (coming from a view, or a history table for example). |
||
628 | * |
||
629 | * @var bool |
||
630 | */ |
||
631 | public $isReadOnly = false; |
||
632 | |||
633 | /** |
||
634 | * NamingStrategy determining the default column and table names. |
||
635 | * |
||
636 | * @var \Doctrine\ORM\Mapping\NamingStrategy |
||
637 | */ |
||
638 | protected $namingStrategy; |
||
639 | |||
640 | /** |
||
641 | * The ReflectionProperty instances of the mapped class. |
||
642 | * |
||
643 | * @var \ReflectionProperty[] |
||
644 | */ |
||
645 | public $reflFields = array(); |
||
646 | |||
647 | /** |
||
648 | * @var \Doctrine\Instantiator\InstantiatorInterface|null |
||
649 | */ |
||
650 | private $instantiator; |
||
651 | |||
652 | /** |
||
653 | * Initializes a new ClassMetadata instance that will hold the object-relational mapping |
||
654 | * metadata of the class with the given name. |
||
655 | * |
||
656 | * @param string $entityName The name of the entity class the new instance is used for. |
||
657 | * @param NamingStrategy|null $namingStrategy |
||
658 | */ |
||
659 | 645 | public function __construct($entityName, NamingStrategy $namingStrategy = null) |
|
660 | { |
||
661 | 645 | $this->name = $entityName; |
|
662 | 645 | $this->rootEntityName = $entityName; |
|
663 | 645 | $this->namingStrategy = $namingStrategy ?: new DefaultNamingStrategy(); |
|
664 | 645 | $this->instantiator = new Instantiator(); |
|
665 | 645 | } |
|
666 | |||
667 | /** |
||
668 | * Gets the ReflectionProperties of the mapped class. |
||
669 | * |
||
670 | * @return array An array of ReflectionProperty instances. |
||
671 | */ |
||
672 | 223 | public function getReflectionProperties() |
|
676 | |||
677 | /** |
||
678 | * Gets a ReflectionProperty for a specific field of the mapped class. |
||
679 | * |
||
680 | * @param string $name |
||
681 | * |
||
682 | * @return \ReflectionProperty |
||
683 | */ |
||
684 | 1 | public function getReflectionProperty($name) |
|
688 | |||
689 | /** |
||
690 | * Gets the ReflectionProperty for the single identifier field. |
||
691 | * |
||
692 | * @return \ReflectionProperty |
||
693 | * |
||
694 | * @throws BadMethodCallException If the class has a composite identifier. |
||
695 | */ |
||
696 | public function getSingleIdReflectionProperty() |
||
697 | { |
||
698 | if ($this->isIdentifierComposite) { |
||
699 | throw new BadMethodCallException("Class " . $this->name . " has a composite identifier."); |
||
700 | } |
||
701 | |||
702 | return $this->reflFields[$this->identifier[0]]; |
||
703 | } |
||
704 | |||
705 | /** |
||
706 | * Extracts the identifier values of an entity of this class. |
||
707 | * |
||
708 | * For composite identifiers, the identifier values are returned as an array |
||
709 | * with the same order as the field order in {@link identifier}. |
||
710 | * |
||
711 | * @param object $entity |
||
712 | * |
||
713 | * @return array |
||
714 | */ |
||
715 | 463 | public function getIdentifierValues($entity) |
|
716 | { |
||
717 | 463 | if ($this->isIdentifierComposite) { |
|
718 | 90 | $id = array(); |
|
719 | |||
720 | 90 | foreach ($this->identifier as $idField) { |
|
721 | 90 | $value = $this->reflFields[$idField]->getValue($entity); |
|
722 | |||
723 | 90 | if ($value !== null) { |
|
724 | 90 | $id[$idField] = $value; |
|
725 | } |
||
726 | } |
||
727 | |||
728 | 90 | return $id; |
|
729 | } |
||
730 | |||
731 | 444 | $id = $this->identifier[0]; |
|
732 | 444 | $value = $this->reflFields[$id]->getValue($entity); |
|
733 | |||
734 | 444 | if (null === $value) { |
|
735 | 28 | return array(); |
|
736 | } |
||
737 | |||
738 | 421 | return array($id => $value); |
|
739 | } |
||
740 | |||
741 | /** |
||
742 | * Populates the entity identifier of an entity. |
||
743 | * |
||
744 | * @param object $entity |
||
745 | * @param array $id |
||
746 | * |
||
747 | * @return void |
||
748 | * |
||
749 | * @todo Rename to assignIdentifier() |
||
750 | */ |
||
751 | 6 | public function setIdentifierValues($entity, array $id) |
|
752 | { |
||
753 | 6 | foreach ($id as $idField => $idValue) { |
|
754 | 6 | $this->reflFields[$idField]->setValue($entity, $idValue); |
|
755 | } |
||
756 | 6 | } |
|
757 | |||
758 | /** |
||
759 | * Sets the specified field to the specified value on the given entity. |
||
760 | * |
||
761 | * @param object $entity |
||
762 | * @param string $field |
||
763 | * @param mixed $value |
||
764 | * |
||
765 | * @return void |
||
766 | */ |
||
767 | 231 | public function setFieldValue($entity, $field, $value) |
|
771 | |||
772 | /** |
||
773 | * Gets the specified field's value off the given entity. |
||
774 | * |
||
775 | * @param object $entity |
||
776 | * @param string $field |
||
777 | * |
||
778 | * @return mixed |
||
779 | */ |
||
780 | 302 | public function getFieldValue($entity, $field) |
|
781 | { |
||
782 | 302 | if (!$entity instanceof $this->reflFields[$field]->class) { |
|
783 | 1 | return null; |
|
784 | } |
||
785 | |||
786 | 302 | return $this->reflFields[$field]->getValue($entity); |
|
787 | } |
||
788 | |||
789 | /** |
||
790 | * Creates a string representation of this instance. |
||
791 | * |
||
792 | * @return string The string representation of this instance. |
||
793 | * |
||
794 | * @todo Construct meaningful string representation. |
||
795 | */ |
||
796 | public function __toString() |
||
797 | { |
||
798 | return __CLASS__ . '@' . spl_object_hash($this); |
||
799 | } |
||
800 | |||
801 | /** |
||
802 | * Determines which fields get serialized. |
||
803 | * |
||
804 | * It is only serialized what is necessary for best unserialization performance. |
||
805 | * That means any metadata properties that are not set or empty or simply have |
||
806 | * their default value are NOT serialized. |
||
807 | * |
||
808 | * Parts that are also NOT serialized because they can not be properly unserialized: |
||
809 | * - reflClass (ReflectionClass) |
||
810 | * - reflFields (ReflectionProperty array) |
||
811 | * |
||
812 | * @return array The names of all the fields that should be serialized. |
||
813 | */ |
||
814 | 6 | public function __sleep() |
|
815 | { |
||
816 | // This metadata is always serialized/cached. |
||
817 | $serialized = array( |
||
818 | 6 | 'associationMappings', |
|
819 | 'columnNames', //TODO: 3.0 Remove this. Can use fieldMappings[$fieldName]['columnName'] |
||
820 | 'fieldMappings', |
||
821 | 'fieldNames', |
||
822 | 'embeddedClasses', |
||
823 | 'identifier', |
||
824 | 'isIdentifierComposite', // TODO: REMOVE |
||
825 | 'name', |
||
826 | 'namespace', // TODO: REMOVE |
||
827 | 'table', |
||
828 | 'rootEntityName', |
||
829 | 'idGenerator', //TODO: Does not really need to be serialized. Could be moved to runtime. |
||
830 | ); |
||
831 | |||
832 | // The rest of the metadata is only serialized if necessary. |
||
833 | 6 | if ($this->changeTrackingPolicy != self::CHANGETRACKING_DEFERRED_IMPLICIT) { |
|
834 | $serialized[] = 'changeTrackingPolicy'; |
||
835 | } |
||
836 | |||
837 | 6 | if ($this->customRepositoryClassName) { |
|
838 | 1 | $serialized[] = 'customRepositoryClassName'; |
|
839 | } |
||
840 | |||
841 | 6 | if ($this->inheritanceType != self::INHERITANCE_TYPE_NONE) { |
|
842 | 1 | $serialized[] = 'inheritanceType'; |
|
843 | 1 | $serialized[] = 'discriminatorColumn'; |
|
844 | 1 | $serialized[] = 'discriminatorValue'; |
|
845 | 1 | $serialized[] = 'discriminatorMap'; |
|
846 | 1 | $serialized[] = 'parentClasses'; |
|
847 | 1 | $serialized[] = 'subClasses'; |
|
848 | } |
||
849 | |||
850 | 6 | if ($this->generatorType != self::GENERATOR_TYPE_NONE) { |
|
851 | 1 | $serialized[] = 'generatorType'; |
|
852 | 1 | if ($this->generatorType == self::GENERATOR_TYPE_SEQUENCE) { |
|
853 | $serialized[] = 'sequenceGeneratorDefinition'; |
||
854 | } |
||
855 | } |
||
856 | |||
857 | 6 | if ($this->isMappedSuperclass) { |
|
858 | $serialized[] = 'isMappedSuperclass'; |
||
859 | } |
||
860 | |||
861 | 6 | if ($this->isEmbeddedClass) { |
|
862 | 1 | $serialized[] = 'isEmbeddedClass'; |
|
863 | } |
||
864 | |||
865 | 6 | if ($this->containsForeignIdentifier) { |
|
866 | $serialized[] = 'containsForeignIdentifier'; |
||
867 | } |
||
868 | |||
869 | 6 | if ($this->isVersioned) { |
|
870 | $serialized[] = 'isVersioned'; |
||
871 | $serialized[] = 'versionField'; |
||
872 | } |
||
873 | |||
874 | 6 | if ($this->lifecycleCallbacks) { |
|
875 | $serialized[] = 'lifecycleCallbacks'; |
||
876 | } |
||
877 | |||
878 | 6 | if ($this->entityListeners) { |
|
879 | 1 | $serialized[] = 'entityListeners'; |
|
880 | } |
||
881 | |||
882 | 6 | if ($this->namedQueries) { |
|
883 | 1 | $serialized[] = 'namedQueries'; |
|
884 | } |
||
885 | |||
886 | 6 | if ($this->namedNativeQueries) { |
|
887 | $serialized[] = 'namedNativeQueries'; |
||
888 | } |
||
889 | |||
890 | 6 | if ($this->sqlResultSetMappings) { |
|
891 | $serialized[] = 'sqlResultSetMappings'; |
||
892 | } |
||
893 | |||
894 | 6 | if ($this->isReadOnly) { |
|
895 | 1 | $serialized[] = 'isReadOnly'; |
|
896 | } |
||
897 | |||
898 | 6 | if ($this->customGeneratorDefinition) { |
|
899 | $serialized[] = "customGeneratorDefinition"; |
||
900 | } |
||
901 | |||
902 | 6 | if ($this->cache) { |
|
903 | $serialized[] = 'cache'; |
||
904 | } |
||
905 | |||
906 | 6 | return $serialized; |
|
907 | } |
||
908 | |||
909 | /** |
||
910 | * Creates a new instance of the mapped class, without invoking the constructor. |
||
911 | * |
||
912 | * @return object |
||
913 | */ |
||
914 | 670 | public function newInstance() |
|
915 | { |
||
916 | 670 | return $this->instantiator->instantiate($this->name); |
|
917 | } |
||
918 | |||
919 | /** |
||
920 | * Restores some state that can not be serialized/unserialized. |
||
921 | * |
||
922 | * @param \Doctrine\Common\Persistence\Mapping\ReflectionService $reflService |
||
923 | * |
||
924 | * @return void |
||
925 | */ |
||
926 | 2003 | public function wakeupReflection($reflService) |
|
927 | { |
||
928 | // Restore ReflectionClass and properties |
||
929 | 2003 | $this->reflClass = $reflService->getClass($this->name); |
|
930 | 2003 | $this->instantiator = $this->instantiator ?: new Instantiator(); |
|
931 | |||
932 | 2003 | $parentReflFields = array(); |
|
933 | |||
934 | 2003 | foreach ($this->embeddedClasses as $property => $embeddedClass) { |
|
935 | 20 | if (isset($embeddedClass['declaredField'])) { |
|
936 | 15 | $parentReflFields[$property] = new ReflectionEmbeddedProperty( |
|
937 | 15 | $parentReflFields[$embeddedClass['declaredField']], |
|
938 | 15 | $reflService->getAccessibleProperty( |
|
939 | 15 | $this->embeddedClasses[$embeddedClass['declaredField']]['class'], |
|
940 | 15 | $embeddedClass['originalField'] |
|
941 | ), |
||
942 | 15 | $this->embeddedClasses[$embeddedClass['declaredField']]['class'] |
|
943 | ); |
||
944 | |||
945 | 15 | continue; |
|
946 | } |
||
947 | |||
948 | 20 | $parentReflFields[$property] = $reflService->getAccessibleProperty($this->name, $property); |
|
949 | 20 | $this->reflFields[$property] = $reflService->getAccessibleProperty($this->name, $property); |
|
950 | } |
||
951 | |||
952 | 2003 | foreach ($this->fieldMappings as $field => $mapping) { |
|
953 | 1998 | if (isset($mapping['declaredField']) && isset($parentReflFields[$mapping['declaredField']])) { |
|
954 | 19 | $this->reflFields[$field] = new ReflectionEmbeddedProperty( |
|
955 | 19 | $parentReflFields[$mapping['declaredField']], |
|
956 | 19 | $reflService->getAccessibleProperty($mapping['originalClass'], $mapping['originalField']), |
|
957 | 19 | $mapping['originalClass'] |
|
958 | ); |
||
959 | 19 | continue; |
|
960 | } |
||
961 | |||
962 | 1998 | $this->reflFields[$field] = isset($mapping['declared']) |
|
963 | 493 | ? $reflService->getAccessibleProperty($mapping['declared'], $field) |
|
964 | 1998 | : $reflService->getAccessibleProperty($this->name, $field); |
|
965 | } |
||
966 | |||
967 | 2003 | foreach ($this->associationMappings as $field => $mapping) { |
|
968 | 1691 | $this->reflFields[$field] = isset($mapping['declared']) |
|
969 | 401 | ? $reflService->getAccessibleProperty($mapping['declared'], $field) |
|
970 | 1691 | : $reflService->getAccessibleProperty($this->name, $field); |
|
971 | } |
||
972 | 2003 | } |
|
973 | |||
974 | /** |
||
975 | * Initializes a new ClassMetadata instance that will hold the object-relational mapping |
||
976 | * metadata of the class with the given name. |
||
977 | * |
||
978 | * @param \Doctrine\Common\Persistence\Mapping\ReflectionService $reflService The reflection service. |
||
979 | * |
||
980 | * @return void |
||
981 | */ |
||
982 | 609 | public function initializeReflection($reflService) |
|
983 | { |
||
984 | 609 | $this->reflClass = $reflService->getClass($this->name); |
|
985 | 609 | $this->namespace = $reflService->getClassNamespace($this->name); |
|
986 | |||
987 | 609 | if ($this->reflClass) { |
|
988 | 602 | $this->name = $this->rootEntityName = $this->reflClass->getName(); |
|
989 | } |
||
990 | |||
991 | 609 | $this->table['name'] = $this->namingStrategy->classToTableName($this->name); |
|
992 | 609 | } |
|
993 | |||
994 | /** |
||
995 | * Validates Identifier. |
||
996 | * |
||
997 | * @return void |
||
998 | * |
||
999 | * @throws MappingException |
||
1000 | */ |
||
1001 | 398 | public function validateIdentifier() |
|
1002 | { |
||
1003 | 398 | if ($this->isMappedSuperclass || $this->isEmbeddedClass) { |
|
1004 | 59 | return; |
|
1005 | } |
||
1006 | |||
1007 | // Verify & complete identifier mapping |
||
1008 | 396 | if ( ! $this->identifier) { |
|
1009 | 6 | throw MappingException::identifierRequired($this->name); |
|
1010 | } |
||
1011 | |||
1012 | 390 | if ($this->usesIdGenerator() && $this->isIdentifierComposite) { |
|
1013 | throw MappingException::compositeKeyAssignedIdGeneratorRequired($this->name); |
||
1014 | } |
||
1015 | 390 | } |
|
1016 | |||
1017 | /** |
||
1018 | * Validates association targets actually exist. |
||
1019 | * |
||
1020 | * @return void |
||
1021 | * |
||
1022 | * @throws MappingException |
||
1023 | */ |
||
1024 | 399 | public function validateAssociations() |
|
1025 | { |
||
1026 | 399 | foreach ($this->associationMappings as $mapping) { |
|
1027 | 266 | if ( ! ClassLoader::classExists($mapping['targetEntity']) ) { |
|
1028 | 266 | throw MappingException::invalidTargetEntityClass($mapping['targetEntity'], $this->name, $mapping['fieldName']); |
|
1029 | } |
||
1030 | } |
||
1031 | 398 | } |
|
1032 | |||
1033 | /** |
||
1034 | * Validates lifecycle callbacks. |
||
1035 | * |
||
1036 | * @param \Doctrine\Common\Persistence\Mapping\ReflectionService $reflService |
||
1037 | * |
||
1038 | * @return void |
||
1039 | * |
||
1040 | * @throws MappingException |
||
1041 | */ |
||
1042 | 399 | public function validateLifecycleCallbacks($reflService) |
|
1043 | { |
||
1044 | 399 | foreach ($this->lifecycleCallbacks as $callbacks) { |
|
1045 | 13 | foreach ($callbacks as $callbackFuncName) { |
|
1046 | 13 | if ( ! $reflService->hasPublicMethod($this->name, $callbackFuncName)) { |
|
1047 | 13 | throw MappingException::lifecycleCallbackMethodNotFound($this->name, $callbackFuncName); |
|
1048 | } |
||
1049 | } |
||
1050 | } |
||
1051 | 398 | } |
|
1052 | |||
1053 | /** |
||
1054 | * {@inheritDoc} |
||
1055 | */ |
||
1056 | 526 | public function getReflectionClass() |
|
1057 | { |
||
1058 | 526 | return $this->reflClass; |
|
1059 | } |
||
1060 | |||
1061 | /** |
||
1062 | * @param array $cache |
||
1063 | * |
||
1064 | * @return void |
||
1065 | */ |
||
1066 | 20 | public function enableCache(array $cache) |
|
1078 | |||
1079 | /** |
||
1080 | * @param string $fieldName |
||
1081 | * @param array $cache |
||
1082 | * |
||
1083 | * @return void |
||
1084 | */ |
||
1085 | 2 | public function enableAssociationCache($fieldName, array $cache) |
|
1089 | |||
1090 | /** |
||
1091 | * @param string $fieldName |
||
1092 | * @param array $cache |
||
1093 | * |
||
1094 | * @return array |
||
1095 | */ |
||
1096 | 16 | public function getAssociationCacheDefaults($fieldName, array $cache) |
|
1110 | |||
1111 | /** |
||
1112 | * Sets the change tracking policy used by this class. |
||
1113 | * |
||
1114 | * @param integer $policy |
||
1115 | * |
||
1116 | * @return void |
||
1117 | */ |
||
1118 | 138 | public function setChangeTrackingPolicy($policy) |
|
1122 | |||
1123 | /** |
||
1124 | * Whether the change tracking policy of this class is "deferred explicit". |
||
1125 | * |
||
1126 | * @return boolean |
||
1127 | */ |
||
1128 | 267 | public function isChangeTrackingDeferredExplicit() |
|
1132 | |||
1133 | /** |
||
1134 | * Whether the change tracking policy of this class is "deferred implicit". |
||
1135 | * |
||
1136 | * @return boolean |
||
1137 | */ |
||
1138 | 457 | public function isChangeTrackingDeferredImplicit() |
|
1142 | |||
1143 | /** |
||
1144 | * Whether the change tracking policy of this class is "notify". |
||
1145 | * |
||
1146 | * @return boolean |
||
1147 | */ |
||
1148 | 289 | public function isChangeTrackingNotify() |
|
1152 | |||
1153 | /** |
||
1154 | * Checks whether a field is part of the identifier/primary key field(s). |
||
1155 | * |
||
1156 | * @param string $fieldName The field name. |
||
1157 | * |
||
1158 | * @return boolean TRUE if the field is part of the table identifier/primary key field(s), |
||
1159 | * FALSE otherwise. |
||
1160 | */ |
||
1161 | 1068 | public function isIdentifier($fieldName) |
|
1173 | |||
1174 | /** |
||
1175 | * Checks if the field is unique. |
||
1176 | * |
||
1177 | * @param string $fieldName The field name. |
||
1178 | * |
||
1179 | * @return boolean TRUE if the field is unique, FALSE otherwise. |
||
1180 | */ |
||
1181 | public function isUniqueField($fieldName) |
||
1191 | |||
1192 | /** |
||
1193 | * Checks if the field is not null. |
||
1194 | * |
||
1195 | * @param string $fieldName The field name. |
||
1196 | * |
||
1197 | * @return boolean TRUE if the field is not null, FALSE otherwise. |
||
1198 | */ |
||
1199 | 1 | public function isNullable($fieldName) |
|
1209 | |||
1210 | /** |
||
1211 | * Gets a column name for a field name. |
||
1212 | * If the column name for the field cannot be found, the given field name |
||
1213 | * is returned. |
||
1214 | * |
||
1215 | * @param string $fieldName The field name. |
||
1216 | * |
||
1217 | * @return string The column name. |
||
1218 | */ |
||
1219 | 16 | public function getColumnName($fieldName) |
|
1225 | |||
1226 | /** |
||
1227 | * Gets the mapping of a (regular) field that holds some data but not a |
||
1228 | * reference to another object. |
||
1229 | * |
||
1230 | * @param string $fieldName The field name. |
||
1231 | * |
||
1232 | * @return array The field mapping. |
||
1233 | * |
||
1234 | * @throws MappingException |
||
1235 | */ |
||
1236 | 199 | public function getFieldMapping($fieldName) |
|
1244 | |||
1245 | /** |
||
1246 | * Gets the mapping of an association. |
||
1247 | * |
||
1248 | * @see ClassMetadataInfo::$associationMappings |
||
1249 | * |
||
1250 | * @param string $fieldName The field name that represents the association in |
||
1251 | * the object model. |
||
1252 | * |
||
1253 | * @return array The mapping. |
||
1254 | * |
||
1255 | * @throws MappingException |
||
1256 | */ |
||
1257 | 484 | public function getAssociationMapping($fieldName) |
|
1265 | |||
1266 | /** |
||
1267 | * Gets all association mappings of the class. |
||
1268 | * |
||
1269 | * @return array |
||
1270 | */ |
||
1271 | public function getAssociationMappings() |
||
1275 | |||
1276 | /** |
||
1277 | * Gets the field name for a column name. |
||
1278 | * If no field name can be found the column name is returned. |
||
1279 | * |
||
1280 | * @param string $columnName The column name. |
||
1281 | * |
||
1282 | * @return string The column alias. |
||
1283 | */ |
||
1284 | 236 | public function getFieldName($columnName) |
|
1290 | |||
1291 | /** |
||
1292 | * Gets the named query. |
||
1293 | * |
||
1294 | * @see ClassMetadataInfo::$namedQueries |
||
1295 | * |
||
1296 | * @param string $queryName The query name. |
||
1297 | * |
||
1298 | * @return string |
||
1299 | * |
||
1300 | * @throws MappingException |
||
1301 | */ |
||
1302 | 4 | public function getNamedQuery($queryName) |
|
1310 | |||
1311 | /** |
||
1312 | * Gets all named queries of the class. |
||
1313 | * |
||
1314 | * @return array |
||
1315 | */ |
||
1316 | 7 | public function getNamedQueries() |
|
1320 | |||
1321 | /** |
||
1322 | * Gets the named native query. |
||
1323 | * |
||
1324 | * @see ClassMetadataInfo::$namedNativeQueries |
||
1325 | * |
||
1326 | * @param string $queryName The query name. |
||
1327 | * |
||
1328 | * @return array |
||
1329 | * |
||
1330 | * @throws MappingException |
||
1331 | */ |
||
1332 | 17 | public function getNamedNativeQuery($queryName) |
|
1340 | |||
1341 | /** |
||
1342 | * Gets all named native queries of the class. |
||
1343 | * |
||
1344 | * @return array |
||
1345 | */ |
||
1346 | 2 | public function getNamedNativeQueries() |
|
1350 | |||
1351 | /** |
||
1352 | * Gets the result set mapping. |
||
1353 | * |
||
1354 | * @see ClassMetadataInfo::$sqlResultSetMappings |
||
1355 | * |
||
1356 | * @param string $name The result set mapping name. |
||
1357 | * |
||
1358 | * @return array |
||
1359 | * |
||
1360 | * @throws MappingException |
||
1361 | */ |
||
1362 | 21 | public function getSqlResultSetMapping($name) |
|
1370 | |||
1371 | /** |
||
1372 | * Gets all sql result set mappings of the class. |
||
1373 | * |
||
1374 | * @return array |
||
1375 | */ |
||
1376 | 8 | public function getSqlResultSetMappings() |
|
1380 | |||
1381 | /** |
||
1382 | * Validates & completes the given field mapping. |
||
1383 | * |
||
1384 | * @param array $mapping The field mapping to validate & complete. |
||
1385 | * |
||
1386 | * @return array The validated and completed field mapping. |
||
1387 | * |
||
1388 | * @throws MappingException |
||
1389 | */ |
||
1390 | 526 | protected function _validateAndCompleteFieldMapping(array &$mapping) |
|
1444 | |||
1445 | /** |
||
1446 | * Validates & completes the basic mapping information that is common to all |
||
1447 | * association mappings (one-to-one, many-ot-one, one-to-many, many-to-many). |
||
1448 | * |
||
1449 | * @param array $mapping The mapping. |
||
1450 | * |
||
1451 | * @return array The updated mapping. |
||
1452 | * |
||
1453 | * @throws MappingException If something is wrong with the mapping. |
||
1454 | */ |
||
1455 | 349 | protected function _validateAndCompleteAssociationMapping(array $mapping) |
|
1567 | |||
1568 | /** |
||
1569 | * Validates & completes a one-to-one association mapping. |
||
1570 | * |
||
1571 | * @param array $mapping The mapping to validate & complete. |
||
1572 | * |
||
1573 | * @return array The validated & completed mapping. |
||
1574 | * |
||
1575 | * @throws RuntimeException |
||
1576 | * @throws MappingException |
||
1577 | */ |
||
1578 | 296 | protected function _validateAndCompleteOneToOneMapping(array $mapping) |
|
1660 | |||
1661 | /** |
||
1662 | * Validates & completes a one-to-many association mapping. |
||
1663 | * |
||
1664 | * @param array $mapping The mapping to validate and complete. |
||
1665 | * |
||
1666 | * @return array The validated and completed mapping. |
||
1667 | * |
||
1668 | * @throws MappingException |
||
1669 | * @throws InvalidArgumentException |
||
1670 | */ |
||
1671 | 128 | protected function _validateAndCompleteOneToManyMapping(array $mapping) |
|
1691 | |||
1692 | /** |
||
1693 | * Validates & completes a many-to-many association mapping. |
||
1694 | * |
||
1695 | * @param array $mapping The mapping to validate & complete. |
||
1696 | * |
||
1697 | * @return array The validated & completed mapping. |
||
1698 | * |
||
1699 | * @throws \InvalidArgumentException |
||
1700 | */ |
||
1701 | 149 | protected function _validateAndCompleteManyToManyMapping(array $mapping) |
|
1801 | |||
1802 | /** |
||
1803 | * {@inheritDoc} |
||
1804 | */ |
||
1805 | 593 | public function getIdentifierFieldNames() |
|
1809 | |||
1810 | /** |
||
1811 | * Gets the name of the single id field. Note that this only works on |
||
1812 | * entity classes that have a single-field pk. |
||
1813 | * |
||
1814 | * @return string |
||
1815 | * |
||
1816 | * @throws MappingException If the class has a composite primary key. |
||
1817 | */ |
||
1818 | 396 | public function getSingleIdentifierFieldName() |
|
1826 | |||
1827 | /** |
||
1828 | * Gets the column name of the single id column. Note that this only works on |
||
1829 | * entity classes that have a single-field pk. |
||
1830 | * |
||
1831 | * @return string |
||
1832 | * |
||
1833 | * @throws MappingException If the class has a composite primary key. |
||
1834 | */ |
||
1835 | 3 | public function getSingleIdentifierColumnName() |
|
1839 | |||
1840 | /** |
||
1841 | * INTERNAL: |
||
1842 | * Sets the mapped identifier/primary key fields of this class. |
||
1843 | * Mainly used by the ClassMetadataFactory to assign inherited identifiers. |
||
1844 | * |
||
1845 | * @param array $identifier |
||
1846 | * |
||
1847 | * @return void |
||
1848 | */ |
||
1849 | 123 | public function setIdentifier(array $identifier) |
|
1854 | |||
1855 | /** |
||
1856 | * {@inheritDoc} |
||
1857 | */ |
||
1858 | 61 | public function getIdentifier() |
|
1862 | |||
1863 | /** |
||
1864 | * {@inheritDoc} |
||
1865 | */ |
||
1866 | 292 | public function hasField($fieldName) |
|
1870 | |||
1871 | /** |
||
1872 | * Gets an array containing all the column names. |
||
1873 | * |
||
1874 | * @param array|null $fieldNames |
||
1875 | * |
||
1876 | * @return array |
||
1877 | */ |
||
1878 | 42 | public function getColumnNames(array $fieldNames = null) |
|
1886 | |||
1887 | /** |
||
1888 | * Returns an array with all the identifier column names. |
||
1889 | * |
||
1890 | * @return array |
||
1891 | */ |
||
1892 | 322 | public function getIdentifierColumnNames() |
|
1912 | |||
1913 | /** |
||
1914 | * Sets the type of Id generator to use for the mapped class. |
||
1915 | * |
||
1916 | * @param int $generatorType |
||
1917 | * |
||
1918 | * @return void |
||
1919 | */ |
||
1920 | 455 | public function setIdGeneratorType($generatorType) |
|
1924 | |||
1925 | /** |
||
1926 | * Checks whether the mapped class uses an Id generator. |
||
1927 | * |
||
1928 | * @return boolean TRUE if the mapped class uses an Id generator, FALSE otherwise. |
||
1929 | */ |
||
1930 | 390 | public function usesIdGenerator() |
|
1934 | |||
1935 | /** |
||
1936 | * @return boolean |
||
1937 | */ |
||
1938 | 1321 | public function isInheritanceTypeNone() |
|
1942 | |||
1943 | /** |
||
1944 | * Checks whether the mapped class uses the JOINED inheritance mapping strategy. |
||
1945 | * |
||
1946 | * @return boolean TRUE if the class participates in a JOINED inheritance mapping, |
||
1947 | * FALSE otherwise. |
||
1948 | */ |
||
1949 | 1049 | public function isInheritanceTypeJoined() |
|
1953 | |||
1954 | /** |
||
1955 | * Checks whether the mapped class uses the SINGLE_TABLE inheritance mapping strategy. |
||
1956 | * |
||
1957 | * @return boolean TRUE if the class participates in a SINGLE_TABLE inheritance mapping, |
||
1958 | * FALSE otherwise. |
||
1959 | */ |
||
1960 | 1221 | public function isInheritanceTypeSingleTable() |
|
1964 | |||
1965 | /** |
||
1966 | * Checks whether the mapped class uses the TABLE_PER_CLASS inheritance mapping strategy. |
||
1967 | * |
||
1968 | * @return boolean TRUE if the class participates in a TABLE_PER_CLASS inheritance mapping, |
||
1969 | * FALSE otherwise. |
||
1970 | */ |
||
1971 | 259 | public function isInheritanceTypeTablePerClass() |
|
1975 | |||
1976 | /** |
||
1977 | * Checks whether the class uses an identity column for the Id generation. |
||
1978 | * |
||
1979 | * @return boolean TRUE if the class uses the IDENTITY generator, FALSE otherwise. |
||
1980 | */ |
||
1981 | 1061 | public function isIdGeneratorIdentity() |
|
1985 | |||
1986 | /** |
||
1987 | * Checks whether the class uses a sequence for id generation. |
||
1988 | * |
||
1989 | * @return boolean TRUE if the class uses the SEQUENCE generator, FALSE otherwise. |
||
1990 | */ |
||
1991 | 312 | public function isIdGeneratorSequence() |
|
1995 | |||
1996 | /** |
||
1997 | * Checks whether the class uses a table for id generation. |
||
1998 | * |
||
1999 | * @return boolean TRUE if the class uses the TABLE generator, FALSE otherwise. |
||
2000 | */ |
||
2001 | 80 | public function isIdGeneratorTable() |
|
2005 | |||
2006 | /** |
||
2007 | * Checks whether the class has a natural identifier/pk (which means it does |
||
2008 | * not use any Id generator. |
||
2009 | * |
||
2010 | * @return boolean |
||
2011 | */ |
||
2012 | 73 | public function isIdentifierNatural() |
|
2016 | |||
2017 | /** |
||
2018 | * Checks whether the class use a UUID for id generation. |
||
2019 | * |
||
2020 | * @return boolean |
||
2021 | */ |
||
2022 | public function isIdentifierUuid() |
||
2026 | |||
2027 | /** |
||
2028 | * Gets the type of a field. |
||
2029 | * |
||
2030 | * @param string $fieldName |
||
2031 | * |
||
2032 | * @return \Doctrine\DBAL\Types\Type|string|null |
||
2033 | * |
||
2034 | * @todo 3.0 Remove this. PersisterHelper should fix it somehow |
||
2035 | */ |
||
2036 | 38 | public function getTypeOfField($fieldName) |
|
2042 | |||
2043 | /** |
||
2044 | * Gets the type of a column. |
||
2045 | * |
||
2046 | * @param string $columnName |
||
2047 | * |
||
2048 | * @return \Doctrine\DBAL\Types\Type|string|null |
||
2049 | * |
||
2050 | * @deprecated 3.0 remove this. this method is bogous and unreliable, since it cannot resolve the type of a column |
||
2051 | * that is derived by a referenced field on a different entity. |
||
2052 | */ |
||
2053 | public function getTypeOfColumn($columnName) |
||
2057 | |||
2058 | /** |
||
2059 | * Gets the name of the primary table. |
||
2060 | * |
||
2061 | * @return string |
||
2062 | */ |
||
2063 | 1463 | public function getTableName() |
|
2067 | |||
2068 | /** |
||
2069 | * Gets primary table's schema name. |
||
2070 | * |
||
2071 | * @return string|null |
||
2072 | */ |
||
2073 | 13 | public function getSchemaName() |
|
2077 | |||
2078 | /** |
||
2079 | * Gets the table name to use for temporary identifier tables of this class. |
||
2080 | * |
||
2081 | * @return string |
||
2082 | */ |
||
2083 | 7 | public function getTemporaryIdTableName() |
|
2088 | |||
2089 | /** |
||
2090 | * Sets the mapped subclasses of this class. |
||
2091 | * |
||
2092 | * @param array $subclasses The names of all mapped subclasses. |
||
2093 | * |
||
2094 | * @return void |
||
2095 | */ |
||
2096 | 2 | public function setSubclasses(array $subclasses) |
|
2102 | |||
2103 | /** |
||
2104 | * Sets the parent class names. |
||
2105 | * Assumes that the class names in the passed array are in the order: |
||
2106 | * directParent -> directParentParent -> directParentParentParent ... -> root. |
||
2107 | * |
||
2108 | * @param array $classNames |
||
2109 | * |
||
2110 | * @return void |
||
2111 | */ |
||
2112 | 407 | public function setParentClasses(array $classNames) |
|
2120 | |||
2121 | /** |
||
2122 | * Sets the inheritance type used by the class and its subclasses. |
||
2123 | * |
||
2124 | * @param integer $type |
||
2125 | * |
||
2126 | * @return void |
||
2127 | * |
||
2128 | * @throws MappingException |
||
2129 | */ |
||
2130 | 169 | public function setInheritanceType($type) |
|
2138 | |||
2139 | /** |
||
2140 | * Sets the association to override association mapping of property for an entity relationship. |
||
2141 | * |
||
2142 | * @param string $fieldName |
||
2143 | * @param array $overrideMapping |
||
2144 | * |
||
2145 | * @return void |
||
2146 | * |
||
2147 | * @throws MappingException |
||
2148 | */ |
||
2149 | 20 | public function setAssociationOverride($fieldName, array $overrideMapping) |
|
2192 | |||
2193 | /** |
||
2194 | * Sets the override for a mapped field. |
||
2195 | * |
||
2196 | * @param string $fieldName |
||
2197 | * @param array $overrideMapping |
||
2198 | * |
||
2199 | * @return void |
||
2200 | * |
||
2201 | * @throws MappingException |
||
2202 | */ |
||
2203 | 15 | public function setAttributeOverride($fieldName, array $overrideMapping) |
|
2235 | |||
2236 | /** |
||
2237 | * Checks whether a mapped field is inherited from an entity superclass. |
||
2238 | * |
||
2239 | * @param string $fieldName |
||
2240 | * |
||
2241 | * @return bool TRUE if the field is inherited, FALSE otherwise. |
||
2242 | */ |
||
2243 | 367 | public function isInheritedField($fieldName) |
|
2247 | |||
2248 | /** |
||
2249 | * Checks if this entity is the root in any entity-inheritance-hierarchy. |
||
2250 | * |
||
2251 | * @return bool |
||
2252 | */ |
||
2253 | 406 | public function isRootEntity() |
|
2257 | |||
2258 | /** |
||
2259 | * Checks whether a mapped association field is inherited from a superclass. |
||
2260 | * |
||
2261 | * @param string $fieldName |
||
2262 | * |
||
2263 | * @return boolean TRUE if the field is inherited, FALSE otherwise. |
||
2264 | */ |
||
2265 | 346 | public function isInheritedAssociation($fieldName) |
|
2269 | |||
2270 | 346 | public function isInheritedEmbeddedClass($fieldName) |
|
2274 | |||
2275 | /** |
||
2276 | * Sets the name of the primary table the class is mapped to. |
||
2277 | * |
||
2278 | * @param string $tableName The table name. |
||
2279 | * |
||
2280 | * @return void |
||
2281 | * |
||
2282 | * @deprecated Use {@link setPrimaryTable}. |
||
2283 | */ |
||
2284 | public function setTableName($tableName) |
||
2288 | |||
2289 | /** |
||
2290 | * Sets the primary table definition. The provided array supports the |
||
2291 | * following structure: |
||
2292 | * |
||
2293 | * name => <tableName> (optional, defaults to class name) |
||
2294 | * indexes => array of indexes (optional) |
||
2295 | * uniqueConstraints => array of constraints (optional) |
||
2296 | * |
||
2297 | * If a key is omitted, the current value is kept. |
||
2298 | * |
||
2299 | * @param array $table The table description. |
||
2300 | * |
||
2301 | * @return void |
||
2302 | */ |
||
2303 | 322 | public function setPrimaryTable(array $table) |
|
2335 | |||
2336 | /** |
||
2337 | * Checks whether the given type identifies an inheritance type. |
||
2338 | * |
||
2339 | * @param integer $type |
||
2340 | * |
||
2341 | * @return boolean TRUE if the given type identifies an inheritance type, FALSe otherwise. |
||
2342 | */ |
||
2343 | 169 | private function _isInheritanceType($type) |
|
2350 | |||
2351 | /** |
||
2352 | * Adds a mapped field to the class. |
||
2353 | * |
||
2354 | * @param array $mapping The field mapping. |
||
2355 | * |
||
2356 | * @return void |
||
2357 | * |
||
2358 | * @throws MappingException |
||
2359 | */ |
||
2360 | 526 | public function mapField(array $mapping) |
|
2367 | |||
2368 | /** |
||
2369 | * INTERNAL: |
||
2370 | * Adds an association mapping without completing/validating it. |
||
2371 | * This is mainly used to add inherited association mappings to derived classes. |
||
2372 | * |
||
2373 | * @param array $mapping |
||
2374 | * |
||
2375 | * @return void |
||
2376 | * |
||
2377 | * @throws MappingException |
||
2378 | */ |
||
2379 | 48 | public function addInheritedAssociationMapping(array $mapping/*, $owningClassName = null*/) |
|
2386 | |||
2387 | /** |
||
2388 | * INTERNAL: |
||
2389 | * Adds a field mapping without completing/validating it. |
||
2390 | * This is mainly used to add inherited field mappings to derived classes. |
||
2391 | * |
||
2392 | * @param array $fieldMapping |
||
2393 | * |
||
2394 | * @return void |
||
2395 | */ |
||
2396 | 107 | public function addInheritedFieldMapping(array $fieldMapping) |
|
2402 | |||
2403 | /** |
||
2404 | * INTERNAL: |
||
2405 | * Adds a named query to this class. |
||
2406 | * |
||
2407 | * @param array $queryMapping |
||
2408 | * |
||
2409 | * @return void |
||
2410 | * |
||
2411 | * @throws MappingException |
||
2412 | */ |
||
2413 | 29 | public function addNamedQuery(array $queryMapping) |
|
2437 | |||
2438 | /** |
||
2439 | * INTERNAL: |
||
2440 | * Adds a named native query to this class. |
||
2441 | * |
||
2442 | * @param array $queryMapping |
||
2443 | * |
||
2444 | * @return void |
||
2445 | * |
||
2446 | * @throws MappingException |
||
2447 | */ |
||
2448 | 39 | public function addNamedNativeQuery(array $queryMapping) |
|
2481 | |||
2482 | /** |
||
2483 | * INTERNAL: |
||
2484 | * Adds a sql result set mapping to this class. |
||
2485 | * |
||
2486 | * @param array $resultMapping |
||
2487 | * |
||
2488 | * @return void |
||
2489 | * |
||
2490 | * @throws MappingException |
||
2491 | */ |
||
2492 | 39 | public function addSqlResultSetMapping(array $resultMapping) |
|
2542 | |||
2543 | /** |
||
2544 | * Adds a one-to-one mapping. |
||
2545 | * |
||
2546 | * @param array $mapping The mapping. |
||
2547 | * |
||
2548 | * @return void |
||
2549 | */ |
||
2550 | 167 | public function mapOneToOne(array $mapping) |
|
2558 | |||
2559 | /** |
||
2560 | * Adds a one-to-many mapping. |
||
2561 | * |
||
2562 | * @param array $mapping The mapping. |
||
2563 | * |
||
2564 | * @return void |
||
2565 | */ |
||
2566 | 128 | public function mapOneToMany(array $mapping) |
|
2574 | |||
2575 | /** |
||
2576 | * Adds a many-to-one mapping. |
||
2577 | * |
||
2578 | * @param array $mapping The mapping. |
||
2579 | * |
||
2580 | * @return void |
||
2581 | */ |
||
2582 | 161 | public function mapManyToOne(array $mapping) |
|
2591 | |||
2592 | /** |
||
2593 | * Adds a many-to-many mapping. |
||
2594 | * |
||
2595 | * @param array $mapping The mapping. |
||
2596 | * |
||
2597 | * @return void |
||
2598 | */ |
||
2599 | 149 | public function mapManyToMany(array $mapping) |
|
2607 | |||
2608 | /** |
||
2609 | * Stores the association mapping. |
||
2610 | * |
||
2611 | * @param array $assocMapping |
||
2612 | * |
||
2613 | * @return void |
||
2614 | * |
||
2615 | * @throws MappingException |
||
2616 | */ |
||
2617 | 338 | protected function _storeAssociationMapping(array $assocMapping) |
|
2625 | |||
2626 | /** |
||
2627 | * Registers a custom repository class for the entity class. |
||
2628 | * |
||
2629 | * @param string $repositoryClassName The class name of the custom mapper. |
||
2630 | * |
||
2631 | * @return void |
||
2632 | */ |
||
2633 | 62 | public function setCustomRepositoryClass($repositoryClassName) |
|
2637 | |||
2638 | /** |
||
2639 | * Dispatches the lifecycle event of the given entity to the registered |
||
2640 | * lifecycle callbacks and lifecycle listeners. |
||
2641 | * |
||
2642 | * @deprecated Deprecated since version 2.4 in favor of \Doctrine\ORM\Event\ListenersInvoker |
||
2643 | * |
||
2644 | * @param string $lifecycleEvent The lifecycle event. |
||
2645 | * @param object $entity The Entity on which the event occurred. |
||
2646 | * |
||
2647 | * @return void |
||
2648 | */ |
||
2649 | public function invokeLifecycleCallbacks($lifecycleEvent, $entity) |
||
2655 | |||
2656 | /** |
||
2657 | * Whether the class has any attached lifecycle listeners or callbacks for a lifecycle event. |
||
2658 | * |
||
2659 | * @param string $lifecycleEvent |
||
2660 | * |
||
2661 | * @return boolean |
||
2662 | */ |
||
2663 | public function hasLifecycleCallbacks($lifecycleEvent) |
||
2667 | |||
2668 | /** |
||
2669 | * Gets the registered lifecycle callbacks for an event. |
||
2670 | * |
||
2671 | * @param string $event |
||
2672 | * |
||
2673 | * @return array |
||
2674 | */ |
||
2675 | public function getLifecycleCallbacks($event) |
||
2679 | |||
2680 | /** |
||
2681 | * Adds a lifecycle callback for entities of this class. |
||
2682 | * |
||
2683 | * @param string $callback |
||
2684 | * @param string $event |
||
2685 | * |
||
2686 | * @return void |
||
2687 | */ |
||
2688 | 41 | public function addLifecycleCallback($callback, $event) |
|
2696 | |||
2697 | /** |
||
2698 | * Sets the lifecycle callbacks for entities of this class. |
||
2699 | * Any previously registered callbacks are overwritten. |
||
2700 | * |
||
2701 | * @param array $callbacks |
||
2702 | * |
||
2703 | * @return void |
||
2704 | */ |
||
2705 | 122 | public function setLifecycleCallbacks(array $callbacks) |
|
2709 | |||
2710 | /** |
||
2711 | * Adds a entity listener for entities of this class. |
||
2712 | * |
||
2713 | * @param string $eventName The entity lifecycle event. |
||
2714 | * @param string $class The listener class. |
||
2715 | * @param string $method The listener callback method. |
||
2716 | * |
||
2717 | * @throws \Doctrine\ORM\Mapping\MappingException |
||
2718 | */ |
||
2719 | 35 | public function addEntityListener($eventName, $class, $method) |
|
2742 | |||
2743 | /** |
||
2744 | * Sets the discriminator column definition. |
||
2745 | * |
||
2746 | * @param array $columnDef |
||
2747 | * |
||
2748 | * @return void |
||
2749 | * |
||
2750 | * @throws MappingException |
||
2751 | * |
||
2752 | * @see getDiscriminatorColumn() |
||
2753 | */ |
||
2754 | 163 | public function setDiscriminatorColumn($columnDef) |
|
2780 | |||
2781 | /** |
||
2782 | * Sets the discriminator values used by this class. |
||
2783 | * Used for JOINED and SINGLE_TABLE inheritance mapping strategies. |
||
2784 | * |
||
2785 | * @param array $map |
||
2786 | * |
||
2787 | * @return void |
||
2788 | */ |
||
2789 | 156 | public function setDiscriminatorMap(array $map) |
|
2795 | |||
2796 | /** |
||
2797 | * Adds one entry of the discriminator map with a new class and corresponding name. |
||
2798 | * |
||
2799 | * @param string $name |
||
2800 | * @param string $className |
||
2801 | * |
||
2802 | * @return void |
||
2803 | * |
||
2804 | * @throws MappingException |
||
2805 | */ |
||
2806 | 104 | public function addDiscriminatorMapClass($name, $className) |
|
2827 | |||
2828 | /** |
||
2829 | * Checks whether the class has a named query with the given query name. |
||
2830 | * |
||
2831 | * @param string $queryName |
||
2832 | * |
||
2833 | * @return boolean |
||
2834 | */ |
||
2835 | 1 | public function hasNamedQuery($queryName) |
|
2839 | |||
2840 | /** |
||
2841 | * Checks whether the class has a named native query with the given query name. |
||
2842 | * |
||
2843 | * @param string $queryName |
||
2844 | * |
||
2845 | * @return boolean |
||
2846 | */ |
||
2847 | 1 | public function hasNamedNativeQuery($queryName) |
|
2851 | |||
2852 | /** |
||
2853 | * Checks whether the class has a named native query with the given query name. |
||
2854 | * |
||
2855 | * @param string $name |
||
2856 | * |
||
2857 | * @return boolean |
||
2858 | */ |
||
2859 | 1 | public function hasSqlResultSetMapping($name) |
|
2863 | |||
2864 | /** |
||
2865 | * {@inheritDoc} |
||
2866 | */ |
||
2867 | 341 | public function hasAssociation($fieldName) |
|
2871 | |||
2872 | /** |
||
2873 | * {@inheritDoc} |
||
2874 | */ |
||
2875 | 1 | public function isSingleValuedAssociation($fieldName) |
|
2880 | |||
2881 | /** |
||
2882 | * {@inheritDoc} |
||
2883 | */ |
||
2884 | 1024 | public function isCollectionValuedAssociation($fieldName) |
|
2889 | |||
2890 | /** |
||
2891 | * Is this an association that only has a single join column? |
||
2892 | * |
||
2893 | * @param string $fieldName |
||
2894 | * |
||
2895 | * @return bool |
||
2896 | */ |
||
2897 | 35 | public function isAssociationWithSingleJoinColumn($fieldName) |
|
2903 | |||
2904 | /** |
||
2905 | * Returns the single association join column (if any). |
||
2906 | * |
||
2907 | * @param string $fieldName |
||
2908 | * |
||
2909 | * @return string |
||
2910 | * |
||
2911 | * @throws MappingException |
||
2912 | */ |
||
2913 | 9 | public function getSingleAssociationJoinColumnName($fieldName) |
|
2921 | |||
2922 | /** |
||
2923 | * Returns the single association referenced join column name (if any). |
||
2924 | * |
||
2925 | * @param string $fieldName |
||
2926 | * |
||
2927 | * @return string |
||
2928 | * |
||
2929 | * @throws MappingException |
||
2930 | */ |
||
2931 | 9 | public function getSingleAssociationReferencedJoinColumnName($fieldName) |
|
2939 | |||
2940 | /** |
||
2941 | * Used to retrieve a fieldname for either field or association from a given column. |
||
2942 | * |
||
2943 | * This method is used in foreign-key as primary-key contexts. |
||
2944 | * |
||
2945 | * @param string $columnName |
||
2946 | * |
||
2947 | * @return string |
||
2948 | * |
||
2949 | * @throws MappingException |
||
2950 | */ |
||
2951 | 633 | public function getFieldForColumn($columnName) |
|
2967 | |||
2968 | /** |
||
2969 | * Sets the ID generator used to generate IDs for instances of this class. |
||
2970 | * |
||
2971 | * @param \Doctrine\ORM\Id\AbstractIdGenerator $generator |
||
2972 | * |
||
2973 | * @return void |
||
2974 | */ |
||
2975 | 409 | public function setIdGenerator($generator) |
|
2979 | |||
2980 | /** |
||
2981 | * Sets definition. |
||
2982 | * |
||
2983 | * @param array $definition |
||
2984 | * |
||
2985 | * @return void |
||
2986 | */ |
||
2987 | 12 | public function setCustomGeneratorDefinition(array $definition) |
|
2991 | |||
2992 | /** |
||
2993 | * Sets the definition of the sequence ID generator for this class. |
||
2994 | * |
||
2995 | * The definition must have the following structure: |
||
2996 | * <code> |
||
2997 | * array( |
||
2998 | * 'sequenceName' => 'name', |
||
2999 | * 'allocationSize' => 20, |
||
3000 | * 'initialValue' => 1 |
||
3001 | * 'quoted' => 1 |
||
3002 | * ) |
||
3003 | * </code> |
||
3004 | * |
||
3005 | * @param array $definition |
||
3006 | * |
||
3007 | * @return void |
||
3008 | * |
||
3009 | * @throws MappingException |
||
3010 | */ |
||
3011 | 23 | public function setSequenceGeneratorDefinition(array $definition) |
|
3024 | |||
3025 | /** |
||
3026 | * Sets the version field mapping used for versioning. Sets the default |
||
3027 | * value to use depending on the column type. |
||
3028 | * |
||
3029 | * @param array $mapping The version field mapping array. |
||
3030 | * |
||
3031 | * @return void |
||
3032 | * |
||
3033 | * @throws MappingException |
||
3034 | */ |
||
3035 | 25 | public function setVersionMapping(array &$mapping) |
|
3050 | |||
3051 | /** |
||
3052 | * Sets whether this class is to be versioned for optimistic locking. |
||
3053 | * |
||
3054 | * @param boolean $bool |
||
3055 | * |
||
3056 | * @return void |
||
3057 | */ |
||
3058 | 122 | public function setVersioned($bool) |
|
3062 | |||
3063 | /** |
||
3064 | * Sets the name of the field that is to be used for versioning if this class is |
||
3065 | * versioned for optimistic locking. |
||
3066 | * |
||
3067 | * @param string $versionField |
||
3068 | * |
||
3069 | * @return void |
||
3070 | */ |
||
3071 | 122 | public function setVersionField($versionField) |
|
3075 | |||
3076 | /** |
||
3077 | * Marks this class as read only, no change tracking is applied to it. |
||
3078 | * |
||
3079 | * @return void |
||
3080 | */ |
||
3081 | 3 | public function markReadOnly() |
|
3085 | |||
3086 | /** |
||
3087 | * {@inheritDoc} |
||
3088 | */ |
||
3089 | public function getFieldNames() |
||
3093 | |||
3094 | /** |
||
3095 | * {@inheritDoc} |
||
3096 | */ |
||
3097 | public function getAssociationNames() |
||
3101 | |||
3102 | /** |
||
3103 | * {@inheritDoc} |
||
3104 | * |
||
3105 | * @throws InvalidArgumentException |
||
3106 | */ |
||
3107 | 1 | public function getAssociationTargetClass($assocName) |
|
3115 | |||
3116 | /** |
||
3117 | * {@inheritDoc} |
||
3118 | */ |
||
3119 | 703 | public function getName() |
|
3123 | |||
3124 | /** |
||
3125 | * Gets the (possibly quoted) identifier column names for safe use in an SQL statement. |
||
3126 | * |
||
3127 | * @deprecated Deprecated since version 2.3 in favor of \Doctrine\ORM\Mapping\QuoteStrategy |
||
3128 | * |
||
3129 | * @param \Doctrine\DBAL\Platforms\AbstractPlatform $platform |
||
3130 | * |
||
3131 | * @return array |
||
3132 | */ |
||
3133 | public function getQuotedIdentifierColumnNames($platform) |
||
3162 | |||
3163 | /** |
||
3164 | * Gets the (possibly quoted) column name of a mapped field for safe use in an SQL statement. |
||
3165 | * |
||
3166 | * @deprecated Deprecated since version 2.3 in favor of \Doctrine\ORM\Mapping\QuoteStrategy |
||
3167 | * |
||
3168 | * @param string $field |
||
3169 | * @param \Doctrine\DBAL\Platforms\AbstractPlatform $platform |
||
3170 | * |
||
3171 | * @return string |
||
3172 | */ |
||
3173 | public function getQuotedColumnName($field, $platform) |
||
3179 | |||
3180 | /** |
||
3181 | * Gets the (possibly quoted) primary table name of this class for safe use in an SQL statement. |
||
3182 | * |
||
3183 | * @deprecated Deprecated since version 2.3 in favor of \Doctrine\ORM\Mapping\QuoteStrategy |
||
3184 | * |
||
3185 | * @param \Doctrine\DBAL\Platforms\AbstractPlatform $platform |
||
3186 | * |
||
3187 | * @return string |
||
3188 | */ |
||
3189 | public function getQuotedTableName($platform) |
||
3195 | |||
3196 | /** |
||
3197 | * Gets the (possibly quoted) name of the join table. |
||
3198 | * |
||
3199 | * @deprecated Deprecated since version 2.3 in favor of \Doctrine\ORM\Mapping\QuoteStrategy |
||
3200 | * |
||
3201 | * @param array $assoc |
||
3202 | * @param \Doctrine\DBAL\Platforms\AbstractPlatform $platform |
||
3203 | * |
||
3204 | * @return string |
||
3205 | */ |
||
3206 | public function getQuotedJoinTableName(array $assoc, $platform) |
||
3212 | |||
3213 | /** |
||
3214 | * {@inheritDoc} |
||
3215 | */ |
||
3216 | 12 | public function isAssociationInverseSide($fieldName) |
|
3221 | |||
3222 | /** |
||
3223 | * {@inheritDoc} |
||
3224 | */ |
||
3225 | public function getAssociationMappedByTargetField($fieldName) |
||
3229 | |||
3230 | /** |
||
3231 | * @param string $targetClass |
||
3232 | * |
||
3233 | * @return array |
||
3234 | */ |
||
3235 | 2 | public function getAssociationsByTargetClass($targetClass) |
|
3247 | |||
3248 | /** |
||
3249 | * @param string|null $className |
||
3250 | * |
||
3251 | * @return string|null null if the input value is null |
||
3252 | */ |
||
3253 | 475 | public function fullyQualifiedClassName($className) |
|
3265 | |||
3266 | /** |
||
3267 | * @param string $name |
||
3268 | * |
||
3269 | * @return mixed |
||
3270 | */ |
||
3271 | 2 | public function getMetadataValue($name) |
|
3280 | |||
3281 | /** |
||
3282 | * Map Embedded Class |
||
3283 | * |
||
3284 | * @param array $mapping |
||
3285 | * |
||
3286 | * @throws MappingException |
||
3287 | * @return void |
||
3288 | */ |
||
3289 | 26 | public function mapEmbedded(array $mapping) |
|
3300 | |||
3301 | /** |
||
3302 | * Inline the embeddable class |
||
3303 | * |
||
3304 | * @param string $property |
||
3305 | * @param ClassMetadataInfo $embeddable |
||
3306 | */ |
||
3307 | 10 | public function inlineEmbeddable($property, ClassMetadataInfo $embeddable) |
|
3336 | |||
3337 | /** |
||
3338 | * @param string $fieldName |
||
3339 | * @throws MappingException |
||
3340 | */ |
||
3341 | 561 | private function assertFieldNotMapped($fieldName) |
|
3350 | |||
3351 | /** |
||
3352 | * Gets the sequence name based on class metadata. |
||
3353 | * |
||
3354 | * @param AbstractPlatform $platform |
||
3355 | * @return string |
||
3356 | * |
||
3357 | * @todo Sequence names should be computed in DBAL depending on the platform |
||
3358 | */ |
||
3359 | 3 | public function getSequenceName(AbstractPlatform $platform) |
|
3367 | |||
3368 | /** |
||
3369 | * Gets the sequence name prefix based on class metadata. |
||
3370 | * |
||
3371 | * @param AbstractPlatform $platform |
||
3372 | * @return string |
||
3373 | * |
||
3374 | * @todo Sequence names should be computed in DBAL depending on the platform |
||
3375 | */ |
||
3376 | 3 | public function getSequencePrefix(AbstractPlatform $platform) |
|
3392 | } |
||
3393 |
Let’s assume that you have a directory layout like this:
and let’s assume the following content of
Bar.php
:If both files
OtherDir/Foo.php
andSomeDir/Foo.php
are loaded in the same runtime, you will see a PHP error such as the following:PHP Fatal error: Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.php
However, as
OtherDir/Foo.php
does not necessarily have to be loaded and the error is only triggered if it is loaded beforeOtherDir/Bar.php
, this problem might go unnoticed for a while. In order to prevent this error from surfacing, you must import the namespace with a different alias: