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: Whether or not queries on this document should require indexes. |
||
244 | * |
||
245 | * @deprecated property was deprecated in 1.2 and will be removed in 2.0 |
||
246 | */ |
||
247 | public $requireIndexes = false; |
||
248 | |||
249 | /** |
||
250 | * READ-ONLY: The name of the document class. |
||
251 | */ |
||
252 | public $name; |
||
253 | |||
254 | /** |
||
255 | * READ-ONLY: The namespace the document class is contained in. |
||
256 | * |
||
257 | * @var string |
||
258 | * @todo Not really needed. Usage could be localized. |
||
259 | */ |
||
260 | public $namespace; |
||
261 | |||
262 | /** |
||
263 | * READ-ONLY: The name of the document class that is at the root of the mapped document inheritance |
||
264 | * hierarchy. If the document is not part of a mapped inheritance hierarchy this is the same |
||
265 | * as {@link $documentName}. |
||
266 | * |
||
267 | * @var string |
||
268 | */ |
||
269 | public $rootDocumentName; |
||
270 | |||
271 | /** |
||
272 | * The name of the custom repository class used for the document class. |
||
273 | * (Optional). |
||
274 | * |
||
275 | * @var string |
||
276 | */ |
||
277 | public $customRepositoryClassName; |
||
278 | |||
279 | /** |
||
280 | * READ-ONLY: The names of the parent classes (ancestors). |
||
281 | * |
||
282 | * @var array |
||
283 | */ |
||
284 | public $parentClasses = array(); |
||
285 | |||
286 | /** |
||
287 | * READ-ONLY: The names of all subclasses (descendants). |
||
288 | * |
||
289 | * @var array |
||
290 | */ |
||
291 | public $subClasses = array(); |
||
292 | |||
293 | /** |
||
294 | * The ReflectionProperty instances of the mapped class. |
||
295 | * |
||
296 | * @var \ReflectionProperty[] |
||
297 | */ |
||
298 | public $reflFields = array(); |
||
299 | |||
300 | /** |
||
301 | * READ-ONLY: The inheritance mapping type used by the class. |
||
302 | * |
||
303 | * @var integer |
||
304 | */ |
||
305 | public $inheritanceType = self::INHERITANCE_TYPE_NONE; |
||
306 | |||
307 | /** |
||
308 | * READ-ONLY: The Id generator type used by the class. |
||
309 | * |
||
310 | * @var string |
||
311 | */ |
||
312 | public $generatorType = self::GENERATOR_TYPE_AUTO; |
||
313 | |||
314 | /** |
||
315 | * READ-ONLY: The Id generator options. |
||
316 | * |
||
317 | * @var array |
||
318 | */ |
||
319 | public $generatorOptions = array(); |
||
320 | |||
321 | /** |
||
322 | * READ-ONLY: The ID generator used for generating IDs for this class. |
||
323 | * |
||
324 | * @var \Doctrine\ODM\MongoDB\Id\AbstractIdGenerator |
||
325 | */ |
||
326 | public $idGenerator; |
||
327 | |||
328 | /** |
||
329 | * READ-ONLY: The field mappings of the class. |
||
330 | * Keys are field names and values are mapping definitions. |
||
331 | * |
||
332 | * The mapping definition array has the following values: |
||
333 | * |
||
334 | * - <b>fieldName</b> (string) |
||
335 | * The name of the field in the Document. |
||
336 | * |
||
337 | * - <b>id</b> (boolean, optional) |
||
338 | * Marks the field as the primary key of the document. Multiple fields of an |
||
339 | * document can have the id attribute, forming a composite key. |
||
340 | * |
||
341 | * @var array |
||
342 | */ |
||
343 | public $fieldMappings = array(); |
||
344 | |||
345 | /** |
||
346 | * READ-ONLY: The association mappings of the class. |
||
347 | * Keys are field names and values are mapping definitions. |
||
348 | * |
||
349 | * @var array |
||
350 | */ |
||
351 | public $associationMappings = array(); |
||
352 | |||
353 | /** |
||
354 | * READ-ONLY: Array of fields to also load with a given method. |
||
355 | * |
||
356 | * @var array |
||
357 | */ |
||
358 | public $alsoLoadMethods = array(); |
||
359 | |||
360 | /** |
||
361 | * READ-ONLY: The registered lifecycle callbacks for documents of this class. |
||
362 | * |
||
363 | * @var array |
||
364 | */ |
||
365 | public $lifecycleCallbacks = array(); |
||
366 | |||
367 | /** |
||
368 | * READ-ONLY: The discriminator value of this class. |
||
369 | * |
||
370 | * <b>This does only apply to the JOINED and SINGLE_COLLECTION inheritance mapping strategies |
||
371 | * where a discriminator field is used.</b> |
||
372 | * |
||
373 | * @var mixed |
||
374 | * @see discriminatorField |
||
375 | */ |
||
376 | public $discriminatorValue; |
||
377 | |||
378 | /** |
||
379 | * READ-ONLY: The discriminator map of all mapped classes in the hierarchy. |
||
380 | * |
||
381 | * <b>This does only apply to the SINGLE_COLLECTION inheritance mapping strategy |
||
382 | * where a discriminator field is used.</b> |
||
383 | * |
||
384 | * @var mixed |
||
385 | * @see discriminatorField |
||
386 | */ |
||
387 | public $discriminatorMap = array(); |
||
388 | |||
389 | /** |
||
390 | * READ-ONLY: The definition of the discriminator field used in SINGLE_COLLECTION |
||
391 | * inheritance mapping. |
||
392 | * |
||
393 | * @var string |
||
394 | */ |
||
395 | public $discriminatorField; |
||
396 | |||
397 | /** |
||
398 | * READ-ONLY: The default value for discriminatorField in case it's not set in the document |
||
399 | * |
||
400 | * @var string |
||
401 | * @see discriminatorField |
||
402 | */ |
||
403 | public $defaultDiscriminatorValue; |
||
404 | |||
405 | /** |
||
406 | * READ-ONLY: Whether this class describes the mapping of a mapped superclass. |
||
407 | * |
||
408 | * @var boolean |
||
409 | */ |
||
410 | public $isMappedSuperclass = false; |
||
411 | |||
412 | /** |
||
413 | * READ-ONLY: Whether this class describes the mapping of a embedded document. |
||
414 | * |
||
415 | * @var boolean |
||
416 | */ |
||
417 | public $isEmbeddedDocument = false; |
||
418 | |||
419 | /** |
||
420 | * READ-ONLY: Whether this class describes the mapping of an aggregation result document. |
||
421 | * |
||
422 | * @var boolean |
||
423 | */ |
||
424 | public $isQueryResultDocument = false; |
||
425 | |||
426 | /** |
||
427 | * READ-ONLY: The policy used for change-tracking on entities of this class. |
||
428 | * |
||
429 | * @var integer |
||
430 | */ |
||
431 | public $changeTrackingPolicy = self::CHANGETRACKING_DEFERRED_IMPLICIT; |
||
432 | |||
433 | /** |
||
434 | * READ-ONLY: A flag for whether or not instances of this class are to be versioned |
||
435 | * with optimistic locking. |
||
436 | * |
||
437 | * @var boolean $isVersioned |
||
438 | */ |
||
439 | public $isVersioned; |
||
440 | |||
441 | /** |
||
442 | * READ-ONLY: The name of the field which is used for versioning in optimistic locking (if any). |
||
443 | * |
||
444 | * @var mixed $versionField |
||
445 | */ |
||
446 | public $versionField; |
||
447 | |||
448 | /** |
||
449 | * READ-ONLY: A flag for whether or not instances of this class are to allow pessimistic |
||
450 | * locking. |
||
451 | * |
||
452 | * @var boolean $isLockable |
||
453 | */ |
||
454 | public $isLockable; |
||
455 | |||
456 | /** |
||
457 | * READ-ONLY: The name of the field which is used for locking a document. |
||
458 | * |
||
459 | * @var mixed $lockField |
||
460 | */ |
||
461 | public $lockField; |
||
462 | |||
463 | /** |
||
464 | * The ReflectionClass instance of the mapped class. |
||
465 | * |
||
466 | * @var \ReflectionClass |
||
467 | */ |
||
468 | public $reflClass; |
||
469 | |||
470 | /** |
||
471 | * READ_ONLY: A flag for whether or not this document is read-only. |
||
472 | * |
||
473 | * @var bool |
||
474 | */ |
||
475 | public $isReadOnly; |
||
476 | |||
477 | /** |
||
478 | * Initializes a new ClassMetadata instance that will hold the object-document mapping |
||
479 | * metadata of the class with the given name. |
||
480 | * |
||
481 | * @param string $documentName The name of the document class the new instance is used for. |
||
482 | */ |
||
483 | 1005 | public function __construct($documentName) |
|
488 | |||
489 | /** |
||
490 | * Helper method to get reference id of ref* type references |
||
491 | * @param mixed $reference |
||
492 | * @param string $storeAs |
||
493 | * @return mixed |
||
494 | * @internal |
||
495 | */ |
||
496 | 117 | public static function getReferenceId($reference, $storeAs) |
|
500 | |||
501 | /** |
||
502 | * Returns the reference prefix used for a reference |
||
503 | * @param string $storeAs |
||
504 | * @return string |
||
505 | */ |
||
506 | 196 | private static function getReferencePrefix($storeAs) |
|
514 | |||
515 | /** |
||
516 | * Returns a fully qualified field name for a given reference |
||
517 | * @param string $storeAs |
||
518 | * @param string $pathPrefix The field path prefix |
||
519 | * @return string |
||
520 | * @internal |
||
521 | */ |
||
522 | 142 | public static function getReferenceFieldName($storeAs, $pathPrefix = '') |
|
530 | |||
531 | /** |
||
532 | * {@inheritDoc} |
||
533 | */ |
||
534 | 933 | public function getReflectionClass() |
|
542 | |||
543 | /** |
||
544 | * {@inheritDoc} |
||
545 | */ |
||
546 | 337 | public function isIdentifier($fieldName) |
|
550 | |||
551 | /** |
||
552 | * INTERNAL: |
||
553 | * Sets the mapped identifier field of this class. |
||
554 | * |
||
555 | * @param string $identifier |
||
556 | */ |
||
557 | 378 | public function setIdentifier($identifier) |
|
561 | |||
562 | /** |
||
563 | * {@inheritDoc} |
||
564 | * |
||
565 | * Since MongoDB only allows exactly one identifier field |
||
566 | * this will always return an array with only one value |
||
567 | */ |
||
568 | 40 | public function getIdentifier() |
|
572 | |||
573 | /** |
||
574 | * {@inheritDoc} |
||
575 | * |
||
576 | * Since MongoDB only allows exactly one identifier field |
||
577 | * this will always return an array with only one value |
||
578 | */ |
||
579 | 98 | public function getIdentifierFieldNames() |
|
583 | |||
584 | /** |
||
585 | * {@inheritDoc} |
||
586 | */ |
||
587 | 573 | public function hasField($fieldName) |
|
591 | |||
592 | /** |
||
593 | * Sets the inheritance type used by the class and it's subclasses. |
||
594 | * |
||
595 | * @param integer $type |
||
596 | */ |
||
597 | 394 | public function setInheritanceType($type) |
|
601 | |||
602 | /** |
||
603 | * Checks whether a mapped field is inherited from an entity superclass. |
||
604 | * |
||
605 | * @param string $fieldName |
||
606 | * |
||
607 | * @return boolean TRUE if the field is inherited, FALSE otherwise. |
||
608 | */ |
||
609 | 933 | public function isInheritedField($fieldName) |
|
613 | |||
614 | /** |
||
615 | * Registers a custom repository class for the document class. |
||
616 | * |
||
617 | * @param string $repositoryClassName The class name of the custom repository. |
||
618 | */ |
||
619 | 326 | public function setCustomRepositoryClass($repositoryClassName) |
|
631 | |||
632 | /** |
||
633 | * Dispatches the lifecycle event of the given document by invoking all |
||
634 | * registered callbacks. |
||
635 | * |
||
636 | * @param string $event Lifecycle event |
||
637 | * @param object $document Document on which the event occurred |
||
638 | * @param array $arguments Arguments to pass to all callbacks |
||
639 | * @throws \InvalidArgumentException if document class is not this class or |
||
640 | * a Proxy of this class |
||
641 | */ |
||
642 | 681 | public function invokeLifecycleCallbacks($event, $document, array $arguments = null) |
|
660 | |||
661 | /** |
||
662 | * Checks whether the class has callbacks registered for a lifecycle event. |
||
663 | * |
||
664 | * @param string $event Lifecycle event |
||
665 | * |
||
666 | * @return boolean |
||
667 | */ |
||
668 | public function hasLifecycleCallbacks($event) |
||
672 | |||
673 | /** |
||
674 | * Gets the registered lifecycle callbacks for an event. |
||
675 | * |
||
676 | * @param string $event |
||
677 | * @return array |
||
678 | */ |
||
679 | public function getLifecycleCallbacks($event) |
||
683 | |||
684 | /** |
||
685 | * Adds a lifecycle callback for documents of this class. |
||
686 | * |
||
687 | * If the callback is already registered, this is a NOOP. |
||
688 | * |
||
689 | * @param string $callback |
||
690 | * @param string $event |
||
691 | */ |
||
692 | 304 | public function addLifecycleCallback($callback, $event) |
|
700 | |||
701 | /** |
||
702 | * Sets the lifecycle callbacks for documents of this class. |
||
703 | * |
||
704 | * Any previously registered callbacks are overwritten. |
||
705 | * |
||
706 | * @param array $callbacks |
||
707 | */ |
||
708 | 377 | public function setLifecycleCallbacks(array $callbacks) |
|
712 | |||
713 | /** |
||
714 | * Registers a method for loading document data before field hydration. |
||
715 | * |
||
716 | * Note: A method may be registered multiple times for different fields. |
||
717 | * it will be invoked only once for the first field found. |
||
718 | * |
||
719 | * @param string $method Method name |
||
720 | * @param array|string $fields Database field name(s) |
||
721 | */ |
||
722 | 15 | public function registerAlsoLoadMethod($method, $fields) |
|
726 | |||
727 | /** |
||
728 | * Sets the AlsoLoad methods for documents of this class. |
||
729 | * |
||
730 | * Any previously registered methods are overwritten. |
||
731 | * |
||
732 | * @param array $methods |
||
733 | */ |
||
734 | 377 | public function setAlsoLoadMethods(array $methods) |
|
738 | |||
739 | /** |
||
740 | * Sets the discriminator field. |
||
741 | * |
||
742 | * The field name is the the unmapped database field. Discriminator values |
||
743 | * are only used to discern the hydration class and are not mapped to class |
||
744 | * properties. |
||
745 | * |
||
746 | * @param string $discriminatorField |
||
747 | * |
||
748 | * @throws MappingException If the discriminator field conflicts with the |
||
749 | * "name" attribute of a mapped field. |
||
750 | */ |
||
751 | 407 | public function setDiscriminatorField($discriminatorField) |
|
776 | |||
777 | /** |
||
778 | * Sets the discriminator values used by this class. |
||
779 | * Used for JOINED and SINGLE_TABLE inheritance mapping strategies. |
||
780 | * |
||
781 | * @param array $map |
||
782 | * |
||
783 | * @throws MappingException |
||
784 | */ |
||
785 | 400 | public function setDiscriminatorMap(array $map) |
|
804 | |||
805 | /** |
||
806 | * Sets the default discriminator value to be used for this class |
||
807 | * Used for JOINED and SINGLE_TABLE inheritance mapping strategies if the document has no discriminator value |
||
808 | * |
||
809 | * @param string $defaultDiscriminatorValue |
||
810 | * |
||
811 | * @throws MappingException |
||
812 | */ |
||
813 | 384 | public function setDefaultDiscriminatorValue($defaultDiscriminatorValue) |
|
827 | |||
828 | /** |
||
829 | * Sets the discriminator value for this class. |
||
830 | * Used for JOINED/SINGLE_TABLE inheritance and multiple document types in a single |
||
831 | * collection. |
||
832 | * |
||
833 | * @param string $value |
||
834 | */ |
||
835 | 3 | public function setDiscriminatorValue($value) |
|
840 | |||
841 | /** |
||
842 | * Sets the slaveOkay option applied to collections for this class. |
||
843 | * |
||
844 | * @param boolean|null $slaveOkay |
||
845 | * |
||
846 | * @deprecated in version 1.2 and will be removed in 2.0. |
||
847 | */ |
||
848 | 3 | public function setSlaveOkay($slaveOkay) |
|
856 | |||
857 | /** |
||
858 | * Add a index for this Document. |
||
859 | * |
||
860 | * @param array $keys Array of keys for the index. |
||
861 | * @param array $options Array of options for the index. |
||
862 | */ |
||
863 | 235 | public function addIndex($keys, array $options = array()) |
|
883 | |||
884 | /** |
||
885 | * Set whether or not queries on this document should require indexes. |
||
886 | * |
||
887 | * @param bool $requireIndexes |
||
888 | * |
||
889 | * @deprecated method was deprecated in 1.2 and will be removed in 2.0 |
||
890 | */ |
||
891 | 924 | public function setRequireIndexes($requireIndexes) |
|
899 | |||
900 | /** |
||
901 | * Returns the array of indexes for this Document. |
||
902 | * |
||
903 | * @return array $indexes The array of indexes. |
||
904 | */ |
||
905 | 54 | public function getIndexes() |
|
909 | |||
910 | /** |
||
911 | * Checks whether this document has indexes or not. |
||
912 | * |
||
913 | * @return boolean |
||
914 | */ |
||
915 | public function hasIndexes() |
||
919 | |||
920 | /** |
||
921 | * Set shard key for this Document. |
||
922 | * |
||
923 | * @param array $keys Array of document keys. |
||
924 | * @param array $options Array of sharding options. |
||
925 | * |
||
926 | * @throws MappingException |
||
927 | */ |
||
928 | 87 | public function setShardKey(array $keys, array $options = array()) |
|
970 | |||
971 | /** |
||
972 | * @return array |
||
973 | */ |
||
974 | 28 | public function getShardKey() |
|
978 | |||
979 | /** |
||
980 | * Checks whether this document has shard key or not. |
||
981 | * |
||
982 | * @return bool |
||
983 | */ |
||
984 | 620 | public function isSharded() |
|
988 | |||
989 | /** |
||
990 | * Sets the read preference used by this class. |
||
991 | * |
||
992 | * @param string $readPreference |
||
993 | * @param array|null $tags |
||
994 | */ |
||
995 | 381 | public function setReadPreference($readPreference, $tags) |
|
1000 | |||
1001 | /** |
||
1002 | * Sets the write concern used by this class. |
||
1003 | * |
||
1004 | * @param string $writeConcern |
||
1005 | */ |
||
1006 | 391 | public function setWriteConcern($writeConcern) |
|
1010 | |||
1011 | /** |
||
1012 | * @return string |
||
1013 | */ |
||
1014 | 12 | public function getWriteConcern() |
|
1018 | |||
1019 | /** |
||
1020 | * Whether there is a write concern configured for this class. |
||
1021 | * |
||
1022 | * @return bool |
||
1023 | */ |
||
1024 | 625 | public function hasWriteConcern() |
|
1028 | |||
1029 | /** |
||
1030 | * Sets the change tracking policy used by this class. |
||
1031 | * |
||
1032 | * @param integer $policy |
||
1033 | */ |
||
1034 | 382 | public function setChangeTrackingPolicy($policy) |
|
1038 | |||
1039 | /** |
||
1040 | * Whether the change tracking policy of this class is "deferred explicit". |
||
1041 | * |
||
1042 | * @return boolean |
||
1043 | */ |
||
1044 | 75 | public function isChangeTrackingDeferredExplicit() |
|
1048 | |||
1049 | /** |
||
1050 | * Whether the change tracking policy of this class is "deferred implicit". |
||
1051 | * |
||
1052 | * @return boolean |
||
1053 | */ |
||
1054 | 646 | public function isChangeTrackingDeferredImplicit() |
|
1058 | |||
1059 | /** |
||
1060 | * Whether the change tracking policy of this class is "notify". |
||
1061 | * |
||
1062 | * @return boolean |
||
1063 | */ |
||
1064 | 352 | public function isChangeTrackingNotify() |
|
1068 | |||
1069 | /** |
||
1070 | * Gets the ReflectionProperties of the mapped class. |
||
1071 | * |
||
1072 | * @return array An array of ReflectionProperty instances. |
||
1073 | */ |
||
1074 | 98 | public function getReflectionProperties() |
|
1078 | |||
1079 | /** |
||
1080 | * Gets a ReflectionProperty for a specific field of the mapped class. |
||
1081 | * |
||
1082 | * @param string $name |
||
1083 | * |
||
1084 | * @return \ReflectionProperty |
||
1085 | */ |
||
1086 | public function getReflectionProperty($name) |
||
1090 | |||
1091 | /** |
||
1092 | * {@inheritDoc} |
||
1093 | */ |
||
1094 | 939 | public function getName() |
|
1098 | |||
1099 | /** |
||
1100 | * The namespace this Document class belongs to. |
||
1101 | * |
||
1102 | * @return string $namespace The namespace name. |
||
1103 | */ |
||
1104 | public function getNamespace() |
||
1108 | |||
1109 | /** |
||
1110 | * Returns the database this Document is mapped to. |
||
1111 | * |
||
1112 | * @return string $db The database name. |
||
1113 | */ |
||
1114 | 857 | public function getDatabase() |
|
1118 | |||
1119 | /** |
||
1120 | * Set the database this Document is mapped to. |
||
1121 | * |
||
1122 | * @param string $db The database name |
||
1123 | */ |
||
1124 | 104 | public function setDatabase($db) |
|
1128 | |||
1129 | /** |
||
1130 | * Get the collection this Document is mapped to. |
||
1131 | * |
||
1132 | * @return string $collection The collection name. |
||
1133 | */ |
||
1134 | 862 | public function getCollection() |
|
1138 | |||
1139 | /** |
||
1140 | * Sets the collection this Document is mapped to. |
||
1141 | * |
||
1142 | * @param array|string $name |
||
1143 | * |
||
1144 | * @throws \InvalidArgumentException |
||
1145 | */ |
||
1146 | 969 | public function setCollection($name) |
|
1160 | |||
1161 | /** |
||
1162 | * Get whether or not the documents collection is capped. |
||
1163 | * |
||
1164 | * @return boolean |
||
1165 | */ |
||
1166 | 4 | public function getCollectionCapped() |
|
1170 | |||
1171 | /** |
||
1172 | * Set whether or not the documents collection is capped. |
||
1173 | * |
||
1174 | * @param boolean $bool |
||
1175 | */ |
||
1176 | 1 | public function setCollectionCapped($bool) |
|
1180 | |||
1181 | /** |
||
1182 | * Get the collection size |
||
1183 | * |
||
1184 | * @return integer |
||
1185 | */ |
||
1186 | 4 | public function getCollectionSize() |
|
1190 | |||
1191 | /** |
||
1192 | * Set the collection size. |
||
1193 | * |
||
1194 | * @param integer $size |
||
1195 | */ |
||
1196 | 1 | public function setCollectionSize($size) |
|
1200 | |||
1201 | /** |
||
1202 | * Get the collection max. |
||
1203 | * |
||
1204 | * @return integer |
||
1205 | */ |
||
1206 | 4 | public function getCollectionMax() |
|
1210 | |||
1211 | /** |
||
1212 | * Set the collection max. |
||
1213 | * |
||
1214 | * @param integer $max |
||
1215 | */ |
||
1216 | 1 | public function setCollectionMax($max) |
|
1220 | |||
1221 | /** |
||
1222 | * Returns TRUE if this Document is mapped to a collection FALSE otherwise. |
||
1223 | * |
||
1224 | * @return boolean |
||
1225 | */ |
||
1226 | public function isMappedToCollection() |
||
1230 | |||
1231 | /** |
||
1232 | * Returns TRUE if this Document is a file to be stored on the MongoGridFS FALSE otherwise. |
||
1233 | * |
||
1234 | * @return boolean |
||
1235 | */ |
||
1236 | 803 | public function isFile() |
|
1240 | |||
1241 | /** |
||
1242 | * Returns the file field name. |
||
1243 | * |
||
1244 | * @return string $file The file field name. |
||
1245 | */ |
||
1246 | 377 | public function getFile() |
|
1250 | |||
1251 | /** |
||
1252 | * Set the field name that stores the grid file. |
||
1253 | * |
||
1254 | * @param string $file |
||
1255 | */ |
||
1256 | 378 | public function setFile($file) |
|
1260 | |||
1261 | /** |
||
1262 | * Returns the distance field name. |
||
1263 | * |
||
1264 | * @return string $distance The distance field name. |
||
1265 | */ |
||
1266 | public function getDistance() |
||
1270 | |||
1271 | /** |
||
1272 | * Set the field name that stores the distance. |
||
1273 | * |
||
1274 | * @param string $distance |
||
1275 | */ |
||
1276 | 1 | public function setDistance($distance) |
|
1280 | |||
1281 | /** |
||
1282 | * Map a field. |
||
1283 | * |
||
1284 | * @param array $mapping The mapping information. |
||
1285 | * |
||
1286 | * @return array |
||
1287 | * |
||
1288 | * @throws MappingException |
||
1289 | */ |
||
1290 | 983 | public function mapField(array $mapping) |
|
1484 | |||
1485 | /** |
||
1486 | * Validates the storage strategy of a mapping for consistency |
||
1487 | * @param array $mapping |
||
1488 | * @throws \Doctrine\ODM\MongoDB\Mapping\MappingException |
||
1489 | */ |
||
1490 | 971 | private function applyStorageStrategy(array &$mapping) |
|
1534 | |||
1535 | /** |
||
1536 | * Map a MongoGridFSFile. |
||
1537 | * |
||
1538 | * @param array $mapping The mapping information. |
||
1539 | */ |
||
1540 | public function mapFile(array $mapping) |
||
1546 | |||
1547 | /** |
||
1548 | * Map a single embedded document. |
||
1549 | * |
||
1550 | * @param array $mapping The mapping information. |
||
1551 | */ |
||
1552 | 6 | public function mapOneEmbedded(array $mapping) |
|
1558 | |||
1559 | /** |
||
1560 | * Map a collection of embedded documents. |
||
1561 | * |
||
1562 | * @param array $mapping The mapping information. |
||
1563 | */ |
||
1564 | 5 | public function mapManyEmbedded(array $mapping) |
|
1570 | |||
1571 | /** |
||
1572 | * Map a single document reference. |
||
1573 | * |
||
1574 | * @param array $mapping The mapping information. |
||
1575 | */ |
||
1576 | 8 | public function mapOneReference(array $mapping) |
|
1582 | |||
1583 | /** |
||
1584 | * Map a collection of document references. |
||
1585 | * |
||
1586 | * @param array $mapping The mapping information. |
||
1587 | */ |
||
1588 | 8 | public function mapManyReference(array $mapping) |
|
1594 | |||
1595 | /** |
||
1596 | * INTERNAL: |
||
1597 | * Adds a field mapping without completing/validating it. |
||
1598 | * This is mainly used to add inherited field mappings to derived classes. |
||
1599 | * |
||
1600 | * @param array $fieldMapping |
||
1601 | */ |
||
1602 | 130 | public function addInheritedFieldMapping(array $fieldMapping) |
|
1610 | |||
1611 | /** |
||
1612 | * INTERNAL: |
||
1613 | * Adds an association mapping without completing/validating it. |
||
1614 | * This is mainly used to add inherited association mappings to derived classes. |
||
1615 | * |
||
1616 | * @param array $mapping |
||
1617 | * |
||
1618 | * @return void |
||
1619 | * |
||
1620 | * @throws MappingException |
||
1621 | */ |
||
1622 | 79 | public function addInheritedAssociationMapping(array $mapping/*, $owningClassName = null*/) |
|
1626 | |||
1627 | /** |
||
1628 | * Checks whether the class has a mapped association with the given field name. |
||
1629 | * |
||
1630 | * @param string $fieldName |
||
1631 | * @return boolean |
||
1632 | */ |
||
1633 | 17 | public function hasReference($fieldName) |
|
1637 | |||
1638 | /** |
||
1639 | * Checks whether the class has a mapped embed with the given field name. |
||
1640 | * |
||
1641 | * @param string $fieldName |
||
1642 | * @return boolean |
||
1643 | */ |
||
1644 | 5 | public function hasEmbed($fieldName) |
|
1648 | |||
1649 | /** |
||
1650 | * {@inheritDoc} |
||
1651 | * |
||
1652 | * Checks whether the class has a mapped association (embed or reference) with the given field name. |
||
1653 | */ |
||
1654 | 7 | public function hasAssociation($fieldName) |
|
1658 | |||
1659 | /** |
||
1660 | * {@inheritDoc} |
||
1661 | * |
||
1662 | * Checks whether the class has a mapped reference or embed for the specified field and |
||
1663 | * is a single valued association. |
||
1664 | */ |
||
1665 | public function isSingleValuedAssociation($fieldName) |
||
1669 | |||
1670 | /** |
||
1671 | * {@inheritDoc} |
||
1672 | * |
||
1673 | * Checks whether the class has a mapped reference or embed for the specified field and |
||
1674 | * is a collection valued association. |
||
1675 | */ |
||
1676 | public function isCollectionValuedAssociation($fieldName) |
||
1680 | |||
1681 | /** |
||
1682 | * Checks whether the class has a mapped association for the specified field |
||
1683 | * and if yes, checks whether it is a single-valued association (to-one). |
||
1684 | * |
||
1685 | * @param string $fieldName |
||
1686 | * @return boolean TRUE if the association exists and is single-valued, FALSE otherwise. |
||
1687 | */ |
||
1688 | public function isSingleValuedReference($fieldName) |
||
1693 | |||
1694 | /** |
||
1695 | * Checks whether the class has a mapped association for the specified field |
||
1696 | * and if yes, checks whether it is a collection-valued association (to-many). |
||
1697 | * |
||
1698 | * @param string $fieldName |
||
1699 | * @return boolean TRUE if the association exists and is collection-valued, FALSE otherwise. |
||
1700 | */ |
||
1701 | public function isCollectionValuedReference($fieldName) |
||
1706 | |||
1707 | /** |
||
1708 | * Checks whether the class has a mapped embedded document for the specified field |
||
1709 | * and if yes, checks whether it is a single-valued association (to-one). |
||
1710 | * |
||
1711 | * @param string $fieldName |
||
1712 | * @return boolean TRUE if the association exists and is single-valued, FALSE otherwise. |
||
1713 | */ |
||
1714 | public function isSingleValuedEmbed($fieldName) |
||
1719 | |||
1720 | /** |
||
1721 | * Checks whether the class has a mapped embedded document for the specified field |
||
1722 | * and if yes, checks whether it is a collection-valued association (to-many). |
||
1723 | * |
||
1724 | * @param string $fieldName |
||
1725 | * @return boolean TRUE if the association exists and is collection-valued, FALSE otherwise. |
||
1726 | */ |
||
1727 | public function isCollectionValuedEmbed($fieldName) |
||
1732 | |||
1733 | /** |
||
1734 | * Sets the ID generator used to generate IDs for instances of this class. |
||
1735 | * |
||
1736 | * @param \Doctrine\ODM\MongoDB\Id\AbstractIdGenerator $generator |
||
1737 | */ |
||
1738 | 872 | public function setIdGenerator($generator) |
|
1742 | |||
1743 | /** |
||
1744 | * Casts the identifier to its portable PHP type. |
||
1745 | * |
||
1746 | * @param mixed $id |
||
1747 | * @return mixed $id |
||
1748 | */ |
||
1749 | 668 | public function getPHPIdentifierValue($id) |
|
1754 | |||
1755 | /** |
||
1756 | * Casts the identifier to its database type. |
||
1757 | * |
||
1758 | * @param mixed $id |
||
1759 | * @return mixed $id |
||
1760 | */ |
||
1761 | 740 | public function getDatabaseIdentifierValue($id) |
|
1766 | |||
1767 | /** |
||
1768 | * Sets the document identifier of a document. |
||
1769 | * |
||
1770 | * The value will be converted to a PHP type before being set. |
||
1771 | * |
||
1772 | * @param object $document |
||
1773 | * @param mixed $id |
||
1774 | */ |
||
1775 | 594 | public function setIdentifierValue($document, $id) |
|
1780 | |||
1781 | /** |
||
1782 | * Gets the document identifier as a PHP type. |
||
1783 | * |
||
1784 | * @param object $document |
||
1785 | * @return mixed $id |
||
1786 | */ |
||
1787 | 685 | public function getIdentifierValue($document) |
|
1791 | |||
1792 | /** |
||
1793 | * {@inheritDoc} |
||
1794 | * |
||
1795 | * Since MongoDB only allows exactly one identifier field this is a proxy |
||
1796 | * to {@see getIdentifierValue()} and returns an array with the identifier |
||
1797 | * field as a key. |
||
1798 | */ |
||
1799 | public function getIdentifierValues($object) |
||
1803 | |||
1804 | /** |
||
1805 | * Get the document identifier object as a database type. |
||
1806 | * |
||
1807 | * @param object $document |
||
1808 | * |
||
1809 | * @return \MongoId $id The MongoID object. |
||
1810 | */ |
||
1811 | 36 | public function getIdentifierObject($document) |
|
1815 | |||
1816 | /** |
||
1817 | * Sets the specified field to the specified value on the given document. |
||
1818 | * |
||
1819 | * @param object $document |
||
1820 | * @param string $field |
||
1821 | * @param mixed $value |
||
1822 | */ |
||
1823 | 11 | public function setFieldValue($document, $field, $value) |
|
1833 | |||
1834 | /** |
||
1835 | * Gets the specified field's value off the given document. |
||
1836 | * |
||
1837 | * @param object $document |
||
1838 | * @param string $field |
||
1839 | * |
||
1840 | * @return mixed |
||
1841 | */ |
||
1842 | 31 | public function getFieldValue($document, $field) |
|
1850 | |||
1851 | /** |
||
1852 | * Gets the mapping of a field. |
||
1853 | * |
||
1854 | * @param string $fieldName The field name. |
||
1855 | * |
||
1856 | * @return array The field mapping. |
||
1857 | * |
||
1858 | * @throws MappingException if the $fieldName is not found in the fieldMappings array |
||
1859 | */ |
||
1860 | 201 | public function getFieldMapping($fieldName) |
|
1867 | |||
1868 | /** |
||
1869 | * Gets mappings of fields holding embedded document(s). |
||
1870 | * |
||
1871 | * @return array of field mappings |
||
1872 | */ |
||
1873 | 637 | public function getEmbeddedFieldsMappings() |
|
1880 | |||
1881 | /** |
||
1882 | * Gets the field mapping by its DB name. |
||
1883 | * E.g. it returns identifier's mapping when called with _id. |
||
1884 | * |
||
1885 | * @param string $dbFieldName |
||
1886 | * |
||
1887 | * @return array |
||
1888 | * @throws MappingException |
||
1889 | */ |
||
1890 | 9 | public function getFieldMappingByDbFieldName($dbFieldName) |
|
1900 | |||
1901 | /** |
||
1902 | * Check if the field is not null. |
||
1903 | * |
||
1904 | * @param string $fieldName The field name |
||
1905 | * |
||
1906 | * @return boolean TRUE if the field is not null, FALSE otherwise. |
||
1907 | */ |
||
1908 | 1 | public function isNullable($fieldName) |
|
1916 | |||
1917 | /** |
||
1918 | * Checks whether the document has a discriminator field and value configured. |
||
1919 | * |
||
1920 | * @return boolean |
||
1921 | */ |
||
1922 | 541 | public function hasDiscriminator() |
|
1926 | |||
1927 | /** |
||
1928 | * Sets the type of Id generator to use for the mapped class. |
||
1929 | * |
||
1930 | * @param string $generatorType Generator type. |
||
1931 | */ |
||
1932 | 383 | public function setIdGeneratorType($generatorType) |
|
1936 | |||
1937 | /** |
||
1938 | * Sets the Id generator options. |
||
1939 | * |
||
1940 | * @param array $generatorOptions Generator options. |
||
1941 | */ |
||
1942 | public function setIdGeneratorOptions($generatorOptions) |
||
1946 | |||
1947 | /** |
||
1948 | * @return boolean |
||
1949 | */ |
||
1950 | 644 | public function isInheritanceTypeNone() |
|
1954 | |||
1955 | /** |
||
1956 | * Checks whether the mapped class uses the SINGLE_COLLECTION inheritance mapping strategy. |
||
1957 | * |
||
1958 | * @return boolean |
||
1959 | */ |
||
1960 | 376 | public function isInheritanceTypeSingleCollection() |
|
1964 | |||
1965 | /** |
||
1966 | * Checks whether the mapped class uses the COLLECTION_PER_CLASS inheritance mapping strategy. |
||
1967 | * |
||
1968 | * @return boolean |
||
1969 | */ |
||
1970 | public function isInheritanceTypeCollectionPerClass() |
||
1974 | |||
1975 | /** |
||
1976 | * Sets the mapped subclasses of this class. |
||
1977 | * |
||
1978 | * @param string[] $subclasses The names of all mapped subclasses. |
||
1979 | */ |
||
1980 | 2 | public function setSubclasses(array $subclasses) |
|
1990 | |||
1991 | /** |
||
1992 | * Sets the parent class names. |
||
1993 | * Assumes that the class names in the passed array are in the order: |
||
1994 | * directParent -> directParentParent -> directParentParentParent ... -> root. |
||
1995 | * |
||
1996 | * @param string[] $classNames |
||
1997 | */ |
||
1998 | 930 | public function setParentClasses(array $classNames) |
|
2006 | |||
2007 | /** |
||
2008 | * Checks whether the class will generate a new \MongoId instance for us. |
||
2009 | * |
||
2010 | * @return boolean TRUE if the class uses the AUTO generator, FALSE otherwise. |
||
2011 | */ |
||
2012 | public function isIdGeneratorAuto() |
||
2016 | |||
2017 | /** |
||
2018 | * Checks whether the class will use a collection to generate incremented identifiers. |
||
2019 | * |
||
2020 | * @return boolean TRUE if the class uses the INCREMENT generator, FALSE otherwise. |
||
2021 | */ |
||
2022 | public function isIdGeneratorIncrement() |
||
2026 | |||
2027 | /** |
||
2028 | * Checks whether the class will generate a uuid id. |
||
2029 | * |
||
2030 | * @return boolean TRUE if the class uses the UUID generator, FALSE otherwise. |
||
2031 | */ |
||
2032 | public function isIdGeneratorUuid() |
||
2036 | |||
2037 | /** |
||
2038 | * Checks whether the class uses no id generator. |
||
2039 | * |
||
2040 | * @return boolean TRUE if the class does not use any id generator, FALSE otherwise. |
||
2041 | */ |
||
2042 | public function isIdGeneratorNone() |
||
2046 | |||
2047 | /** |
||
2048 | * Sets the version field mapping used for versioning. Sets the default |
||
2049 | * value to use depending on the column type. |
||
2050 | * |
||
2051 | * @param array $mapping The version field mapping array |
||
2052 | * |
||
2053 | * @throws LockException |
||
2054 | */ |
||
2055 | 102 | public function setVersionMapping(array &$mapping) |
|
2064 | |||
2065 | /** |
||
2066 | * Sets whether this class is to be versioned for optimistic locking. |
||
2067 | * |
||
2068 | * @param boolean $bool |
||
2069 | */ |
||
2070 | 377 | public function setVersioned($bool) |
|
2074 | |||
2075 | /** |
||
2076 | * Sets the name of the field that is to be used for versioning if this class is |
||
2077 | * versioned for optimistic locking. |
||
2078 | * |
||
2079 | * @param string $versionField |
||
2080 | */ |
||
2081 | 377 | public function setVersionField($versionField) |
|
2085 | |||
2086 | /** |
||
2087 | * Sets the version field mapping used for versioning. Sets the default |
||
2088 | * value to use depending on the column type. |
||
2089 | * |
||
2090 | * @param array $mapping The version field mapping array |
||
2091 | * |
||
2092 | * @throws \Doctrine\ODM\MongoDB\LockException |
||
2093 | */ |
||
2094 | 27 | public function setLockMapping(array &$mapping) |
|
2103 | |||
2104 | /** |
||
2105 | * Sets whether this class is to allow pessimistic locking. |
||
2106 | * |
||
2107 | * @param boolean $bool |
||
2108 | */ |
||
2109 | public function setLockable($bool) |
||
2113 | |||
2114 | /** |
||
2115 | * Sets the name of the field that is to be used for storing whether a document |
||
2116 | * is currently locked or not. |
||
2117 | * |
||
2118 | * @param string $lockField |
||
2119 | */ |
||
2120 | public function setLockField($lockField) |
||
2124 | |||
2125 | /** |
||
2126 | * Marks this class as read only, no change tracking is applied to it. |
||
2127 | */ |
||
2128 | 9 | public function markReadOnly() |
|
2132 | |||
2133 | /** |
||
2134 | * {@inheritDoc} |
||
2135 | */ |
||
2136 | public function getFieldNames() |
||
2140 | |||
2141 | /** |
||
2142 | * {@inheritDoc} |
||
2143 | */ |
||
2144 | public function getAssociationNames() |
||
2148 | |||
2149 | /** |
||
2150 | * {@inheritDoc} |
||
2151 | */ |
||
2152 | 22 | public function getTypeOfField($fieldName) |
|
2157 | |||
2158 | /** |
||
2159 | * {@inheritDoc} |
||
2160 | */ |
||
2161 | 6 | public function getAssociationTargetClass($assocName) |
|
2169 | |||
2170 | /** |
||
2171 | * Retrieve the collectionClass associated with an association |
||
2172 | * |
||
2173 | * @param string $assocName |
||
2174 | */ |
||
2175 | 2 | public function getAssociationCollectionClass($assocName) |
|
2187 | |||
2188 | /** |
||
2189 | * {@inheritDoc} |
||
2190 | */ |
||
2191 | public function isAssociationInverseSide($fieldName) |
||
2195 | |||
2196 | /** |
||
2197 | * {@inheritDoc} |
||
2198 | */ |
||
2199 | public function getAssociationMappedByTargetField($fieldName) |
||
2203 | } |
||
2204 |
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: