Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
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 |
||
44 | class ClassMetadataInfo implements \Doctrine\Common\Persistence\Mapping\ClassMetadata |
||
45 | { |
||
46 | /* The Id generator types. */ |
||
47 | /** |
||
48 | * AUTO means Doctrine will automatically create a new \MongoId instance for us. |
||
49 | */ |
||
50 | const GENERATOR_TYPE_AUTO = 1; |
||
51 | |||
52 | /** |
||
53 | * INCREMENT means a separate collection is used for maintaining and incrementing id generation. |
||
54 | * Offers full portability. |
||
55 | */ |
||
56 | const GENERATOR_TYPE_INCREMENT = 2; |
||
57 | |||
58 | /** |
||
59 | * UUID means Doctrine will generate a uuid for us. |
||
60 | */ |
||
61 | const GENERATOR_TYPE_UUID = 3; |
||
62 | |||
63 | /** |
||
64 | * ALNUM means Doctrine will generate Alpha-numeric string identifiers, using the INCREMENT |
||
65 | * generator to ensure identifier uniqueness |
||
66 | */ |
||
67 | const GENERATOR_TYPE_ALNUM = 4; |
||
68 | |||
69 | /** |
||
70 | * CUSTOM means Doctrine expect a class parameter. It will then try to initiate that class |
||
71 | * and pass other options to the generator. It will throw an Exception if the class |
||
72 | * does not exist or if an option was passed for that there is not setter in the new |
||
73 | * generator class. |
||
74 | * |
||
75 | * The class will have to be a subtype of AbstractIdGenerator. |
||
76 | */ |
||
77 | const GENERATOR_TYPE_CUSTOM = 5; |
||
78 | |||
79 | /** |
||
80 | * NONE means Doctrine will not generate any id for us and you are responsible for manually |
||
81 | * assigning an id. |
||
82 | */ |
||
83 | const GENERATOR_TYPE_NONE = 6; |
||
84 | |||
85 | /** |
||
86 | * Default discriminator field name. |
||
87 | * |
||
88 | * This is used for associations value for associations where a that do not define a "targetDocument" or |
||
89 | * "discriminatorField" option in their mapping. |
||
90 | */ |
||
91 | const DEFAULT_DISCRIMINATOR_FIELD = '_doctrine_class_name'; |
||
92 | |||
93 | const REFERENCE_ONE = 1; |
||
94 | const REFERENCE_MANY = 2; |
||
95 | const EMBED_ONE = 3; |
||
96 | const EMBED_MANY = 4; |
||
97 | const MANY = 'many'; |
||
98 | const ONE = 'one'; |
||
99 | |||
100 | /** |
||
101 | * The types of storeAs references |
||
102 | */ |
||
103 | const REFERENCE_STORE_AS_ID = 'id'; |
||
104 | const REFERENCE_STORE_AS_DB_REF = 'dbRef'; |
||
105 | const REFERENCE_STORE_AS_DB_REF_WITH_DB = 'dbRefWithDb'; |
||
106 | const REFERENCE_STORE_AS_REF = 'ref'; |
||
107 | |||
108 | /* The inheritance mapping types */ |
||
109 | /** |
||
110 | * NONE means the class does not participate in an inheritance hierarchy |
||
111 | * and therefore does not need an inheritance mapping type. |
||
112 | */ |
||
113 | const INHERITANCE_TYPE_NONE = 1; |
||
114 | |||
115 | /** |
||
116 | * SINGLE_COLLECTION means the class will be persisted according to the rules of |
||
117 | * <tt>Single Collection Inheritance</tt>. |
||
118 | */ |
||
119 | const INHERITANCE_TYPE_SINGLE_COLLECTION = 2; |
||
120 | |||
121 | /** |
||
122 | * COLLECTION_PER_CLASS means the class will be persisted according to the rules |
||
123 | * of <tt>Concrete Collection Inheritance</tt>. |
||
124 | */ |
||
125 | const INHERITANCE_TYPE_COLLECTION_PER_CLASS = 3; |
||
126 | |||
127 | /** |
||
128 | * DEFERRED_IMPLICIT means that changes of entities are calculated at commit-time |
||
129 | * by doing a property-by-property comparison with the original data. This will |
||
130 | * be done for all entities that are in MANAGED state at commit-time. |
||
131 | * |
||
132 | * This is the default change tracking policy. |
||
133 | */ |
||
134 | const CHANGETRACKING_DEFERRED_IMPLICIT = 1; |
||
135 | |||
136 | /** |
||
137 | * DEFERRED_EXPLICIT means that changes of entities are calculated at commit-time |
||
138 | * by doing a property-by-property comparison with the original data. This will |
||
139 | * be done only for entities that were explicitly saved (through persist() or a cascade). |
||
140 | */ |
||
141 | const CHANGETRACKING_DEFERRED_EXPLICIT = 2; |
||
142 | |||
143 | /** |
||
144 | * NOTIFY means that Doctrine relies on the entities sending out notifications |
||
145 | * when their properties change. Such entity classes must implement |
||
146 | * the <tt>NotifyPropertyChanged</tt> interface. |
||
147 | */ |
||
148 | const CHANGETRACKING_NOTIFY = 3; |
||
149 | |||
150 | /** |
||
151 | * SET means that fields will be written to the database using a $set operator |
||
152 | */ |
||
153 | const STORAGE_STRATEGY_SET = 'set'; |
||
154 | |||
155 | /** |
||
156 | * INCREMENT means that fields will be written to the database by calculating |
||
157 | * the difference and using the $inc operator |
||
158 | */ |
||
159 | const STORAGE_STRATEGY_INCREMENT = 'increment'; |
||
160 | |||
161 | const STORAGE_STRATEGY_PUSH_ALL = 'pushAll'; |
||
162 | const STORAGE_STRATEGY_ADD_TO_SET = 'addToSet'; |
||
163 | const STORAGE_STRATEGY_ATOMIC_SET = 'atomicSet'; |
||
164 | const STORAGE_STRATEGY_ATOMIC_SET_ARRAY = 'atomicSetArray'; |
||
165 | const STORAGE_STRATEGY_SET_ARRAY = 'setArray'; |
||
166 | |||
167 | /** |
||
168 | * READ-ONLY: The name of the mongo database the document is mapped to. |
||
169 | */ |
||
170 | public $db; |
||
171 | |||
172 | /** |
||
173 | * READ-ONLY: The name of the mongo collection the document is mapped to. |
||
174 | */ |
||
175 | public $collection; |
||
176 | |||
177 | /** |
||
178 | * READ-ONLY: If the collection should be a fixed size. |
||
179 | */ |
||
180 | public $collectionCapped; |
||
181 | |||
182 | /** |
||
183 | * READ-ONLY: If the collection is fixed size, its size in bytes. |
||
184 | */ |
||
185 | public $collectionSize; |
||
186 | |||
187 | /** |
||
188 | * READ-ONLY: If the collection is fixed size, the maximum number of elements to store in the collection. |
||
189 | */ |
||
190 | public $collectionMax; |
||
191 | |||
192 | /** |
||
193 | * READ-ONLY Describes how MongoDB clients route read operations to the members of a replica set. |
||
194 | */ |
||
195 | public $readPreference; |
||
196 | |||
197 | /** |
||
198 | * READ-ONLY Associated with readPreference Allows to specify criteria so that your application can target read |
||
199 | * operations to specific members, based on custom parameters. |
||
200 | */ |
||
201 | public $readPreferenceTags; |
||
202 | |||
203 | /** |
||
204 | * READ-ONLY: Describes the level of acknowledgement requested from MongoDB for write operations. |
||
205 | */ |
||
206 | public $writeConcern; |
||
207 | |||
208 | /** |
||
209 | * READ-ONLY: The field name of the document identifier. |
||
210 | */ |
||
211 | public $identifier; |
||
212 | |||
213 | /** |
||
214 | * READ-ONLY: The field that stores a file reference and indicates the |
||
215 | * document is a file and should be stored on the MongoGridFS. |
||
216 | */ |
||
217 | public $file; |
||
218 | |||
219 | /** |
||
220 | * READ-ONLY: The field that stores the calculated distance when performing geo spatial |
||
221 | * queries. |
||
222 | */ |
||
223 | public $distance; |
||
224 | |||
225 | /** |
||
226 | * READ-ONLY: Whether or not reads for this class are okay to read from a slave. |
||
227 | * |
||
228 | * @deprecated in version 1.2 and will be removed in 2.0. |
||
229 | */ |
||
230 | public $slaveOkay; |
||
231 | |||
232 | /** |
||
233 | * READ-ONLY: The array of indexes for the document collection. |
||
234 | */ |
||
235 | public $indexes = array(); |
||
236 | |||
237 | /** |
||
238 | * READ-ONLY: Keys and options describing shard key. Only for sharded collections. |
||
239 | */ |
||
240 | public $shardKey; |
||
241 | |||
242 | /** |
||
243 | * READ-ONLY: The name of the document class. |
||
244 | */ |
||
245 | public $name; |
||
246 | |||
247 | /** |
||
248 | * READ-ONLY: The namespace the document class is contained in. |
||
249 | * |
||
250 | * @var string |
||
251 | * @todo Not really needed. Usage could be localized. |
||
252 | */ |
||
253 | public $namespace; |
||
254 | |||
255 | /** |
||
256 | * READ-ONLY: The name of the document class that is at the root of the mapped document inheritance |
||
257 | * hierarchy. If the document is not part of a mapped inheritance hierarchy this is the same |
||
258 | * as {@link $documentName}. |
||
259 | * |
||
260 | * @var string |
||
261 | */ |
||
262 | public $rootDocumentName; |
||
263 | |||
264 | /** |
||
265 | * The name of the custom repository class used for the document class. |
||
266 | * (Optional). |
||
267 | * |
||
268 | * @var string |
||
269 | */ |
||
270 | public $customRepositoryClassName; |
||
271 | |||
272 | /** |
||
273 | * READ-ONLY: The names of the parent classes (ancestors). |
||
274 | * |
||
275 | * @var array |
||
276 | */ |
||
277 | public $parentClasses = array(); |
||
278 | |||
279 | /** |
||
280 | * READ-ONLY: The names of all subclasses (descendants). |
||
281 | * |
||
282 | * @var array |
||
283 | */ |
||
284 | public $subClasses = array(); |
||
285 | |||
286 | /** |
||
287 | * The ReflectionProperty instances of the mapped class. |
||
288 | * |
||
289 | * @var \ReflectionProperty[] |
||
290 | */ |
||
291 | public $reflFields = array(); |
||
292 | |||
293 | /** |
||
294 | * READ-ONLY: The inheritance mapping type used by the class. |
||
295 | * |
||
296 | * @var integer |
||
297 | */ |
||
298 | public $inheritanceType = self::INHERITANCE_TYPE_NONE; |
||
299 | |||
300 | /** |
||
301 | * READ-ONLY: The Id generator type used by the class. |
||
302 | * |
||
303 | * @var string |
||
304 | */ |
||
305 | public $generatorType = self::GENERATOR_TYPE_AUTO; |
||
306 | |||
307 | /** |
||
308 | * READ-ONLY: The Id generator options. |
||
309 | * |
||
310 | * @var array |
||
311 | */ |
||
312 | public $generatorOptions = array(); |
||
313 | |||
314 | /** |
||
315 | * READ-ONLY: The ID generator used for generating IDs for this class. |
||
316 | * |
||
317 | * @var \Doctrine\ODM\MongoDB\Id\AbstractIdGenerator |
||
318 | */ |
||
319 | public $idGenerator; |
||
320 | |||
321 | /** |
||
322 | * READ-ONLY: The field mappings of the class. |
||
323 | * Keys are field names and values are mapping definitions. |
||
324 | * |
||
325 | * The mapping definition array has the following values: |
||
326 | * |
||
327 | * - <b>fieldName</b> (string) |
||
328 | * The name of the field in the Document. |
||
329 | * |
||
330 | * - <b>id</b> (boolean, optional) |
||
331 | * Marks the field as the primary key of the document. Multiple fields of an |
||
332 | * document can have the id attribute, forming a composite key. |
||
333 | * |
||
334 | * @var array |
||
335 | */ |
||
336 | public $fieldMappings = array(); |
||
337 | |||
338 | /** |
||
339 | * READ-ONLY: The association mappings of the class. |
||
340 | * Keys are field names and values are mapping definitions. |
||
341 | * |
||
342 | * @var array |
||
343 | */ |
||
344 | public $associationMappings = array(); |
||
345 | |||
346 | /** |
||
347 | * READ-ONLY: Array of fields to also load with a given method. |
||
348 | * |
||
349 | * @var array |
||
350 | */ |
||
351 | public $alsoLoadMethods = array(); |
||
352 | |||
353 | /** |
||
354 | * READ-ONLY: The registered lifecycle callbacks for documents of this class. |
||
355 | * |
||
356 | * @var array |
||
357 | */ |
||
358 | public $lifecycleCallbacks = array(); |
||
359 | |||
360 | /** |
||
361 | * READ-ONLY: The discriminator value of this class. |
||
362 | * |
||
363 | * <b>This does only apply to the JOINED and SINGLE_COLLECTION inheritance mapping strategies |
||
364 | * where a discriminator field is used.</b> |
||
365 | * |
||
366 | * @var mixed |
||
367 | * @see discriminatorField |
||
368 | */ |
||
369 | public $discriminatorValue; |
||
370 | |||
371 | /** |
||
372 | * READ-ONLY: The discriminator map of all mapped classes in the hierarchy. |
||
373 | * |
||
374 | * <b>This does only apply to the SINGLE_COLLECTION inheritance mapping strategy |
||
375 | * where a discriminator field is used.</b> |
||
376 | * |
||
377 | * @var mixed |
||
378 | * @see discriminatorField |
||
379 | */ |
||
380 | public $discriminatorMap = array(); |
||
381 | |||
382 | /** |
||
383 | * READ-ONLY: The definition of the discriminator field used in SINGLE_COLLECTION |
||
384 | * inheritance mapping. |
||
385 | * |
||
386 | * @var string |
||
387 | */ |
||
388 | public $discriminatorField; |
||
389 | |||
390 | /** |
||
391 | * READ-ONLY: The default value for discriminatorField in case it's not set in the document |
||
392 | * |
||
393 | * @var string |
||
394 | * @see discriminatorField |
||
395 | */ |
||
396 | public $defaultDiscriminatorValue; |
||
397 | |||
398 | /** |
||
399 | * READ-ONLY: Whether this class describes the mapping of a mapped superclass. |
||
400 | * |
||
401 | * @var boolean |
||
402 | */ |
||
403 | public $isMappedSuperclass = false; |
||
404 | |||
405 | /** |
||
406 | * READ-ONLY: Whether this class describes the mapping of a embedded document. |
||
407 | * |
||
408 | * @var boolean |
||
409 | */ |
||
410 | public $isEmbeddedDocument = false; |
||
411 | |||
412 | /** |
||
413 | * READ-ONLY: Whether this class describes the mapping of an aggregation result document. |
||
414 | * |
||
415 | * @var boolean |
||
416 | */ |
||
417 | public $isQueryResultDocument = false; |
||
418 | |||
419 | /** |
||
420 | * READ-ONLY: The policy used for change-tracking on entities of this class. |
||
421 | * |
||
422 | * @var integer |
||
423 | */ |
||
424 | public $changeTrackingPolicy = self::CHANGETRACKING_DEFERRED_IMPLICIT; |
||
425 | |||
426 | /** |
||
427 | * READ-ONLY: A flag for whether or not instances of this class are to be versioned |
||
428 | * with optimistic locking. |
||
429 | * |
||
430 | * @var boolean $isVersioned |
||
431 | */ |
||
432 | public $isVersioned; |
||
433 | |||
434 | /** |
||
435 | * READ-ONLY: The name of the field which is used for versioning in optimistic locking (if any). |
||
436 | * |
||
437 | * @var mixed $versionField |
||
438 | */ |
||
439 | public $versionField; |
||
440 | |||
441 | /** |
||
442 | * READ-ONLY: A flag for whether or not instances of this class are to allow pessimistic |
||
443 | * locking. |
||
444 | * |
||
445 | * @var boolean $isLockable |
||
446 | */ |
||
447 | public $isLockable; |
||
448 | |||
449 | /** |
||
450 | * READ-ONLY: The name of the field which is used for locking a document. |
||
451 | * |
||
452 | * @var mixed $lockField |
||
453 | */ |
||
454 | public $lockField; |
||
455 | |||
456 | /** |
||
457 | * The ReflectionClass instance of the mapped class. |
||
458 | * |
||
459 | * @var \ReflectionClass |
||
460 | */ |
||
461 | public $reflClass; |
||
462 | |||
463 | /** |
||
464 | * READ_ONLY: A flag for whether or not this document is read-only. |
||
465 | * |
||
466 | * @var bool |
||
467 | */ |
||
468 | public $isReadOnly; |
||
469 | |||
470 | /** |
||
471 | * Initializes a new ClassMetadata instance that will hold the object-document mapping |
||
472 | * metadata of the class with the given name. |
||
473 | * |
||
474 | * @param string $documentName The name of the document class the new instance is used for. |
||
475 | */ |
||
476 | 993 | public function __construct($documentName) |
|
481 | |||
482 | /** |
||
483 | * Helper method to get reference id of ref* type references |
||
484 | * @param mixed $reference |
||
485 | * @param string $storeAs |
||
486 | * @return mixed |
||
487 | * @internal |
||
488 | */ |
||
489 | 117 | public static function getReferenceId($reference, $storeAs) |
|
493 | |||
494 | /** |
||
495 | * Returns the reference prefix used for a reference |
||
496 | * @param string $storeAs |
||
497 | * @return string |
||
498 | */ |
||
499 | 196 | private static function getReferencePrefix($storeAs) |
|
507 | |||
508 | /** |
||
509 | * Returns a fully qualified field name for a given reference |
||
510 | * @param string $storeAs |
||
511 | * @param string $pathPrefix The field path prefix |
||
512 | * @return string |
||
513 | * @internal |
||
514 | */ |
||
515 | 142 | public static function getReferenceFieldName($storeAs, $pathPrefix = '') |
|
523 | |||
524 | /** |
||
525 | * {@inheritDoc} |
||
526 | */ |
||
527 | 922 | public function getReflectionClass() |
|
535 | |||
536 | /** |
||
537 | * {@inheritDoc} |
||
538 | */ |
||
539 | 324 | public function isIdentifier($fieldName) |
|
543 | |||
544 | /** |
||
545 | * INTERNAL: |
||
546 | * Sets the mapped identifier field of this class. |
||
547 | * |
||
548 | * @param string $identifier |
||
549 | */ |
||
550 | 385 | public function setIdentifier($identifier) |
|
554 | |||
555 | /** |
||
556 | * {@inheritDoc} |
||
557 | * |
||
558 | * Since MongoDB only allows exactly one identifier field |
||
559 | * this will always return an array with only one value |
||
560 | */ |
||
561 | 40 | public function getIdentifier() |
|
565 | |||
566 | /** |
||
567 | * {@inheritDoc} |
||
568 | * |
||
569 | * Since MongoDB only allows exactly one identifier field |
||
570 | * this will always return an array with only one value |
||
571 | */ |
||
572 | 98 | public function getIdentifierFieldNames() |
|
576 | |||
577 | /** |
||
578 | * {@inheritDoc} |
||
579 | */ |
||
580 | 561 | public function hasField($fieldName) |
|
584 | |||
585 | /** |
||
586 | * Sets the inheritance type used by the class and it's subclasses. |
||
587 | * |
||
588 | * @param integer $type |
||
589 | */ |
||
590 | 401 | public function setInheritanceType($type) |
|
594 | |||
595 | /** |
||
596 | * Checks whether a mapped field is inherited from an entity superclass. |
||
597 | * |
||
598 | * @param string $fieldName |
||
599 | * |
||
600 | * @return boolean TRUE if the field is inherited, FALSE otherwise. |
||
601 | */ |
||
602 | 922 | public function isInheritedField($fieldName) |
|
606 | |||
607 | /** |
||
608 | * Registers a custom repository class for the document class. |
||
609 | * |
||
610 | * @param string $repositoryClassName The class name of the custom repository. |
||
611 | */ |
||
612 | 333 | public function setCustomRepositoryClass($repositoryClassName) |
|
624 | |||
625 | /** |
||
626 | * Dispatches the lifecycle event of the given document by invoking all |
||
627 | * registered callbacks. |
||
628 | * |
||
629 | * @param string $event Lifecycle event |
||
630 | * @param object $document Document on which the event occurred |
||
631 | * @param array $arguments Arguments to pass to all callbacks |
||
632 | * @throws \InvalidArgumentException if document class is not this class or |
||
633 | * a Proxy of this class |
||
634 | */ |
||
635 | 683 | public function invokeLifecycleCallbacks($event, $document, array $arguments = null) |
|
653 | |||
654 | /** |
||
655 | * Checks whether the class has callbacks registered for a lifecycle event. |
||
656 | * |
||
657 | * @param string $event Lifecycle event |
||
658 | * |
||
659 | * @return boolean |
||
660 | */ |
||
661 | public function hasLifecycleCallbacks($event) |
||
665 | |||
666 | /** |
||
667 | * Gets the registered lifecycle callbacks for an event. |
||
668 | * |
||
669 | * @param string $event |
||
670 | * @return array |
||
671 | */ |
||
672 | public function getLifecycleCallbacks($event) |
||
676 | |||
677 | /** |
||
678 | * Adds a lifecycle callback for documents of this class. |
||
679 | * |
||
680 | * If the callback is already registered, this is a NOOP. |
||
681 | * |
||
682 | * @param string $callback |
||
683 | * @param string $event |
||
684 | */ |
||
685 | 311 | public function addLifecycleCallback($callback, $event) |
|
693 | |||
694 | /** |
||
695 | * Sets the lifecycle callbacks for documents of this class. |
||
696 | * |
||
697 | * Any previously registered callbacks are overwritten. |
||
698 | * |
||
699 | * @param array $callbacks |
||
700 | */ |
||
701 | 384 | public function setLifecycleCallbacks(array $callbacks) |
|
705 | |||
706 | /** |
||
707 | * Registers a method for loading document data before field hydration. |
||
708 | * |
||
709 | * Note: A method may be registered multiple times for different fields. |
||
710 | * it will be invoked only once for the first field found. |
||
711 | * |
||
712 | * @param string $method Method name |
||
713 | * @param array|string $fields Database field name(s) |
||
714 | */ |
||
715 | 15 | public function registerAlsoLoadMethod($method, $fields) |
|
719 | |||
720 | /** |
||
721 | * Sets the AlsoLoad methods for documents of this class. |
||
722 | * |
||
723 | * Any previously registered methods are overwritten. |
||
724 | * |
||
725 | * @param array $methods |
||
726 | */ |
||
727 | 384 | public function setAlsoLoadMethods(array $methods) |
|
731 | |||
732 | /** |
||
733 | * Sets the discriminator field. |
||
734 | * |
||
735 | * The field name is the the unmapped database field. Discriminator values |
||
736 | * are only used to discern the hydration class and are not mapped to class |
||
737 | * properties. |
||
738 | * |
||
739 | * @param string $discriminatorField |
||
740 | * |
||
741 | * @throws MappingException If the discriminator field conflicts with the |
||
742 | * "name" attribute of a mapped field. |
||
743 | */ |
||
744 | 414 | public function setDiscriminatorField($discriminatorField) |
|
769 | |||
770 | /** |
||
771 | * Sets the discriminator values used by this class. |
||
772 | * Used for JOINED and SINGLE_TABLE inheritance mapping strategies. |
||
773 | * |
||
774 | * @param array $map |
||
775 | * |
||
776 | * @throws MappingException |
||
777 | */ |
||
778 | 407 | public function setDiscriminatorMap(array $map) |
|
797 | |||
798 | /** |
||
799 | * Sets the default discriminator value to be used for this class |
||
800 | * Used for JOINED and SINGLE_TABLE inheritance mapping strategies if the document has no discriminator value |
||
801 | * |
||
802 | * @param string $defaultDiscriminatorValue |
||
803 | * |
||
804 | * @throws MappingException |
||
805 | */ |
||
806 | 391 | public function setDefaultDiscriminatorValue($defaultDiscriminatorValue) |
|
820 | |||
821 | /** |
||
822 | * Sets the discriminator value for this class. |
||
823 | * Used for JOINED/SINGLE_TABLE inheritance and multiple document types in a single |
||
824 | * collection. |
||
825 | * |
||
826 | * @param string $value |
||
827 | */ |
||
828 | 3 | public function setDiscriminatorValue($value) |
|
833 | |||
834 | /** |
||
835 | * Sets the slaveOkay option applied to collections for this class. |
||
836 | * |
||
837 | * @param boolean|null $slaveOkay |
||
838 | * |
||
839 | * @deprecated in version 1.2 and will be removed in 2.0. |
||
840 | * |
||
841 | * @throws MappingException |
||
842 | */ |
||
843 | 3 | public function setSlaveOkay($slaveOkay) |
|
857 | |||
858 | /** |
||
859 | * Add a index for this Document. |
||
860 | * |
||
861 | * @param array $keys Array of keys for the index. |
||
862 | * @param array $options Array of options for the index. |
||
863 | */ |
||
864 | 219 | public function addIndex($keys, array $options = array()) |
|
884 | |||
885 | /** |
||
886 | * Returns the array of indexes for this Document. |
||
887 | * |
||
888 | * @return array $indexes The array of indexes. |
||
889 | */ |
||
890 | 31 | public function getIndexes() |
|
894 | |||
895 | /** |
||
896 | * Checks whether this document has indexes or not. |
||
897 | * |
||
898 | * @return boolean |
||
899 | */ |
||
900 | public function hasIndexes() |
||
904 | |||
905 | /** |
||
906 | * Set shard key for this Document. |
||
907 | * |
||
908 | * @param array $keys Array of document keys. |
||
909 | * @param array $options Array of sharding options. |
||
910 | * |
||
911 | * @throws MappingException |
||
912 | */ |
||
913 | 89 | public function setShardKey(array $keys, array $options = array()) |
|
955 | |||
956 | /** |
||
957 | * @return array |
||
958 | */ |
||
959 | 28 | public function getShardKey() |
|
963 | |||
964 | /** |
||
965 | * Checks whether this document has shard key or not. |
||
966 | * |
||
967 | * @return bool |
||
968 | */ |
||
969 | 627 | public function isSharded() |
|
973 | |||
974 | /** |
||
975 | * Sets the read preference used by this class. |
||
976 | * |
||
977 | * @param string $readPreference |
||
978 | * @param array|null $tags |
||
979 | * |
||
980 | * @throws MappingException |
||
981 | */ |
||
982 | 388 | public function setReadPreference($readPreference, $tags) |
|
990 | |||
991 | /** |
||
992 | * Sets the write concern used by this class. |
||
993 | * |
||
994 | * @param string $writeConcern |
||
995 | */ |
||
996 | 398 | public function setWriteConcern($writeConcern) |
|
1000 | |||
1001 | /** |
||
1002 | * @return string |
||
1003 | */ |
||
1004 | 12 | public function getWriteConcern() |
|
1008 | |||
1009 | /** |
||
1010 | * Whether there is a write concern configured for this class. |
||
1011 | * |
||
1012 | * @return bool |
||
1013 | */ |
||
1014 | 629 | public function hasWriteConcern() |
|
1018 | |||
1019 | /** |
||
1020 | * Sets the change tracking policy used by this class. |
||
1021 | * |
||
1022 | * @param integer $policy |
||
1023 | */ |
||
1024 | 389 | public function setChangeTrackingPolicy($policy) |
|
1028 | |||
1029 | /** |
||
1030 | * Whether the change tracking policy of this class is "deferred explicit". |
||
1031 | * |
||
1032 | * @return boolean |
||
1033 | */ |
||
1034 | 75 | public function isChangeTrackingDeferredExplicit() |
|
1038 | |||
1039 | /** |
||
1040 | * Whether the change tracking policy of this class is "deferred implicit". |
||
1041 | * |
||
1042 | * @return boolean |
||
1043 | */ |
||
1044 | 650 | public function isChangeTrackingDeferredImplicit() |
|
1048 | |||
1049 | /** |
||
1050 | * Whether the change tracking policy of this class is "notify". |
||
1051 | * |
||
1052 | * @return boolean |
||
1053 | */ |
||
1054 | 352 | public function isChangeTrackingNotify() |
|
1058 | |||
1059 | /** |
||
1060 | * Gets the ReflectionProperties of the mapped class. |
||
1061 | * |
||
1062 | * @return array An array of ReflectionProperty instances. |
||
1063 | */ |
||
1064 | 98 | public function getReflectionProperties() |
|
1068 | |||
1069 | /** |
||
1070 | * Gets a ReflectionProperty for a specific field of the mapped class. |
||
1071 | * |
||
1072 | * @param string $name |
||
1073 | * |
||
1074 | * @return \ReflectionProperty |
||
1075 | */ |
||
1076 | public function getReflectionProperty($name) |
||
1080 | |||
1081 | /** |
||
1082 | * {@inheritDoc} |
||
1083 | */ |
||
1084 | 928 | public function getName() |
|
1088 | |||
1089 | /** |
||
1090 | * The namespace this Document class belongs to. |
||
1091 | * |
||
1092 | * @return string $namespace The namespace name. |
||
1093 | */ |
||
1094 | public function getNamespace() |
||
1098 | |||
1099 | /** |
||
1100 | * Returns the database this Document is mapped to. |
||
1101 | * |
||
1102 | * @return string $db The database name. |
||
1103 | */ |
||
1104 | 846 | public function getDatabase() |
|
1108 | |||
1109 | /** |
||
1110 | * Set the database this Document is mapped to. |
||
1111 | * |
||
1112 | * @param string $db The database name |
||
1113 | */ |
||
1114 | 104 | public function setDatabase($db) |
|
1118 | |||
1119 | /** |
||
1120 | * Get the collection this Document is mapped to. |
||
1121 | * |
||
1122 | * @return string $collection The collection name. |
||
1123 | */ |
||
1124 | 851 | public function getCollection() |
|
1128 | |||
1129 | /** |
||
1130 | * Sets the collection this Document is mapped to. |
||
1131 | * |
||
1132 | * @param array|string $name |
||
1133 | * |
||
1134 | * @throws \InvalidArgumentException |
||
1135 | */ |
||
1136 | 958 | public function setCollection($name) |
|
1150 | |||
1151 | /** |
||
1152 | * Get whether or not the documents collection is capped. |
||
1153 | * |
||
1154 | * @return boolean |
||
1155 | */ |
||
1156 | 4 | public function getCollectionCapped() |
|
1160 | |||
1161 | /** |
||
1162 | * Set whether or not the documents collection is capped. |
||
1163 | * |
||
1164 | * @param boolean $bool |
||
1165 | */ |
||
1166 | 1 | public function setCollectionCapped($bool) |
|
1170 | |||
1171 | /** |
||
1172 | * Get the collection size |
||
1173 | * |
||
1174 | * @return integer |
||
1175 | */ |
||
1176 | 4 | public function getCollectionSize() |
|
1180 | |||
1181 | /** |
||
1182 | * Set the collection size. |
||
1183 | * |
||
1184 | * @param integer $size |
||
1185 | */ |
||
1186 | 1 | public function setCollectionSize($size) |
|
1190 | |||
1191 | /** |
||
1192 | * Get the collection max. |
||
1193 | * |
||
1194 | * @return integer |
||
1195 | */ |
||
1196 | 4 | public function getCollectionMax() |
|
1200 | |||
1201 | /** |
||
1202 | * Set the collection max. |
||
1203 | * |
||
1204 | * @param integer $max |
||
1205 | */ |
||
1206 | 1 | public function setCollectionMax($max) |
|
1210 | |||
1211 | /** |
||
1212 | * Returns TRUE if this Document is mapped to a collection FALSE otherwise. |
||
1213 | * |
||
1214 | * @return boolean |
||
1215 | */ |
||
1216 | public function isMappedToCollection() |
||
1220 | |||
1221 | /** |
||
1222 | * Returns TRUE if this Document is a file to be stored on the MongoGridFS FALSE otherwise. |
||
1223 | * |
||
1224 | * @return boolean |
||
1225 | */ |
||
1226 | 792 | public function isFile() |
|
1230 | |||
1231 | /** |
||
1232 | * Returns the file field name. |
||
1233 | * |
||
1234 | * @return string $file The file field name. |
||
1235 | */ |
||
1236 | 384 | public function getFile() |
|
1240 | |||
1241 | /** |
||
1242 | * Set the field name that stores the grid file. |
||
1243 | * |
||
1244 | * @param string $file |
||
1245 | */ |
||
1246 | 385 | public function setFile($file) |
|
1250 | |||
1251 | /** |
||
1252 | * Returns the distance field name. |
||
1253 | * |
||
1254 | * @return string $distance The distance field name. |
||
1255 | */ |
||
1256 | public function getDistance() |
||
1260 | |||
1261 | /** |
||
1262 | * Set the field name that stores the distance. |
||
1263 | * |
||
1264 | * @param string $distance |
||
1265 | */ |
||
1266 | 1 | public function setDistance($distance) |
|
1270 | |||
1271 | /** |
||
1272 | * Map a field. |
||
1273 | * |
||
1274 | * @param array $mapping The mapping information. |
||
1275 | * |
||
1276 | * @return array |
||
1277 | * |
||
1278 | * @throws MappingException |
||
1279 | */ |
||
1280 | 971 | public function mapField(array $mapping) |
|
1461 | |||
1462 | /** |
||
1463 | * Validates the storage strategy of a mapping for consistency |
||
1464 | * @param array $mapping |
||
1465 | * @throws \Doctrine\ODM\MongoDB\Mapping\MappingException |
||
1466 | */ |
||
1467 | 959 | private function applyStorageStrategy(array &$mapping) |
|
1510 | |||
1511 | /** |
||
1512 | * Map a MongoGridFSFile. |
||
1513 | * |
||
1514 | * @param array $mapping The mapping information. |
||
1515 | */ |
||
1516 | public function mapFile(array $mapping) |
||
1522 | |||
1523 | /** |
||
1524 | * Map a single embedded document. |
||
1525 | * |
||
1526 | * @param array $mapping The mapping information. |
||
1527 | */ |
||
1528 | 6 | public function mapOneEmbedded(array $mapping) |
|
1534 | |||
1535 | /** |
||
1536 | * Map a collection of embedded documents. |
||
1537 | * |
||
1538 | * @param array $mapping The mapping information. |
||
1539 | */ |
||
1540 | 5 | public function mapManyEmbedded(array $mapping) |
|
1546 | |||
1547 | /** |
||
1548 | * Map a single document reference. |
||
1549 | * |
||
1550 | * @param array $mapping The mapping information. |
||
1551 | */ |
||
1552 | 8 | public function mapOneReference(array $mapping) |
|
1558 | |||
1559 | /** |
||
1560 | * Map a collection of document references. |
||
1561 | * |
||
1562 | * @param array $mapping The mapping information. |
||
1563 | */ |
||
1564 | 8 | public function mapManyReference(array $mapping) |
|
1570 | |||
1571 | /** |
||
1572 | * INTERNAL: |
||
1573 | * Adds a field mapping without completing/validating it. |
||
1574 | * This is mainly used to add inherited field mappings to derived classes. |
||
1575 | * |
||
1576 | * @param array $fieldMapping |
||
1577 | */ |
||
1578 | 130 | public function addInheritedFieldMapping(array $fieldMapping) |
|
1586 | |||
1587 | /** |
||
1588 | * INTERNAL: |
||
1589 | * Adds an association mapping without completing/validating it. |
||
1590 | * This is mainly used to add inherited association mappings to derived classes. |
||
1591 | * |
||
1592 | * @param array $mapping |
||
1593 | * |
||
1594 | * @return void |
||
1595 | * |
||
1596 | * @throws MappingException |
||
1597 | */ |
||
1598 | 79 | public function addInheritedAssociationMapping(array $mapping/*, $owningClassName = null*/) |
|
1602 | |||
1603 | /** |
||
1604 | * Checks whether the class has a mapped association with the given field name. |
||
1605 | * |
||
1606 | * @param string $fieldName |
||
1607 | * @return boolean |
||
1608 | */ |
||
1609 | 20 | public function hasReference($fieldName) |
|
1613 | |||
1614 | /** |
||
1615 | * Checks whether the class has a mapped embed with the given field name. |
||
1616 | * |
||
1617 | * @param string $fieldName |
||
1618 | * @return boolean |
||
1619 | */ |
||
1620 | 5 | public function hasEmbed($fieldName) |
|
1624 | |||
1625 | /** |
||
1626 | * {@inheritDoc} |
||
1627 | * |
||
1628 | * Checks whether the class has a mapped association (embed or reference) with the given field name. |
||
1629 | */ |
||
1630 | 7 | public function hasAssociation($fieldName) |
|
1634 | |||
1635 | /** |
||
1636 | * {@inheritDoc} |
||
1637 | * |
||
1638 | * Checks whether the class has a mapped reference or embed for the specified field and |
||
1639 | * is a single valued association. |
||
1640 | */ |
||
1641 | public function isSingleValuedAssociation($fieldName) |
||
1645 | |||
1646 | /** |
||
1647 | * {@inheritDoc} |
||
1648 | * |
||
1649 | * Checks whether the class has a mapped reference or embed for the specified field and |
||
1650 | * is a collection valued association. |
||
1651 | */ |
||
1652 | public function isCollectionValuedAssociation($fieldName) |
||
1656 | |||
1657 | /** |
||
1658 | * Checks whether the class has a mapped association for the specified field |
||
1659 | * and if yes, checks whether it is a single-valued association (to-one). |
||
1660 | * |
||
1661 | * @param string $fieldName |
||
1662 | * @return boolean TRUE if the association exists and is single-valued, FALSE otherwise. |
||
1663 | */ |
||
1664 | public function isSingleValuedReference($fieldName) |
||
1669 | |||
1670 | /** |
||
1671 | * Checks whether the class has a mapped association for the specified field |
||
1672 | * and if yes, checks whether it is a collection-valued association (to-many). |
||
1673 | * |
||
1674 | * @param string $fieldName |
||
1675 | * @return boolean TRUE if the association exists and is collection-valued, FALSE otherwise. |
||
1676 | */ |
||
1677 | public function isCollectionValuedReference($fieldName) |
||
1682 | |||
1683 | /** |
||
1684 | * Checks whether the class has a mapped embedded document for the specified field |
||
1685 | * and if yes, checks whether it is a single-valued association (to-one). |
||
1686 | * |
||
1687 | * @param string $fieldName |
||
1688 | * @return boolean TRUE if the association exists and is single-valued, FALSE otherwise. |
||
1689 | */ |
||
1690 | public function isSingleValuedEmbed($fieldName) |
||
1695 | |||
1696 | /** |
||
1697 | * Checks whether the class has a mapped embedded document for the specified field |
||
1698 | * and if yes, checks whether it is a collection-valued association (to-many). |
||
1699 | * |
||
1700 | * @param string $fieldName |
||
1701 | * @return boolean TRUE if the association exists and is collection-valued, FALSE otherwise. |
||
1702 | */ |
||
1703 | public function isCollectionValuedEmbed($fieldName) |
||
1708 | |||
1709 | /** |
||
1710 | * Sets the ID generator used to generate IDs for instances of this class. |
||
1711 | * |
||
1712 | * @param \Doctrine\ODM\MongoDB\Id\AbstractIdGenerator $generator |
||
1713 | */ |
||
1714 | 861 | public function setIdGenerator($generator) |
|
1718 | |||
1719 | /** |
||
1720 | * Casts the identifier to its portable PHP type. |
||
1721 | * |
||
1722 | * @param mixed $id |
||
1723 | * @return mixed $id |
||
1724 | */ |
||
1725 | 672 | public function getPHPIdentifierValue($id) |
|
1730 | |||
1731 | /** |
||
1732 | * Casts the identifier to its database type. |
||
1733 | * |
||
1734 | * @param mixed $id |
||
1735 | * @return mixed $id |
||
1736 | */ |
||
1737 | 742 | public function getDatabaseIdentifierValue($id) |
|
1742 | |||
1743 | /** |
||
1744 | * Sets the document identifier of a document. |
||
1745 | * |
||
1746 | * The value will be converted to a PHP type before being set. |
||
1747 | * |
||
1748 | * @param object $document |
||
1749 | * @param mixed $id |
||
1750 | */ |
||
1751 | 598 | public function setIdentifierValue($document, $id) |
|
1756 | |||
1757 | /** |
||
1758 | * Gets the document identifier as a PHP type. |
||
1759 | * |
||
1760 | * @param object $document |
||
1761 | * @return mixed $id |
||
1762 | */ |
||
1763 | 687 | public function getIdentifierValue($document) |
|
1767 | |||
1768 | /** |
||
1769 | * {@inheritDoc} |
||
1770 | * |
||
1771 | * Since MongoDB only allows exactly one identifier field this is a proxy |
||
1772 | * to {@see getIdentifierValue()} and returns an array with the identifier |
||
1773 | * field as a key. |
||
1774 | */ |
||
1775 | public function getIdentifierValues($object) |
||
1779 | |||
1780 | /** |
||
1781 | * Get the document identifier object as a database type. |
||
1782 | * |
||
1783 | * @param object $document |
||
1784 | * |
||
1785 | * @return \MongoId $id The MongoID object. |
||
1786 | */ |
||
1787 | 36 | public function getIdentifierObject($document) |
|
1791 | |||
1792 | /** |
||
1793 | * Sets the specified field to the specified value on the given document. |
||
1794 | * |
||
1795 | * @param object $document |
||
1796 | * @param string $field |
||
1797 | * @param mixed $value |
||
1798 | */ |
||
1799 | 11 | public function setFieldValue($document, $field, $value) |
|
1809 | |||
1810 | /** |
||
1811 | * Gets the specified field's value off the given document. |
||
1812 | * |
||
1813 | * @param object $document |
||
1814 | * @param string $field |
||
1815 | * |
||
1816 | * @return mixed |
||
1817 | */ |
||
1818 | 31 | public function getFieldValue($document, $field) |
|
1826 | |||
1827 | /** |
||
1828 | * Gets the mapping of a field. |
||
1829 | * |
||
1830 | * @param string $fieldName The field name. |
||
1831 | * |
||
1832 | * @return array The field mapping. |
||
1833 | * |
||
1834 | * @throws MappingException if the $fieldName is not found in the fieldMappings array |
||
1835 | */ |
||
1836 | 179 | public function getFieldMapping($fieldName) |
|
1843 | |||
1844 | /** |
||
1845 | * Gets mappings of fields holding embedded document(s). |
||
1846 | * |
||
1847 | * @return array of field mappings |
||
1848 | */ |
||
1849 | 641 | public function getEmbeddedFieldsMappings() |
|
1856 | |||
1857 | /** |
||
1858 | * Gets the field mapping by its DB name. |
||
1859 | * E.g. it returns identifier's mapping when called with _id. |
||
1860 | * |
||
1861 | * @param string $dbFieldName |
||
1862 | * |
||
1863 | * @return array |
||
1864 | * @throws MappingException |
||
1865 | */ |
||
1866 | 9 | public function getFieldMappingByDbFieldName($dbFieldName) |
|
1876 | |||
1877 | /** |
||
1878 | * Check if the field is not null. |
||
1879 | * |
||
1880 | * @param string $fieldName The field name |
||
1881 | * |
||
1882 | * @return boolean TRUE if the field is not null, FALSE otherwise. |
||
1883 | */ |
||
1884 | 1 | public function isNullable($fieldName) |
|
1892 | |||
1893 | /** |
||
1894 | * Checks whether the document has a discriminator field and value configured. |
||
1895 | * |
||
1896 | * @return boolean |
||
1897 | */ |
||
1898 | 521 | public function hasDiscriminator() |
|
1902 | |||
1903 | /** |
||
1904 | * Sets the type of Id generator to use for the mapped class. |
||
1905 | * |
||
1906 | * @param string $generatorType Generator type. |
||
1907 | */ |
||
1908 | 390 | public function setIdGeneratorType($generatorType) |
|
1912 | |||
1913 | /** |
||
1914 | * Sets the Id generator options. |
||
1915 | * |
||
1916 | * @param array $generatorOptions Generator options. |
||
1917 | */ |
||
1918 | public function setIdGeneratorOptions($generatorOptions) |
||
1922 | |||
1923 | /** |
||
1924 | * @return boolean |
||
1925 | */ |
||
1926 | 648 | public function isInheritanceTypeNone() |
|
1930 | |||
1931 | /** |
||
1932 | * Checks whether the mapped class uses the SINGLE_COLLECTION inheritance mapping strategy. |
||
1933 | * |
||
1934 | * @return boolean |
||
1935 | */ |
||
1936 | 383 | public function isInheritanceTypeSingleCollection() |
|
1940 | |||
1941 | /** |
||
1942 | * Checks whether the mapped class uses the COLLECTION_PER_CLASS inheritance mapping strategy. |
||
1943 | * |
||
1944 | * @return boolean |
||
1945 | */ |
||
1946 | public function isInheritanceTypeCollectionPerClass() |
||
1950 | |||
1951 | /** |
||
1952 | * Sets the mapped subclasses of this class. |
||
1953 | * |
||
1954 | * @param string[] $subclasses The names of all mapped subclasses. |
||
1955 | */ |
||
1956 | 2 | public function setSubclasses(array $subclasses) |
|
1966 | |||
1967 | /** |
||
1968 | * Sets the parent class names. |
||
1969 | * Assumes that the class names in the passed array are in the order: |
||
1970 | * directParent -> directParentParent -> directParentParentParent ... -> root. |
||
1971 | * |
||
1972 | * @param string[] $classNames |
||
1973 | */ |
||
1974 | 919 | public function setParentClasses(array $classNames) |
|
1982 | |||
1983 | /** |
||
1984 | * Checks whether the class will generate a new \MongoId instance for us. |
||
1985 | * |
||
1986 | * @return boolean TRUE if the class uses the AUTO generator, FALSE otherwise. |
||
1987 | */ |
||
1988 | public function isIdGeneratorAuto() |
||
1992 | |||
1993 | /** |
||
1994 | * Checks whether the class will use a collection to generate incremented identifiers. |
||
1995 | * |
||
1996 | * @return boolean TRUE if the class uses the INCREMENT generator, FALSE otherwise. |
||
1997 | */ |
||
1998 | public function isIdGeneratorIncrement() |
||
2002 | |||
2003 | /** |
||
2004 | * Checks whether the class will generate a uuid id. |
||
2005 | * |
||
2006 | * @return boolean TRUE if the class uses the UUID generator, FALSE otherwise. |
||
2007 | */ |
||
2008 | public function isIdGeneratorUuid() |
||
2012 | |||
2013 | /** |
||
2014 | * Checks whether the class uses no id generator. |
||
2015 | * |
||
2016 | * @return boolean TRUE if the class does not use any id generator, FALSE otherwise. |
||
2017 | */ |
||
2018 | public function isIdGeneratorNone() |
||
2022 | |||
2023 | /** |
||
2024 | * Sets the version field mapping used for versioning. Sets the default |
||
2025 | * value to use depending on the column type. |
||
2026 | * |
||
2027 | * @param array $mapping The version field mapping array |
||
2028 | * |
||
2029 | * @throws LockException |
||
2030 | */ |
||
2031 | 102 | public function setVersionMapping(array &$mapping) |
|
2040 | |||
2041 | /** |
||
2042 | * Sets whether this class is to be versioned for optimistic locking. |
||
2043 | * |
||
2044 | * @param boolean $bool |
||
2045 | */ |
||
2046 | 384 | public function setVersioned($bool) |
|
2050 | |||
2051 | /** |
||
2052 | * Sets the name of the field that is to be used for versioning if this class is |
||
2053 | * versioned for optimistic locking. |
||
2054 | * |
||
2055 | * @param string $versionField |
||
2056 | */ |
||
2057 | 384 | public function setVersionField($versionField) |
|
2061 | |||
2062 | /** |
||
2063 | * Sets the version field mapping used for versioning. Sets the default |
||
2064 | * value to use depending on the column type. |
||
2065 | * |
||
2066 | * @param array $mapping The version field mapping array |
||
2067 | * |
||
2068 | * @throws \Doctrine\ODM\MongoDB\LockException |
||
2069 | */ |
||
2070 | 27 | public function setLockMapping(array &$mapping) |
|
2079 | |||
2080 | /** |
||
2081 | * Sets whether this class is to allow pessimistic locking. |
||
2082 | * |
||
2083 | * @param boolean $bool |
||
2084 | */ |
||
2085 | public function setLockable($bool) |
||
2089 | |||
2090 | /** |
||
2091 | * Sets the name of the field that is to be used for storing whether a document |
||
2092 | * is currently locked or not. |
||
2093 | * |
||
2094 | * @param string $lockField |
||
2095 | */ |
||
2096 | public function setLockField($lockField) |
||
2100 | |||
2101 | /** |
||
2102 | * Marks this class as read only, no change tracking is applied to it. |
||
2103 | */ |
||
2104 | 9 | public function markReadOnly() |
|
2108 | |||
2109 | /** |
||
2110 | * {@inheritDoc} |
||
2111 | */ |
||
2112 | public function getFieldNames() |
||
2116 | |||
2117 | /** |
||
2118 | * {@inheritDoc} |
||
2119 | */ |
||
2120 | public function getAssociationNames() |
||
2124 | |||
2125 | /** |
||
2126 | * {@inheritDoc} |
||
2127 | */ |
||
2128 | 22 | public function getTypeOfField($fieldName) |
|
2133 | |||
2134 | /** |
||
2135 | * {@inheritDoc} |
||
2136 | */ |
||
2137 | 6 | public function getAssociationTargetClass($assocName) |
|
2145 | |||
2146 | /** |
||
2147 | * Retrieve the collectionClass associated with an association |
||
2148 | * |
||
2149 | * @param string $assocName |
||
2150 | */ |
||
2151 | 2 | public function getAssociationCollectionClass($assocName) |
|
2163 | |||
2164 | /** |
||
2165 | * {@inheritDoc} |
||
2166 | */ |
||
2167 | public function isAssociationInverseSide($fieldName) |
||
2171 | |||
2172 | /** |
||
2173 | * {@inheritDoc} |
||
2174 | */ |
||
2175 | public function getAssociationMappedByTargetField($fieldName) |
||
2179 | } |
||
2180 |
Let’s assume you have a class which uses late-static binding:
}
The code above will run fine in your PHP runtime. However, if you now create a sub-class and call the
getSomeVariable()
on that sub-class, you will receive a runtime error:In the case above, it makes sense to update
SomeClass
to useself
instead: