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 | * The name of the custom persister class used for the entity class. |
||
261 | * (Optional). |
||
262 | * |
||
263 | * @var string |
||
264 | */ |
||
265 | public $customPersisterClassName; |
||
266 | |||
267 | /** |
||
268 | * READ-ONLY: Whether this class describes the mapping of a mapped superclass. |
||
269 | * |
||
270 | * @var boolean |
||
271 | */ |
||
272 | public $isMappedSuperclass = false; |
||
273 | |||
274 | /** |
||
275 | * READ-ONLY: Whether this class describes the mapping of an embeddable class. |
||
276 | * |
||
277 | * @var boolean |
||
278 | */ |
||
279 | public $isEmbeddedClass = false; |
||
280 | |||
281 | /** |
||
282 | * READ-ONLY: The names of the parent classes (ancestors). |
||
283 | * |
||
284 | * @var array |
||
285 | */ |
||
286 | public $parentClasses = array(); |
||
287 | |||
288 | /** |
||
289 | * READ-ONLY: The names of all subclasses (descendants). |
||
290 | * |
||
291 | * @var array |
||
292 | */ |
||
293 | public $subClasses = array(); |
||
294 | |||
295 | /** |
||
296 | * READ-ONLY: The names of all embedded classes based on properties. |
||
297 | * |
||
298 | * @var array |
||
299 | */ |
||
300 | public $embeddedClasses = array(); |
||
301 | |||
302 | /** |
||
303 | * READ-ONLY: The named queries allowed to be called directly from Repository. |
||
304 | * |
||
305 | * @var array |
||
306 | */ |
||
307 | public $namedQueries = array(); |
||
308 | |||
309 | /** |
||
310 | * READ-ONLY: The named native queries allowed to be called directly from Repository. |
||
311 | * |
||
312 | * A native SQL named query definition has the following structure: |
||
313 | * <pre> |
||
314 | * array( |
||
315 | * 'name' => <query name>, |
||
316 | * 'query' => <sql query>, |
||
317 | * 'resultClass' => <class of the result>, |
||
318 | * 'resultSetMapping' => <name of a SqlResultSetMapping> |
||
319 | * ) |
||
320 | * </pre> |
||
321 | * |
||
322 | * @var array |
||
323 | */ |
||
324 | public $namedNativeQueries = array(); |
||
325 | |||
326 | /** |
||
327 | * READ-ONLY: The mappings of the results of native SQL queries. |
||
328 | * |
||
329 | * A native result mapping definition has the following structure: |
||
330 | * <pre> |
||
331 | * array( |
||
332 | * 'name' => <result name>, |
||
333 | * 'entities' => array(<entity result mapping>), |
||
334 | * 'columns' => array(<column result mapping>) |
||
335 | * ) |
||
336 | * </pre> |
||
337 | * |
||
338 | * @var array |
||
339 | */ |
||
340 | public $sqlResultSetMappings = array(); |
||
341 | |||
342 | /** |
||
343 | * READ-ONLY: The field names of all fields that are part of the identifier/primary key |
||
344 | * of the mapped entity class. |
||
345 | * |
||
346 | * @var array |
||
347 | */ |
||
348 | public $identifier = array(); |
||
349 | |||
350 | /** |
||
351 | * READ-ONLY: The inheritance mapping type used by the class. |
||
352 | * |
||
353 | * @var integer |
||
354 | */ |
||
355 | public $inheritanceType = self::INHERITANCE_TYPE_NONE; |
||
356 | |||
357 | /** |
||
358 | * READ-ONLY: The Id generator type used by the class. |
||
359 | * |
||
360 | * @var int |
||
361 | */ |
||
362 | public $generatorType = self::GENERATOR_TYPE_NONE; |
||
363 | |||
364 | /** |
||
365 | * READ-ONLY: The field mappings of the class. |
||
366 | * Keys are field names and values are mapping definitions. |
||
367 | * |
||
368 | * The mapping definition array has the following values: |
||
369 | * |
||
370 | * - <b>fieldName</b> (string) |
||
371 | * The name of the field in the Entity. |
||
372 | * |
||
373 | * - <b>type</b> (string) |
||
374 | * The type name of the mapped field. Can be one of Doctrine's mapping types |
||
375 | * or a custom mapping type. |
||
376 | * |
||
377 | * - <b>columnName</b> (string, optional) |
||
378 | * The column name. Optional. Defaults to the field name. |
||
379 | * |
||
380 | * - <b>length</b> (integer, optional) |
||
381 | * The database length of the column. Optional. Default value taken from |
||
382 | * the type. |
||
383 | * |
||
384 | * - <b>id</b> (boolean, optional) |
||
385 | * Marks the field as the primary key of the entity. Multiple fields of an |
||
386 | * entity can have the id attribute, forming a composite key. |
||
387 | * |
||
388 | * - <b>nullable</b> (boolean, optional) |
||
389 | * Whether the column is nullable. Defaults to FALSE. |
||
390 | * |
||
391 | * - <b>columnDefinition</b> (string, optional, schema-only) |
||
392 | * The SQL fragment that is used when generating the DDL for the column. |
||
393 | * |
||
394 | * - <b>precision</b> (integer, optional, schema-only) |
||
395 | * The precision of a decimal column. Only valid if the column type is decimal. |
||
396 | * |
||
397 | * - <b>scale</b> (integer, optional, schema-only) |
||
398 | * The scale of a decimal column. Only valid if the column type is decimal. |
||
399 | * |
||
400 | * - <b>'unique'</b> (string, optional, schema-only) |
||
401 | * Whether a unique constraint should be generated for the column. |
||
402 | * |
||
403 | * @var array |
||
404 | */ |
||
405 | public $fieldMappings = array(); |
||
406 | |||
407 | /** |
||
408 | * READ-ONLY: An array of field names. Used to look up field names from column names. |
||
409 | * Keys are column names and values are field names. |
||
410 | * |
||
411 | * @var array |
||
412 | */ |
||
413 | public $fieldNames = array(); |
||
414 | |||
415 | /** |
||
416 | * READ-ONLY: A map of field names to column names. Keys are field names and values column names. |
||
417 | * Used to look up column names from field names. |
||
418 | * This is the reverse lookup map of $_fieldNames. |
||
419 | * |
||
420 | * @var array |
||
421 | * |
||
422 | * @deprecated 3.0 Remove this. |
||
423 | */ |
||
424 | public $columnNames = array(); |
||
425 | |||
426 | /** |
||
427 | * READ-ONLY: The discriminator value of this class. |
||
428 | * |
||
429 | * <b>This does only apply to the JOINED and SINGLE_TABLE inheritance mapping strategies |
||
430 | * where a discriminator column is used.</b> |
||
431 | * |
||
432 | * @var mixed |
||
433 | * |
||
434 | * @see discriminatorColumn |
||
435 | */ |
||
436 | public $discriminatorValue; |
||
437 | |||
438 | /** |
||
439 | * READ-ONLY: The discriminator map of all mapped classes in the hierarchy. |
||
440 | * |
||
441 | * <b>This does only apply to the JOINED and SINGLE_TABLE inheritance mapping strategies |
||
442 | * where a discriminator column is used.</b> |
||
443 | * |
||
444 | * @var mixed |
||
445 | * |
||
446 | * @see discriminatorColumn |
||
447 | */ |
||
448 | public $discriminatorMap = array(); |
||
449 | |||
450 | /** |
||
451 | * READ-ONLY: The definition of the discriminator column used in JOINED and SINGLE_TABLE |
||
452 | * inheritance mappings. |
||
453 | * |
||
454 | * @var array |
||
455 | */ |
||
456 | public $discriminatorColumn; |
||
457 | |||
458 | /** |
||
459 | * READ-ONLY: The primary table definition. The definition is an array with the |
||
460 | * following entries: |
||
461 | * |
||
462 | * name => <tableName> |
||
463 | * schema => <schemaName> |
||
464 | * indexes => array |
||
465 | * uniqueConstraints => array |
||
466 | * |
||
467 | * @var array |
||
468 | */ |
||
469 | public $table; |
||
470 | |||
471 | /** |
||
472 | * READ-ONLY: The registered lifecycle callbacks for entities of this class. |
||
473 | * |
||
474 | * @var array |
||
475 | */ |
||
476 | public $lifecycleCallbacks = array(); |
||
477 | |||
478 | /** |
||
479 | * READ-ONLY: The registered entity listeners. |
||
480 | * |
||
481 | * @var array |
||
482 | */ |
||
483 | public $entityListeners = array(); |
||
484 | |||
485 | /** |
||
486 | * READ-ONLY: The association mappings of this class. |
||
487 | * |
||
488 | * The mapping definition array supports the following keys: |
||
489 | * |
||
490 | * - <b>fieldName</b> (string) |
||
491 | * The name of the field in the entity the association is mapped to. |
||
492 | * |
||
493 | * - <b>targetEntity</b> (string) |
||
494 | * The class name of the target entity. If it is fully-qualified it is used as is. |
||
495 | * If it is a simple, unqualified class name the namespace is assumed to be the same |
||
496 | * as the namespace of the source entity. |
||
497 | * |
||
498 | * - <b>mappedBy</b> (string, required for bidirectional associations) |
||
499 | * The name of the field that completes the bidirectional association on the owning side. |
||
500 | * This key must be specified on the inverse side of a bidirectional association. |
||
501 | * |
||
502 | * - <b>inversedBy</b> (string, required for bidirectional associations) |
||
503 | * The name of the field that completes the bidirectional association on the inverse side. |
||
504 | * This key must be specified on the owning side of a bidirectional association. |
||
505 | * |
||
506 | * - <b>cascade</b> (array, optional) |
||
507 | * The names of persistence operations to cascade on the association. The set of possible |
||
508 | * values are: "persist", "remove", "detach", "merge", "refresh", "all" (implies all others). |
||
509 | * |
||
510 | * - <b>orderBy</b> (array, one-to-many/many-to-many only) |
||
511 | * A map of field names (of the target entity) to sorting directions (ASC/DESC). |
||
512 | * Example: array('priority' => 'desc') |
||
513 | * |
||
514 | * - <b>fetch</b> (integer, optional) |
||
515 | * The fetching strategy to use for the association, usually defaults to FETCH_LAZY. |
||
516 | * Possible values are: ClassMetadata::FETCH_EAGER, ClassMetadata::FETCH_LAZY. |
||
517 | * |
||
518 | * - <b>joinTable</b> (array, optional, many-to-many only) |
||
519 | * Specification of the join table and its join columns (foreign keys). |
||
520 | * Only valid for many-to-many mappings. Note that one-to-many associations can be mapped |
||
521 | * through a join table by simply mapping the association as many-to-many with a unique |
||
522 | * constraint on the join table. |
||
523 | * |
||
524 | * - <b>indexBy</b> (string, optional, to-many only) |
||
525 | * Specification of a field on target-entity that is used to index the collection by. |
||
526 | * This field HAS to be either the primary key or a unique column. Otherwise the collection |
||
527 | * does not contain all the entities that are actually related. |
||
528 | * |
||
529 | * A join table definition has the following structure: |
||
530 | * <pre> |
||
531 | * array( |
||
532 | * 'name' => <join table name>, |
||
533 | * 'joinColumns' => array(<join column mapping from join table to source table>), |
||
534 | * 'inverseJoinColumns' => array(<join column mapping from join table to target table>) |
||
535 | * ) |
||
536 | * </pre> |
||
537 | * |
||
538 | * @var array |
||
539 | */ |
||
540 | public $associationMappings = array(); |
||
541 | |||
542 | /** |
||
543 | * READ-ONLY: Flag indicating whether the identifier/primary key of the class is composite. |
||
544 | * |
||
545 | * @var boolean |
||
546 | */ |
||
547 | public $isIdentifierComposite = false; |
||
548 | |||
549 | /** |
||
550 | * READ-ONLY: Flag indicating whether the identifier/primary key contains at least one foreign key association. |
||
551 | * |
||
552 | * This flag is necessary because some code blocks require special treatment of this cases. |
||
553 | * |
||
554 | * @var boolean |
||
555 | */ |
||
556 | public $containsForeignIdentifier = false; |
||
557 | |||
558 | /** |
||
559 | * READ-ONLY: The ID generator used for generating IDs for this class. |
||
560 | * |
||
561 | * @var \Doctrine\ORM\Id\AbstractIdGenerator |
||
562 | * |
||
563 | * @todo Remove! |
||
564 | */ |
||
565 | public $idGenerator; |
||
566 | |||
567 | /** |
||
568 | * READ-ONLY: The definition of the sequence generator of this class. Only used for the |
||
569 | * SEQUENCE generation strategy. |
||
570 | * |
||
571 | * The definition has the following structure: |
||
572 | * <code> |
||
573 | * array( |
||
574 | * 'sequenceName' => 'name', |
||
575 | * 'allocationSize' => 20, |
||
576 | * 'initialValue' => 1 |
||
577 | * ) |
||
578 | * </code> |
||
579 | * |
||
580 | * @var array |
||
581 | * |
||
582 | * @todo Merge with tableGeneratorDefinition into generic generatorDefinition |
||
583 | */ |
||
584 | public $sequenceGeneratorDefinition; |
||
585 | |||
586 | /** |
||
587 | * READ-ONLY: The definition of the table generator of this class. Only used for the |
||
588 | * TABLE generation strategy. |
||
589 | * |
||
590 | * @var array |
||
591 | * |
||
592 | * @todo Merge with tableGeneratorDefinition into generic generatorDefinition |
||
593 | */ |
||
594 | public $tableGeneratorDefinition; |
||
595 | |||
596 | /** |
||
597 | * READ-ONLY: The policy used for change-tracking on entities of this class. |
||
598 | * |
||
599 | * @var integer |
||
600 | */ |
||
601 | public $changeTrackingPolicy = self::CHANGETRACKING_DEFERRED_IMPLICIT; |
||
602 | |||
603 | /** |
||
604 | * READ-ONLY: A flag for whether or not instances of this class are to be versioned |
||
605 | * with optimistic locking. |
||
606 | * |
||
607 | * @var boolean |
||
608 | */ |
||
609 | public $isVersioned; |
||
610 | |||
611 | /** |
||
612 | * READ-ONLY: The name of the field which is used for versioning in optimistic locking (if any). |
||
613 | * |
||
614 | * @var mixed |
||
615 | */ |
||
616 | public $versionField; |
||
617 | |||
618 | /** |
||
619 | * @var array |
||
620 | */ |
||
621 | public $cache = null; |
||
622 | |||
623 | /** |
||
624 | * The ReflectionClass instance of the mapped class. |
||
625 | * |
||
626 | * @var ReflectionClass |
||
627 | */ |
||
628 | public $reflClass; |
||
629 | |||
630 | /** |
||
631 | * Is this entity marked as "read-only"? |
||
632 | * |
||
633 | * That means it is never considered for change-tracking in the UnitOfWork. It is a very helpful performance |
||
634 | * optimization for entities that are immutable, either in your domain or through the relation database |
||
635 | * (coming from a view, or a history table for example). |
||
636 | * |
||
637 | * @var bool |
||
638 | */ |
||
639 | public $isReadOnly = false; |
||
640 | |||
641 | /** |
||
642 | * NamingStrategy determining the default column and table names. |
||
643 | * |
||
644 | * @var \Doctrine\ORM\Mapping\NamingStrategy |
||
645 | */ |
||
646 | protected $namingStrategy; |
||
647 | |||
648 | /** |
||
649 | * The ReflectionProperty instances of the mapped class. |
||
650 | * |
||
651 | * @var \ReflectionProperty[] |
||
652 | */ |
||
653 | public $reflFields = array(); |
||
654 | |||
655 | /** |
||
656 | * @var \Doctrine\Instantiator\InstantiatorInterface|null |
||
657 | */ |
||
658 | private $instantiator; |
||
659 | |||
660 | /** |
||
661 | * Initializes a new ClassMetadata instance that will hold the object-relational mapping |
||
662 | * metadata of the class with the given name. |
||
663 | * |
||
664 | * @param string $entityName The name of the entity class the new instance is used for. |
||
665 | * @param NamingStrategy|null $namingStrategy |
||
666 | */ |
||
667 | 655 | public function __construct($entityName, NamingStrategy $namingStrategy = null) |
|
674 | |||
675 | /** |
||
676 | * Gets the ReflectionProperties of the mapped class. |
||
677 | * |
||
678 | * @return array An array of ReflectionProperty instances. |
||
679 | */ |
||
680 | 221 | public function getReflectionProperties() |
|
684 | |||
685 | /** |
||
686 | * Gets a ReflectionProperty for a specific field of the mapped class. |
||
687 | * |
||
688 | * @param string $name |
||
689 | * |
||
690 | * @return \ReflectionProperty |
||
691 | */ |
||
692 | 1 | public function getReflectionProperty($name) |
|
696 | |||
697 | /** |
||
698 | * Gets the ReflectionProperty for the single identifier field. |
||
699 | * |
||
700 | * @return \ReflectionProperty |
||
701 | * |
||
702 | * @throws BadMethodCallException If the class has a composite identifier. |
||
703 | */ |
||
704 | public function getSingleIdReflectionProperty() |
||
712 | |||
713 | /** |
||
714 | * Extracts the identifier values of an entity of this class. |
||
715 | * |
||
716 | * For composite identifiers, the identifier values are returned as an array |
||
717 | * with the same order as the field order in {@link identifier}. |
||
718 | * |
||
719 | * @param object $entity |
||
720 | * |
||
721 | * @return array |
||
722 | */ |
||
723 | 459 | public function getIdentifierValues($entity) |
|
748 | |||
749 | /** |
||
750 | * Populates the entity identifier of an entity. |
||
751 | * |
||
752 | * @param object $entity |
||
753 | * @param array $id |
||
754 | * |
||
755 | * @return void |
||
756 | * |
||
757 | * @todo Rename to assignIdentifier() |
||
758 | */ |
||
759 | 6 | public function setIdentifierValues($entity, array $id) |
|
765 | |||
766 | /** |
||
767 | * Sets the specified field to the specified value on the given entity. |
||
768 | * |
||
769 | * @param object $entity |
||
770 | * @param string $field |
||
771 | * @param mixed $value |
||
772 | * |
||
773 | * @return void |
||
774 | */ |
||
775 | 231 | public function setFieldValue($entity, $field, $value) |
|
779 | |||
780 | /** |
||
781 | * Gets the specified field's value off the given entity. |
||
782 | * |
||
783 | * @param object $entity |
||
784 | * @param string $field |
||
785 | * |
||
786 | * @return mixed |
||
787 | */ |
||
788 | 300 | public function getFieldValue($entity, $field) |
|
792 | |||
793 | /** |
||
794 | * Creates a string representation of this instance. |
||
795 | * |
||
796 | * @return string The string representation of this instance. |
||
797 | * |
||
798 | * @todo Construct meaningful string representation. |
||
799 | */ |
||
800 | public function __toString() |
||
804 | |||
805 | /** |
||
806 | * Determines which fields get serialized. |
||
807 | * |
||
808 | * It is only serialized what is necessary for best unserialization performance. |
||
809 | * That means any metadata properties that are not set or empty or simply have |
||
810 | * their default value are NOT serialized. |
||
811 | * |
||
812 | * Parts that are also NOT serialized because they can not be properly unserialized: |
||
813 | * - reflClass (ReflectionClass) |
||
814 | * - reflFields (ReflectionProperty array) |
||
815 | * |
||
816 | * @return array The names of all the fields that should be serialized. |
||
817 | */ |
||
818 | 5 | public function __sleep() |
|
916 | |||
917 | /** |
||
918 | * Creates a new instance of the mapped class, without invoking the constructor. |
||
919 | * |
||
920 | * @return object |
||
921 | */ |
||
922 | 658 | public function newInstance() |
|
926 | |||
927 | /** |
||
928 | * Restores some state that can not be serialized/unserialized. |
||
929 | * |
||
930 | * @param \Doctrine\Common\Persistence\Mapping\ReflectionService $reflService |
||
931 | * |
||
932 | * @return void |
||
933 | */ |
||
934 | 1969 | public function wakeupReflection($reflService) |
|
981 | |||
982 | /** |
||
983 | * Initializes a new ClassMetadata instance that will hold the object-relational mapping |
||
984 | * metadata of the class with the given name. |
||
985 | * |
||
986 | * @param \Doctrine\Common\Persistence\Mapping\ReflectionService $reflService The reflection service. |
||
987 | * |
||
988 | * @return void |
||
989 | */ |
||
990 | 619 | public function initializeReflection($reflService) |
|
1001 | |||
1002 | /** |
||
1003 | * Validates Identifier. |
||
1004 | * |
||
1005 | * @return void |
||
1006 | * |
||
1007 | * @throws MappingException |
||
1008 | */ |
||
1009 | 373 | public function validateIdentifier() |
|
1024 | |||
1025 | /** |
||
1026 | * Validates association targets actually exist. |
||
1027 | * |
||
1028 | * @return void |
||
1029 | * |
||
1030 | * @throws MappingException |
||
1031 | */ |
||
1032 | 374 | public function validateAssociations() |
|
1040 | |||
1041 | /** |
||
1042 | * Validates lifecycle callbacks. |
||
1043 | * |
||
1044 | * @param \Doctrine\Common\Persistence\Mapping\ReflectionService $reflService |
||
1045 | * |
||
1046 | * @return void |
||
1047 | * |
||
1048 | * @throws MappingException |
||
1049 | */ |
||
1050 | 374 | public function validateLifecycleCallbacks($reflService) |
|
1060 | |||
1061 | /** |
||
1062 | * {@inheritDoc} |
||
1063 | */ |
||
1064 | 535 | public function getReflectionClass() |
|
1068 | |||
1069 | /** |
||
1070 | * @param array $cache |
||
1071 | * |
||
1072 | * @return void |
||
1073 | */ |
||
1074 | 20 | public function enableCache(array $cache) |
|
1086 | |||
1087 | /** |
||
1088 | * @param string $fieldName |
||
1089 | * @param array $cache |
||
1090 | * |
||
1091 | * @return void |
||
1092 | */ |
||
1093 | 2 | public function enableAssociationCache($fieldName, array $cache) |
|
1097 | |||
1098 | /** |
||
1099 | * @param string $fieldName |
||
1100 | * @param array $cache |
||
1101 | * |
||
1102 | * @return array |
||
1103 | */ |
||
1104 | 16 | public function getAssociationCacheDefaults($fieldName, array $cache) |
|
1118 | |||
1119 | /** |
||
1120 | * Sets the change tracking policy used by this class. |
||
1121 | * |
||
1122 | * @param integer $policy |
||
1123 | * |
||
1124 | * @return void |
||
1125 | */ |
||
1126 | 116 | public function setChangeTrackingPolicy($policy) |
|
1130 | |||
1131 | /** |
||
1132 | * Whether the change tracking policy of this class is "deferred explicit". |
||
1133 | * |
||
1134 | * @return boolean |
||
1135 | */ |
||
1136 | 263 | public function isChangeTrackingDeferredExplicit() |
|
1140 | |||
1141 | /** |
||
1142 | * Whether the change tracking policy of this class is "deferred implicit". |
||
1143 | * |
||
1144 | * @return boolean |
||
1145 | */ |
||
1146 | 453 | public function isChangeTrackingDeferredImplicit() |
|
1150 | |||
1151 | /** |
||
1152 | * Whether the change tracking policy of this class is "notify". |
||
1153 | * |
||
1154 | * @return boolean |
||
1155 | */ |
||
1156 | 284 | public function isChangeTrackingNotify() |
|
1160 | |||
1161 | /** |
||
1162 | * Checks whether a field is part of the identifier/primary key field(s). |
||
1163 | * |
||
1164 | * @param string $fieldName The field name. |
||
1165 | * |
||
1166 | * @return boolean TRUE if the field is part of the table identifier/primary key field(s), |
||
1167 | * FALSE otherwise. |
||
1168 | */ |
||
1169 | 1047 | public function isIdentifier($fieldName) |
|
1181 | |||
1182 | /** |
||
1183 | * Checks if the field is unique. |
||
1184 | * |
||
1185 | * @param string $fieldName The field name. |
||
1186 | * |
||
1187 | * @return boolean TRUE if the field is unique, FALSE otherwise. |
||
1188 | */ |
||
1189 | public function isUniqueField($fieldName) |
||
1199 | |||
1200 | /** |
||
1201 | * Checks if the field is not null. |
||
1202 | * |
||
1203 | * @param string $fieldName The field name. |
||
1204 | * |
||
1205 | * @return boolean TRUE if the field is not null, FALSE otherwise. |
||
1206 | */ |
||
1207 | 1 | public function isNullable($fieldName) |
|
1217 | |||
1218 | /** |
||
1219 | * Gets a column name for a field name. |
||
1220 | * If the column name for the field cannot be found, the given field name |
||
1221 | * is returned. |
||
1222 | * |
||
1223 | * @param string $fieldName The field name. |
||
1224 | * |
||
1225 | * @return string The column name. |
||
1226 | */ |
||
1227 | 16 | public function getColumnName($fieldName) |
|
1233 | |||
1234 | /** |
||
1235 | * Gets the mapping of a (regular) field that holds some data but not a |
||
1236 | * reference to another object. |
||
1237 | * |
||
1238 | * @param string $fieldName The field name. |
||
1239 | * |
||
1240 | * @return array The field mapping. |
||
1241 | * |
||
1242 | * @throws MappingException |
||
1243 | */ |
||
1244 | 196 | public function getFieldMapping($fieldName) |
|
1252 | |||
1253 | /** |
||
1254 | * Gets the mapping of an association. |
||
1255 | * |
||
1256 | * @see ClassMetadataInfo::$associationMappings |
||
1257 | * |
||
1258 | * @param string $fieldName The field name that represents the association in |
||
1259 | * the object model. |
||
1260 | * |
||
1261 | * @return array The mapping. |
||
1262 | * |
||
1263 | * @throws MappingException |
||
1264 | */ |
||
1265 | 477 | public function getAssociationMapping($fieldName) |
|
1273 | |||
1274 | /** |
||
1275 | * Gets all association mappings of the class. |
||
1276 | * |
||
1277 | * @return array |
||
1278 | */ |
||
1279 | public function getAssociationMappings() |
||
1283 | |||
1284 | /** |
||
1285 | * Gets the field name for a column name. |
||
1286 | * If no field name can be found the column name is returned. |
||
1287 | * |
||
1288 | * @param string $columnName The column name. |
||
1289 | * |
||
1290 | * @return string The column alias. |
||
1291 | */ |
||
1292 | 227 | public function getFieldName($columnName) |
|
1298 | |||
1299 | /** |
||
1300 | * Gets the named query. |
||
1301 | * |
||
1302 | * @see ClassMetadataInfo::$namedQueries |
||
1303 | * |
||
1304 | * @param string $queryName The query name. |
||
1305 | * |
||
1306 | * @return string |
||
1307 | * |
||
1308 | * @throws MappingException |
||
1309 | */ |
||
1310 | 3 | public function getNamedQuery($queryName) |
|
1318 | |||
1319 | /** |
||
1320 | * Gets all named queries of the class. |
||
1321 | * |
||
1322 | * @return array |
||
1323 | */ |
||
1324 | 7 | public function getNamedQueries() |
|
1328 | |||
1329 | /** |
||
1330 | * Gets the named native query. |
||
1331 | * |
||
1332 | * @see ClassMetadataInfo::$namedNativeQueries |
||
1333 | * |
||
1334 | * @param string $queryName The query name. |
||
1335 | * |
||
1336 | * @return array |
||
1337 | * |
||
1338 | * @throws MappingException |
||
1339 | */ |
||
1340 | 17 | public function getNamedNativeQuery($queryName) |
|
1348 | |||
1349 | /** |
||
1350 | * Gets all named native queries of the class. |
||
1351 | * |
||
1352 | * @return array |
||
1353 | */ |
||
1354 | 2 | public function getNamedNativeQueries() |
|
1358 | |||
1359 | /** |
||
1360 | * Gets the result set mapping. |
||
1361 | * |
||
1362 | * @see ClassMetadataInfo::$sqlResultSetMappings |
||
1363 | * |
||
1364 | * @param string $name The result set mapping name. |
||
1365 | * |
||
1366 | * @return array |
||
1367 | * |
||
1368 | * @throws MappingException |
||
1369 | */ |
||
1370 | 21 | public function getSqlResultSetMapping($name) |
|
1378 | |||
1379 | /** |
||
1380 | * Gets all sql result set mappings of the class. |
||
1381 | * |
||
1382 | * @return array |
||
1383 | */ |
||
1384 | 8 | public function getSqlResultSetMappings() |
|
1388 | |||
1389 | /** |
||
1390 | * Validates & completes the given field mapping. |
||
1391 | * |
||
1392 | * @param array $mapping The field mapping to validate & complete. |
||
1393 | * |
||
1394 | * @return array The validated and completed field mapping. |
||
1395 | * |
||
1396 | * @throws MappingException |
||
1397 | */ |
||
1398 | 503 | protected function _validateAndCompleteFieldMapping(array &$mapping) |
|
1452 | |||
1453 | /** |
||
1454 | * Validates & completes the basic mapping information that is common to all |
||
1455 | * association mappings (one-to-one, many-ot-one, one-to-many, many-to-many). |
||
1456 | * |
||
1457 | * @param array $mapping The mapping. |
||
1458 | * |
||
1459 | * @return array The updated mapping. |
||
1460 | * |
||
1461 | * @throws MappingException If something is wrong with the mapping. |
||
1462 | */ |
||
1463 | 337 | protected function _validateAndCompleteAssociationMapping(array $mapping) |
|
1580 | |||
1581 | /** |
||
1582 | * Validates & completes a one-to-one association mapping. |
||
1583 | * |
||
1584 | * @param array $mapping The mapping to validate & complete. |
||
1585 | * |
||
1586 | * @return array The validated & completed mapping. |
||
1587 | * |
||
1588 | * @throws RuntimeException |
||
1589 | * @throws MappingException |
||
1590 | */ |
||
1591 | 288 | protected function _validateAndCompleteOneToOneMapping(array $mapping) |
|
1673 | |||
1674 | /** |
||
1675 | * Validates & completes a one-to-many association mapping. |
||
1676 | * |
||
1677 | * @param array $mapping The mapping to validate and complete. |
||
1678 | * |
||
1679 | * @return array The validated and completed mapping. |
||
1680 | * |
||
1681 | * @throws MappingException |
||
1682 | * @throws InvalidArgumentException |
||
1683 | */ |
||
1684 | 127 | protected function _validateAndCompleteOneToManyMapping(array $mapping) |
|
1704 | |||
1705 | /** |
||
1706 | * Validates & completes a many-to-many association mapping. |
||
1707 | * |
||
1708 | * @param array $mapping The mapping to validate & complete. |
||
1709 | * |
||
1710 | * @return array The validated & completed mapping. |
||
1711 | * |
||
1712 | * @throws \InvalidArgumentException |
||
1713 | */ |
||
1714 | 143 | protected function _validateAndCompleteManyToManyMapping(array $mapping) |
|
1814 | |||
1815 | /** |
||
1816 | * {@inheritDoc} |
||
1817 | */ |
||
1818 | 572 | public function getIdentifierFieldNames() |
|
1822 | |||
1823 | /** |
||
1824 | * Gets the name of the single id field. Note that this only works on |
||
1825 | * entity classes that have a single-field pk. |
||
1826 | * |
||
1827 | * @return string |
||
1828 | * |
||
1829 | * @throws MappingException If the class has a composite primary key. |
||
1830 | */ |
||
1831 | 382 | public function getSingleIdentifierFieldName() |
|
1839 | |||
1840 | /** |
||
1841 | * Gets the column name of the single id column. Note that this only works on |
||
1842 | * entity classes that have a single-field pk. |
||
1843 | * |
||
1844 | * @return string |
||
1845 | * |
||
1846 | * @throws MappingException If the class has a composite primary key. |
||
1847 | */ |
||
1848 | 3 | public function getSingleIdentifierColumnName() |
|
1852 | |||
1853 | /** |
||
1854 | * INTERNAL: |
||
1855 | * Sets the mapped identifier/primary key fields of this class. |
||
1856 | * Mainly used by the ClassMetadataFactory to assign inherited identifiers. |
||
1857 | * |
||
1858 | * @param array $identifier |
||
1859 | * |
||
1860 | * @return void |
||
1861 | */ |
||
1862 | 101 | public function setIdentifier(array $identifier) |
|
1867 | |||
1868 | /** |
||
1869 | * {@inheritDoc} |
||
1870 | */ |
||
1871 | 60 | public function getIdentifier() |
|
1875 | |||
1876 | /** |
||
1877 | * {@inheritDoc} |
||
1878 | */ |
||
1879 | 287 | public function hasField($fieldName) |
|
1883 | |||
1884 | /** |
||
1885 | * Gets an array containing all the column names. |
||
1886 | * |
||
1887 | * @param array|null $fieldNames |
||
1888 | * |
||
1889 | * @return array |
||
1890 | */ |
||
1891 | 36 | public function getColumnNames(array $fieldNames = null) |
|
1899 | |||
1900 | /** |
||
1901 | * Returns an array with all the identifier column names. |
||
1902 | * |
||
1903 | * @return array |
||
1904 | */ |
||
1905 | 319 | public function getIdentifierColumnNames() |
|
1925 | |||
1926 | /** |
||
1927 | * Sets the type of Id generator to use for the mapped class. |
||
1928 | * |
||
1929 | * @param int $generatorType |
||
1930 | * |
||
1931 | * @return void |
||
1932 | */ |
||
1933 | 431 | public function setIdGeneratorType($generatorType) |
|
1937 | |||
1938 | /** |
||
1939 | * Checks whether the mapped class uses an Id generator. |
||
1940 | * |
||
1941 | * @return boolean TRUE if the mapped class uses an Id generator, FALSE otherwise. |
||
1942 | */ |
||
1943 | 368 | public function usesIdGenerator() |
|
1947 | |||
1948 | /** |
||
1949 | * @return boolean |
||
1950 | */ |
||
1951 | 1289 | public function isInheritanceTypeNone() |
|
1955 | |||
1956 | /** |
||
1957 | * Checks whether the mapped class uses the JOINED inheritance mapping strategy. |
||
1958 | * |
||
1959 | * @return boolean TRUE if the class participates in a JOINED inheritance mapping, |
||
1960 | * FALSE otherwise. |
||
1961 | */ |
||
1962 | 1018 | public function isInheritanceTypeJoined() |
|
1966 | |||
1967 | /** |
||
1968 | * Checks whether the mapped class uses the SINGLE_TABLE inheritance mapping strategy. |
||
1969 | * |
||
1970 | * @return boolean TRUE if the class participates in a SINGLE_TABLE inheritance mapping, |
||
1971 | * FALSE otherwise. |
||
1972 | */ |
||
1973 | 1174 | public function isInheritanceTypeSingleTable() |
|
1977 | |||
1978 | /** |
||
1979 | * Checks whether the mapped class uses the TABLE_PER_CLASS inheritance mapping strategy. |
||
1980 | * |
||
1981 | * @return boolean TRUE if the class participates in a TABLE_PER_CLASS inheritance mapping, |
||
1982 | * FALSE otherwise. |
||
1983 | */ |
||
1984 | 240 | public function isInheritanceTypeTablePerClass() |
|
1988 | |||
1989 | /** |
||
1990 | * Checks whether the class uses an identity column for the Id generation. |
||
1991 | * |
||
1992 | * @return boolean TRUE if the class uses the IDENTITY generator, FALSE otherwise. |
||
1993 | */ |
||
1994 | 1040 | public function isIdGeneratorIdentity() |
|
1998 | |||
1999 | /** |
||
2000 | * Checks whether the class uses a sequence for id generation. |
||
2001 | * |
||
2002 | * @return boolean TRUE if the class uses the SEQUENCE generator, FALSE otherwise. |
||
2003 | */ |
||
2004 | 294 | public function isIdGeneratorSequence() |
|
2008 | |||
2009 | /** |
||
2010 | * Checks whether the class uses a table for id generation. |
||
2011 | * |
||
2012 | * @return boolean TRUE if the class uses the TABLE generator, FALSE otherwise. |
||
2013 | */ |
||
2014 | 78 | public function isIdGeneratorTable() |
|
2018 | |||
2019 | /** |
||
2020 | * Checks whether the class has a natural identifier/pk (which means it does |
||
2021 | * not use any Id generator. |
||
2022 | * |
||
2023 | * @return boolean |
||
2024 | */ |
||
2025 | 72 | public function isIdentifierNatural() |
|
2029 | |||
2030 | /** |
||
2031 | * Checks whether the class use a UUID for id generation. |
||
2032 | * |
||
2033 | * @return boolean |
||
2034 | */ |
||
2035 | public function isIdentifierUuid() |
||
2039 | |||
2040 | /** |
||
2041 | * Gets the type of a field. |
||
2042 | * |
||
2043 | * @param string $fieldName |
||
2044 | * |
||
2045 | * @return \Doctrine\DBAL\Types\Type|string|null |
||
2046 | * |
||
2047 | * @todo 3.0 Remove this. PersisterHelper should fix it somehow |
||
2048 | */ |
||
2049 | 37 | public function getTypeOfField($fieldName) |
|
2055 | |||
2056 | /** |
||
2057 | * Gets the type of a column. |
||
2058 | * |
||
2059 | * @param string $columnName |
||
2060 | * |
||
2061 | * @return \Doctrine\DBAL\Types\Type|string|null |
||
2062 | * |
||
2063 | * @deprecated 3.0 remove this. this method is bogous and unreliable, since it cannot resolve the type of a column |
||
2064 | * that is derived by a referenced field on a different entity. |
||
2065 | */ |
||
2066 | public function getTypeOfColumn($columnName) |
||
2070 | |||
2071 | /** |
||
2072 | * Gets the name of the primary table. |
||
2073 | * |
||
2074 | * @return string |
||
2075 | */ |
||
2076 | 1440 | public function getTableName() |
|
2080 | |||
2081 | /** |
||
2082 | * Gets primary table's schema name. |
||
2083 | * |
||
2084 | * @return string|null |
||
2085 | */ |
||
2086 | 13 | public function getSchemaName() |
|
2090 | |||
2091 | /** |
||
2092 | * Gets the table name to use for temporary identifier tables of this class. |
||
2093 | * |
||
2094 | * @return string |
||
2095 | */ |
||
2096 | 7 | public function getTemporaryIdTableName() |
|
2101 | |||
2102 | /** |
||
2103 | * Sets the mapped subclasses of this class. |
||
2104 | * |
||
2105 | * @param array $subclasses The names of all mapped subclasses. |
||
2106 | * |
||
2107 | * @return void |
||
2108 | */ |
||
2109 | 2 | public function setSubclasses(array $subclasses) |
|
2115 | |||
2116 | /** |
||
2117 | * Sets the parent class names. |
||
2118 | * Assumes that the class names in the passed array are in the order: |
||
2119 | * directParent -> directParentParent -> directParentParentParent ... -> root. |
||
2120 | * |
||
2121 | * @param array $classNames |
||
2122 | * |
||
2123 | * @return void |
||
2124 | */ |
||
2125 | 382 | public function setParentClasses(array $classNames) |
|
2133 | |||
2134 | /** |
||
2135 | * Sets the inheritance type used by the class and its subclasses. |
||
2136 | * |
||
2137 | * @param integer $type |
||
2138 | * |
||
2139 | * @return void |
||
2140 | * |
||
2141 | * @throws MappingException |
||
2142 | */ |
||
2143 | 145 | public function setInheritanceType($type) |
|
2151 | |||
2152 | /** |
||
2153 | * Sets the association to override association mapping of property for an entity relationship. |
||
2154 | * |
||
2155 | * @param string $fieldName |
||
2156 | * @param array $overrideMapping |
||
2157 | * |
||
2158 | * @return void |
||
2159 | * |
||
2160 | * @throws MappingException |
||
2161 | */ |
||
2162 | 17 | public function setAssociationOverride($fieldName, array $overrideMapping) |
|
2205 | |||
2206 | /** |
||
2207 | * Sets the override for a mapped field. |
||
2208 | * |
||
2209 | * @param string $fieldName |
||
2210 | * @param array $overrideMapping |
||
2211 | * |
||
2212 | * @return void |
||
2213 | * |
||
2214 | * @throws MappingException |
||
2215 | */ |
||
2216 | 13 | public function setAttributeOverride($fieldName, array $overrideMapping) |
|
2248 | |||
2249 | /** |
||
2250 | * Checks whether a mapped field is inherited from an entity superclass. |
||
2251 | * |
||
2252 | * @param string $fieldName |
||
2253 | * |
||
2254 | * @return bool TRUE if the field is inherited, FALSE otherwise. |
||
2255 | */ |
||
2256 | 343 | public function isInheritedField($fieldName) |
|
2260 | |||
2261 | /** |
||
2262 | * Checks if this entity is the root in any entity-inheritance-hierarchy. |
||
2263 | * |
||
2264 | * @return bool |
||
2265 | */ |
||
2266 | 381 | public function isRootEntity() |
|
2270 | |||
2271 | /** |
||
2272 | * Checks whether a mapped association field is inherited from a superclass. |
||
2273 | * |
||
2274 | * @param string $fieldName |
||
2275 | * |
||
2276 | * @return boolean TRUE if the field is inherited, FALSE otherwise. |
||
2277 | */ |
||
2278 | 322 | public function isInheritedAssociation($fieldName) |
|
2282 | |||
2283 | 322 | public function isInheritedEmbeddedClass($fieldName) |
|
2287 | |||
2288 | /** |
||
2289 | * Sets the name of the primary table the class is mapped to. |
||
2290 | * |
||
2291 | * @param string $tableName The table name. |
||
2292 | * |
||
2293 | * @return void |
||
2294 | * |
||
2295 | * @deprecated Use {@link setPrimaryTable}. |
||
2296 | */ |
||
2297 | public function setTableName($tableName) |
||
2301 | |||
2302 | /** |
||
2303 | * Sets the primary table definition. The provided array supports the |
||
2304 | * following structure: |
||
2305 | * |
||
2306 | * name => <tableName> (optional, defaults to class name) |
||
2307 | * indexes => array of indexes (optional) |
||
2308 | * uniqueConstraints => array of constraints (optional) |
||
2309 | * |
||
2310 | * If a key is omitted, the current value is kept. |
||
2311 | * |
||
2312 | * @param array $table The table description. |
||
2313 | * |
||
2314 | * @return void |
||
2315 | */ |
||
2316 | 310 | public function setPrimaryTable(array $table) |
|
2348 | |||
2349 | /** |
||
2350 | * Checks whether the given type identifies an inheritance type. |
||
2351 | * |
||
2352 | * @param integer $type |
||
2353 | * |
||
2354 | * @return boolean TRUE if the given type identifies an inheritance type, FALSe otherwise. |
||
2355 | */ |
||
2356 | 145 | private function _isInheritanceType($type) |
|
2363 | |||
2364 | /** |
||
2365 | * Adds a mapped field to the class. |
||
2366 | * |
||
2367 | * @param array $mapping The field mapping. |
||
2368 | * |
||
2369 | * @return void |
||
2370 | * |
||
2371 | * @throws MappingException |
||
2372 | */ |
||
2373 | 503 | public function mapField(array $mapping) |
|
2380 | |||
2381 | /** |
||
2382 | * INTERNAL: |
||
2383 | * Adds an association mapping without completing/validating it. |
||
2384 | * This is mainly used to add inherited association mappings to derived classes. |
||
2385 | * |
||
2386 | * @param array $mapping |
||
2387 | * |
||
2388 | * @return void |
||
2389 | * |
||
2390 | * @throws MappingException |
||
2391 | */ |
||
2392 | 46 | public function addInheritedAssociationMapping(array $mapping/*, $owningClassName = null*/) |
|
2399 | |||
2400 | /** |
||
2401 | * INTERNAL: |
||
2402 | * Adds a field mapping without completing/validating it. |
||
2403 | * This is mainly used to add inherited field mappings to derived classes. |
||
2404 | * |
||
2405 | * @param array $fieldMapping |
||
2406 | * |
||
2407 | * @return void |
||
2408 | */ |
||
2409 | 100 | public function addInheritedFieldMapping(array $fieldMapping) |
|
2415 | |||
2416 | /** |
||
2417 | * INTERNAL: |
||
2418 | * Adds a named query to this class. |
||
2419 | * |
||
2420 | * @param array $queryMapping |
||
2421 | * |
||
2422 | * @return void |
||
2423 | * |
||
2424 | * @throws MappingException |
||
2425 | */ |
||
2426 | 28 | public function addNamedQuery(array $queryMapping) |
|
2450 | |||
2451 | /** |
||
2452 | * INTERNAL: |
||
2453 | * Adds a named native query to this class. |
||
2454 | * |
||
2455 | * @param array $queryMapping |
||
2456 | * |
||
2457 | * @return void |
||
2458 | * |
||
2459 | * @throws MappingException |
||
2460 | */ |
||
2461 | 39 | public function addNamedNativeQuery(array $queryMapping) |
|
2494 | |||
2495 | /** |
||
2496 | * INTERNAL: |
||
2497 | * Adds a sql result set mapping to this class. |
||
2498 | * |
||
2499 | * @param array $resultMapping |
||
2500 | * |
||
2501 | * @return void |
||
2502 | * |
||
2503 | * @throws MappingException |
||
2504 | */ |
||
2505 | 39 | public function addSqlResultSetMapping(array $resultMapping) |
|
2555 | |||
2556 | /** |
||
2557 | * Adds a one-to-one mapping. |
||
2558 | * |
||
2559 | * @param array $mapping The mapping. |
||
2560 | * |
||
2561 | * @return void |
||
2562 | */ |
||
2563 | 164 | public function mapOneToOne(array $mapping) |
|
2571 | |||
2572 | /** |
||
2573 | * Adds a one-to-many mapping. |
||
2574 | * |
||
2575 | * @param array $mapping The mapping. |
||
2576 | * |
||
2577 | * @return void |
||
2578 | */ |
||
2579 | 127 | public function mapOneToMany(array $mapping) |
|
2587 | |||
2588 | /** |
||
2589 | * Adds a many-to-one mapping. |
||
2590 | * |
||
2591 | * @param array $mapping The mapping. |
||
2592 | * |
||
2593 | * @return void |
||
2594 | */ |
||
2595 | 155 | public function mapManyToOne(array $mapping) |
|
2604 | |||
2605 | /** |
||
2606 | * Adds a many-to-many mapping. |
||
2607 | * |
||
2608 | * @param array $mapping The mapping. |
||
2609 | * |
||
2610 | * @return void |
||
2611 | */ |
||
2612 | 143 | public function mapManyToMany(array $mapping) |
|
2620 | |||
2621 | /** |
||
2622 | * Stores the association mapping. |
||
2623 | * |
||
2624 | * @param array $assocMapping |
||
2625 | * |
||
2626 | * @return void |
||
2627 | * |
||
2628 | * @throws MappingException |
||
2629 | */ |
||
2630 | 326 | protected function _storeAssociationMapping(array $assocMapping) |
|
2638 | |||
2639 | /** |
||
2640 | * Registers a custom repository class for the entity class. |
||
2641 | * |
||
2642 | * @param string $repositoryClassName The class name of the custom mapper. |
||
2643 | * |
||
2644 | * @return void |
||
2645 | */ |
||
2646 | 78 | public function setCustomRepositoryClass($repositoryClassName) |
|
2650 | |||
2651 | /** |
||
2652 | * Registers a custom persister class for the entity class. |
||
2653 | * |
||
2654 | * @param string $persisterClassName The class name of the custom mapper. |
||
2655 | * |
||
2656 | * @return void |
||
2657 | */ |
||
2658 | 22 | public function setCustomPersisterClass($persisterClassName) |
|
2662 | |||
2663 | /** |
||
2664 | * Dispatches the lifecycle event of the given entity to the registered |
||
2665 | * lifecycle callbacks and lifecycle listeners. |
||
2666 | * |
||
2667 | * @deprecated Deprecated since version 2.4 in favor of \Doctrine\ORM\Event\ListenersInvoker |
||
2668 | * |
||
2669 | * @param string $lifecycleEvent The lifecycle event. |
||
2670 | * @param object $entity The Entity on which the event occurred. |
||
2671 | * |
||
2672 | * @return void |
||
2673 | */ |
||
2674 | public function invokeLifecycleCallbacks($lifecycleEvent, $entity) |
||
2680 | |||
2681 | /** |
||
2682 | * Whether the class has any attached lifecycle listeners or callbacks for a lifecycle event. |
||
2683 | * |
||
2684 | * @param string $lifecycleEvent |
||
2685 | * |
||
2686 | * @return boolean |
||
2687 | */ |
||
2688 | public function hasLifecycleCallbacks($lifecycleEvent) |
||
2692 | |||
2693 | /** |
||
2694 | * Gets the registered lifecycle callbacks for an event. |
||
2695 | * |
||
2696 | * @param string $event |
||
2697 | * |
||
2698 | * @return array |
||
2699 | */ |
||
2700 | public function getLifecycleCallbacks($event) |
||
2704 | |||
2705 | /** |
||
2706 | * Adds a lifecycle callback for entities of this class. |
||
2707 | * |
||
2708 | * @param string $callback |
||
2709 | * @param string $event |
||
2710 | * |
||
2711 | * @return void |
||
2712 | */ |
||
2713 | 39 | public function addLifecycleCallback($callback, $event) |
|
2721 | |||
2722 | /** |
||
2723 | * Sets the lifecycle callbacks for entities of this class. |
||
2724 | * Any previously registered callbacks are overwritten. |
||
2725 | * |
||
2726 | * @param array $callbacks |
||
2727 | * |
||
2728 | * @return void |
||
2729 | */ |
||
2730 | 100 | public function setLifecycleCallbacks(array $callbacks) |
|
2734 | |||
2735 | /** |
||
2736 | * Adds a entity listener for entities of this class. |
||
2737 | * |
||
2738 | * @param string $eventName The entity lifecycle event. |
||
2739 | * @param string $class The listener class. |
||
2740 | * @param string $method The listener callback method. |
||
2741 | * |
||
2742 | * @throws \Doctrine\ORM\Mapping\MappingException |
||
2743 | */ |
||
2744 | 35 | public function addEntityListener($eventName, $class, $method) |
|
2767 | |||
2768 | /** |
||
2769 | * Sets the discriminator column definition. |
||
2770 | * |
||
2771 | * @param array $columnDef |
||
2772 | * |
||
2773 | * @return void |
||
2774 | * |
||
2775 | * @throws MappingException |
||
2776 | * |
||
2777 | * @see getDiscriminatorColumn() |
||
2778 | */ |
||
2779 | 139 | public function setDiscriminatorColumn($columnDef) |
|
2805 | |||
2806 | /** |
||
2807 | * Sets the discriminator values used by this class. |
||
2808 | * Used for JOINED and SINGLE_TABLE inheritance mapping strategies. |
||
2809 | * |
||
2810 | * @param array $map |
||
2811 | * |
||
2812 | * @return void |
||
2813 | */ |
||
2814 | 133 | public function setDiscriminatorMap(array $map) |
|
2820 | |||
2821 | /** |
||
2822 | * Adds one entry of the discriminator map with a new class and corresponding name. |
||
2823 | * |
||
2824 | * @param string $name |
||
2825 | * @param string $className |
||
2826 | * |
||
2827 | * @return void |
||
2828 | * |
||
2829 | * @throws MappingException |
||
2830 | */ |
||
2831 | 103 | public function addDiscriminatorMapClass($name, $className) |
|
2852 | |||
2853 | /** |
||
2854 | * Checks whether the class has a named query with the given query name. |
||
2855 | * |
||
2856 | * @param string $queryName |
||
2857 | * |
||
2858 | * @return boolean |
||
2859 | */ |
||
2860 | 1 | public function hasNamedQuery($queryName) |
|
2864 | |||
2865 | /** |
||
2866 | * Checks whether the class has a named native query with the given query name. |
||
2867 | * |
||
2868 | * @param string $queryName |
||
2869 | * |
||
2870 | * @return boolean |
||
2871 | */ |
||
2872 | 1 | public function hasNamedNativeQuery($queryName) |
|
2876 | |||
2877 | /** |
||
2878 | * Checks whether the class has a named native query with the given query name. |
||
2879 | * |
||
2880 | * @param string $name |
||
2881 | * |
||
2882 | * @return boolean |
||
2883 | */ |
||
2884 | 1 | public function hasSqlResultSetMapping($name) |
|
2888 | |||
2889 | /** |
||
2890 | * {@inheritDoc} |
||
2891 | */ |
||
2892 | 336 | public function hasAssociation($fieldName) |
|
2896 | |||
2897 | /** |
||
2898 | * {@inheritDoc} |
||
2899 | */ |
||
2900 | 1 | public function isSingleValuedAssociation($fieldName) |
|
2905 | |||
2906 | /** |
||
2907 | * {@inheritDoc} |
||
2908 | */ |
||
2909 | 1013 | public function isCollectionValuedAssociation($fieldName) |
|
2914 | |||
2915 | /** |
||
2916 | * Is this an association that only has a single join column? |
||
2917 | * |
||
2918 | * @param string $fieldName |
||
2919 | * |
||
2920 | * @return bool |
||
2921 | */ |
||
2922 | 35 | public function isAssociationWithSingleJoinColumn($fieldName) |
|
2928 | |||
2929 | /** |
||
2930 | * Returns the single association join column (if any). |
||
2931 | * |
||
2932 | * @param string $fieldName |
||
2933 | * |
||
2934 | * @return string |
||
2935 | * |
||
2936 | * @throws MappingException |
||
2937 | */ |
||
2938 | 9 | public function getSingleAssociationJoinColumnName($fieldName) |
|
2946 | |||
2947 | /** |
||
2948 | * Returns the single association referenced join column name (if any). |
||
2949 | * |
||
2950 | * @param string $fieldName |
||
2951 | * |
||
2952 | * @return string |
||
2953 | * |
||
2954 | * @throws MappingException |
||
2955 | */ |
||
2956 | 9 | public function getSingleAssociationReferencedJoinColumnName($fieldName) |
|
2964 | |||
2965 | /** |
||
2966 | * Used to retrieve a fieldname for either field or association from a given column. |
||
2967 | * |
||
2968 | * This method is used in foreign-key as primary-key contexts. |
||
2969 | * |
||
2970 | * @param string $columnName |
||
2971 | * |
||
2972 | * @return string |
||
2973 | * |
||
2974 | * @throws MappingException |
||
2975 | */ |
||
2976 | 629 | public function getFieldForColumn($columnName) |
|
2992 | |||
2993 | /** |
||
2994 | * Sets the ID generator used to generate IDs for instances of this class. |
||
2995 | * |
||
2996 | * @param \Doctrine\ORM\Id\AbstractIdGenerator $generator |
||
2997 | * |
||
2998 | * @return void |
||
2999 | */ |
||
3000 | 384 | public function setIdGenerator($generator) |
|
3004 | |||
3005 | /** |
||
3006 | * Sets definition. |
||
3007 | * |
||
3008 | * @param array $definition |
||
3009 | * |
||
3010 | * @return void |
||
3011 | */ |
||
3012 | 12 | public function setCustomGeneratorDefinition(array $definition) |
|
3016 | |||
3017 | /** |
||
3018 | * Sets the definition of the sequence ID generator for this class. |
||
3019 | * |
||
3020 | * The definition must have the following structure: |
||
3021 | * <code> |
||
3022 | * array( |
||
3023 | * 'sequenceName' => 'name', |
||
3024 | * 'allocationSize' => 20, |
||
3025 | * 'initialValue' => 1 |
||
3026 | * 'quoted' => 1 |
||
3027 | * ) |
||
3028 | * </code> |
||
3029 | * |
||
3030 | * @param array $definition |
||
3031 | * |
||
3032 | * @return void |
||
3033 | * |
||
3034 | * @throws MappingException |
||
3035 | */ |
||
3036 | 20 | public function setSequenceGeneratorDefinition(array $definition) |
|
3049 | |||
3050 | /** |
||
3051 | * Sets the version field mapping used for versioning. Sets the default |
||
3052 | * value to use depending on the column type. |
||
3053 | * |
||
3054 | * @param array $mapping The version field mapping array. |
||
3055 | * |
||
3056 | * @return void |
||
3057 | * |
||
3058 | * @throws MappingException |
||
3059 | */ |
||
3060 | 25 | public function setVersionMapping(array &$mapping) |
|
3075 | |||
3076 | /** |
||
3077 | * Sets whether this class is to be versioned for optimistic locking. |
||
3078 | * |
||
3079 | * @param boolean $bool |
||
3080 | * |
||
3081 | * @return void |
||
3082 | */ |
||
3083 | 100 | public function setVersioned($bool) |
|
3087 | |||
3088 | /** |
||
3089 | * Sets the name of the field that is to be used for versioning if this class is |
||
3090 | * versioned for optimistic locking. |
||
3091 | * |
||
3092 | * @param string $versionField |
||
3093 | * |
||
3094 | * @return void |
||
3095 | */ |
||
3096 | 100 | public function setVersionField($versionField) |
|
3100 | |||
3101 | /** |
||
3102 | * Marks this class as read only, no change tracking is applied to it. |
||
3103 | * |
||
3104 | * @return void |
||
3105 | */ |
||
3106 | 3 | public function markReadOnly() |
|
3110 | |||
3111 | /** |
||
3112 | * {@inheritDoc} |
||
3113 | */ |
||
3114 | public function getFieldNames() |
||
3118 | |||
3119 | /** |
||
3120 | * {@inheritDoc} |
||
3121 | */ |
||
3122 | public function getAssociationNames() |
||
3126 | |||
3127 | /** |
||
3128 | * {@inheritDoc} |
||
3129 | * |
||
3130 | * @throws InvalidArgumentException |
||
3131 | */ |
||
3132 | 1 | public function getAssociationTargetClass($assocName) |
|
3140 | |||
3141 | /** |
||
3142 | * {@inheritDoc} |
||
3143 | */ |
||
3144 | 712 | public function getName() |
|
3148 | |||
3149 | /** |
||
3150 | * Gets the (possibly quoted) identifier column names for safe use in an SQL statement. |
||
3151 | * |
||
3152 | * @deprecated Deprecated since version 2.3 in favor of \Doctrine\ORM\Mapping\QuoteStrategy |
||
3153 | * |
||
3154 | * @param \Doctrine\DBAL\Platforms\AbstractPlatform $platform |
||
3155 | * |
||
3156 | * @return array |
||
3157 | */ |
||
3158 | public function getQuotedIdentifierColumnNames($platform) |
||
3187 | |||
3188 | /** |
||
3189 | * Gets the (possibly quoted) column name of a mapped field for safe use in an SQL statement. |
||
3190 | * |
||
3191 | * @deprecated Deprecated since version 2.3 in favor of \Doctrine\ORM\Mapping\QuoteStrategy |
||
3192 | * |
||
3193 | * @param string $field |
||
3194 | * @param \Doctrine\DBAL\Platforms\AbstractPlatform $platform |
||
3195 | * |
||
3196 | * @return string |
||
3197 | */ |
||
3198 | public function getQuotedColumnName($field, $platform) |
||
3204 | |||
3205 | /** |
||
3206 | * Gets the (possibly quoted) primary table name of this class for safe use in an SQL statement. |
||
3207 | * |
||
3208 | * @deprecated Deprecated since version 2.3 in favor of \Doctrine\ORM\Mapping\QuoteStrategy |
||
3209 | * |
||
3210 | * @param \Doctrine\DBAL\Platforms\AbstractPlatform $platform |
||
3211 | * |
||
3212 | * @return string |
||
3213 | */ |
||
3214 | public function getQuotedTableName($platform) |
||
3220 | |||
3221 | /** |
||
3222 | * Gets the (possibly quoted) name of the join table. |
||
3223 | * |
||
3224 | * @deprecated Deprecated since version 2.3 in favor of \Doctrine\ORM\Mapping\QuoteStrategy |
||
3225 | * |
||
3226 | * @param array $assoc |
||
3227 | * @param \Doctrine\DBAL\Platforms\AbstractPlatform $platform |
||
3228 | * |
||
3229 | * @return string |
||
3230 | */ |
||
3231 | public function getQuotedJoinTableName(array $assoc, $platform) |
||
3237 | |||
3238 | /** |
||
3239 | * {@inheritDoc} |
||
3240 | */ |
||
3241 | 12 | public function isAssociationInverseSide($fieldName) |
|
3246 | |||
3247 | /** |
||
3248 | * {@inheritDoc} |
||
3249 | */ |
||
3250 | public function getAssociationMappedByTargetField($fieldName) |
||
3254 | |||
3255 | /** |
||
3256 | * @param string $targetClass |
||
3257 | * |
||
3258 | * @return array |
||
3259 | */ |
||
3260 | 2 | public function getAssociationsByTargetClass($targetClass) |
|
3272 | |||
3273 | /** |
||
3274 | * @param string|null $className |
||
3275 | * |
||
3276 | * @return string|null null if the input value is null |
||
3277 | */ |
||
3278 | 485 | public function fullyQualifiedClassName($className) |
|
3290 | |||
3291 | /** |
||
3292 | * @param string $name |
||
3293 | * |
||
3294 | * @return mixed |
||
3295 | */ |
||
3296 | 2 | public function getMetadataValue($name) |
|
3305 | |||
3306 | /** |
||
3307 | * Map Embedded Class |
||
3308 | * |
||
3309 | * @param array $mapping |
||
3310 | * |
||
3311 | * @throws MappingException |
||
3312 | * @return void |
||
3313 | */ |
||
3314 | 26 | public function mapEmbedded(array $mapping) |
|
3325 | |||
3326 | /** |
||
3327 | * Inline the embeddable class |
||
3328 | * |
||
3329 | * @param string $property |
||
3330 | * @param ClassMetadataInfo $embeddable |
||
3331 | */ |
||
3332 | 10 | public function inlineEmbeddable($property, ClassMetadataInfo $embeddable) |
|
3361 | |||
3362 | /** |
||
3363 | * @param string $fieldName |
||
3364 | * @throws MappingException |
||
3365 | */ |
||
3366 | 537 | private function assertFieldNotMapped($fieldName) |
|
3375 | |||
3376 | /** |
||
3377 | * Gets the sequence name based on class metadata. |
||
3378 | * |
||
3379 | * @param AbstractPlatform $platform |
||
3380 | * @return string |
||
3381 | * |
||
3382 | * @todo Sequence names should be computed in DBAL depending on the platform |
||
3383 | */ |
||
3384 | 3 | public function getSequenceName(AbstractPlatform $platform) |
|
3392 | |||
3393 | /** |
||
3394 | * Gets the sequence name prefix based on class metadata. |
||
3395 | * |
||
3396 | * @param AbstractPlatform $platform |
||
3397 | * @return string |
||
3398 | * |
||
3399 | * @todo Sequence names should be computed in DBAL depending on the platform |
||
3400 | */ |
||
3401 | 3 | public function getSequencePrefix(AbstractPlatform $platform) |
|
3417 | } |
||
3418 |
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: