Complex classes like ClassMetadata 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 ClassMetadata, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 51 | class ClassMetadata implements BaseClassMetadata |
||
| 52 | { |
||
| 53 | /* The Id generator types. */ |
||
| 54 | /** |
||
| 55 | * AUTO means Doctrine will automatically create a new \MongoDB\BSON\ObjectId instance for us. |
||
| 56 | */ |
||
| 57 | public const GENERATOR_TYPE_AUTO = 1; |
||
| 58 | |||
| 59 | /** |
||
| 60 | * INCREMENT means a separate collection is used for maintaining and incrementing id generation. |
||
| 61 | * Offers full portability. |
||
| 62 | */ |
||
| 63 | public const GENERATOR_TYPE_INCREMENT = 2; |
||
| 64 | |||
| 65 | /** |
||
| 66 | * UUID means Doctrine will generate a uuid for us. |
||
| 67 | */ |
||
| 68 | public const GENERATOR_TYPE_UUID = 3; |
||
| 69 | |||
| 70 | /** |
||
| 71 | * ALNUM means Doctrine will generate Alpha-numeric string identifiers, using the INCREMENT |
||
| 72 | * generator to ensure identifier uniqueness |
||
| 73 | */ |
||
| 74 | public const GENERATOR_TYPE_ALNUM = 4; |
||
| 75 | |||
| 76 | /** |
||
| 77 | * CUSTOM means Doctrine expect a class parameter. It will then try to initiate that class |
||
| 78 | * and pass other options to the generator. It will throw an Exception if the class |
||
| 79 | * does not exist or if an option was passed for that there is not setter in the new |
||
| 80 | * generator class. |
||
| 81 | * |
||
| 82 | * The class will have to be a subtype of AbstractIdGenerator. |
||
| 83 | */ |
||
| 84 | public const GENERATOR_TYPE_CUSTOM = 5; |
||
| 85 | |||
| 86 | /** |
||
| 87 | * NONE means Doctrine will not generate any id for us and you are responsible for manually |
||
| 88 | * assigning an id. |
||
| 89 | */ |
||
| 90 | public const GENERATOR_TYPE_NONE = 6; |
||
| 91 | |||
| 92 | /** |
||
| 93 | * Default discriminator field name. |
||
| 94 | * |
||
| 95 | * This is used for associations value for associations where a that do not define a "targetDocument" or |
||
| 96 | * "discriminatorField" option in their mapping. |
||
| 97 | */ |
||
| 98 | public const DEFAULT_DISCRIMINATOR_FIELD = '_doctrine_class_name'; |
||
| 99 | |||
| 100 | public const REFERENCE_ONE = 1; |
||
| 101 | public const REFERENCE_MANY = 2; |
||
| 102 | public const EMBED_ONE = 3; |
||
| 103 | public const EMBED_MANY = 4; |
||
| 104 | public const MANY = 'many'; |
||
| 105 | public const ONE = 'one'; |
||
| 106 | |||
| 107 | /** |
||
| 108 | * The types of storeAs references |
||
| 109 | */ |
||
| 110 | public const REFERENCE_STORE_AS_ID = 'id'; |
||
| 111 | public const REFERENCE_STORE_AS_DB_REF = 'dbRef'; |
||
| 112 | public const REFERENCE_STORE_AS_DB_REF_WITH_DB = 'dbRefWithDb'; |
||
| 113 | public const REFERENCE_STORE_AS_REF = 'ref'; |
||
| 114 | |||
| 115 | /* The inheritance mapping types */ |
||
| 116 | /** |
||
| 117 | * NONE means the class does not participate in an inheritance hierarchy |
||
| 118 | * and therefore does not need an inheritance mapping type. |
||
| 119 | */ |
||
| 120 | public const INHERITANCE_TYPE_NONE = 1; |
||
| 121 | |||
| 122 | /** |
||
| 123 | * SINGLE_COLLECTION means the class will be persisted according to the rules of |
||
| 124 | * <tt>Single Collection Inheritance</tt>. |
||
| 125 | */ |
||
| 126 | public const INHERITANCE_TYPE_SINGLE_COLLECTION = 2; |
||
| 127 | |||
| 128 | /** |
||
| 129 | * COLLECTION_PER_CLASS means the class will be persisted according to the rules |
||
| 130 | * of <tt>Concrete Collection Inheritance</tt>. |
||
| 131 | */ |
||
| 132 | public const INHERITANCE_TYPE_COLLECTION_PER_CLASS = 3; |
||
| 133 | |||
| 134 | /** |
||
| 135 | * DEFERRED_IMPLICIT means that changes of entities are calculated at commit-time |
||
| 136 | * by doing a property-by-property comparison with the original data. This will |
||
| 137 | * be done for all entities that are in MANAGED state at commit-time. |
||
| 138 | * |
||
| 139 | * This is the default change tracking policy. |
||
| 140 | */ |
||
| 141 | public const CHANGETRACKING_DEFERRED_IMPLICIT = 1; |
||
| 142 | |||
| 143 | /** |
||
| 144 | * DEFERRED_EXPLICIT means that changes of entities are calculated at commit-time |
||
| 145 | * by doing a property-by-property comparison with the original data. This will |
||
| 146 | * be done only for entities that were explicitly saved (through persist() or a cascade). |
||
| 147 | */ |
||
| 148 | public const CHANGETRACKING_DEFERRED_EXPLICIT = 2; |
||
| 149 | |||
| 150 | /** |
||
| 151 | * NOTIFY means that Doctrine relies on the entities sending out notifications |
||
| 152 | * when their properties change. Such entity classes must implement |
||
| 153 | * the <tt>NotifyPropertyChanged</tt> interface. |
||
| 154 | */ |
||
| 155 | public const CHANGETRACKING_NOTIFY = 3; |
||
| 156 | |||
| 157 | /** |
||
| 158 | * SET means that fields will be written to the database using a $set operator |
||
| 159 | */ |
||
| 160 | public const STORAGE_STRATEGY_SET = 'set'; |
||
| 161 | |||
| 162 | /** |
||
| 163 | * INCREMENT means that fields will be written to the database by calculating |
||
| 164 | * the difference and using the $inc operator |
||
| 165 | */ |
||
| 166 | public const STORAGE_STRATEGY_INCREMENT = 'increment'; |
||
| 167 | |||
| 168 | public const STORAGE_STRATEGY_PUSH_ALL = 'pushAll'; |
||
| 169 | public const STORAGE_STRATEGY_ADD_TO_SET = 'addToSet'; |
||
| 170 | public const STORAGE_STRATEGY_ATOMIC_SET = 'atomicSet'; |
||
| 171 | public const STORAGE_STRATEGY_ATOMIC_SET_ARRAY = 'atomicSetArray'; |
||
| 172 | public const STORAGE_STRATEGY_SET_ARRAY = 'setArray'; |
||
| 173 | |||
| 174 | /** |
||
| 175 | * READ-ONLY: The name of the mongo database the document is mapped to. |
||
| 176 | * @var string |
||
| 177 | */ |
||
| 178 | public $db; |
||
| 179 | |||
| 180 | /** |
||
| 181 | * READ-ONLY: The name of the mongo collection the document is mapped to. |
||
| 182 | * @var string |
||
| 183 | */ |
||
| 184 | public $collection; |
||
| 185 | |||
| 186 | /** |
||
| 187 | * READ-ONLY: If the collection should be a fixed size. |
||
| 188 | * @var bool |
||
| 189 | */ |
||
| 190 | public $collectionCapped; |
||
| 191 | |||
| 192 | /** |
||
| 193 | * READ-ONLY: If the collection is fixed size, its size in bytes. |
||
| 194 | * @var int|null |
||
| 195 | */ |
||
| 196 | public $collectionSize; |
||
| 197 | |||
| 198 | /** |
||
| 199 | * READ-ONLY: If the collection is fixed size, the maximum number of elements to store in the collection. |
||
| 200 | * @var int|null |
||
| 201 | */ |
||
| 202 | public $collectionMax; |
||
| 203 | |||
| 204 | /** |
||
| 205 | * READ-ONLY Describes how MongoDB clients route read operations to the members of a replica set. |
||
| 206 | * @var string|int|null |
||
| 207 | */ |
||
| 208 | public $readPreference; |
||
| 209 | |||
| 210 | /** |
||
| 211 | * READ-ONLY Associated with readPreference Allows to specify criteria so that your application can target read |
||
| 212 | * operations to specific members, based on custom parameters. |
||
| 213 | * @var string[][]|null |
||
| 214 | */ |
||
| 215 | public $readPreferenceTags; |
||
| 216 | |||
| 217 | /** |
||
| 218 | * READ-ONLY: Describes the level of acknowledgement requested from MongoDB for write operations. |
||
| 219 | * @var string|int|null |
||
| 220 | */ |
||
| 221 | public $writeConcern; |
||
| 222 | |||
| 223 | /** |
||
| 224 | * READ-ONLY: The field name of the document identifier. |
||
| 225 | * @var string|null |
||
| 226 | */ |
||
| 227 | public $identifier; |
||
| 228 | |||
| 229 | /** |
||
| 230 | * READ-ONLY: The array of indexes for the document collection. |
||
| 231 | * @var array |
||
| 232 | */ |
||
| 233 | public $indexes = []; |
||
| 234 | |||
| 235 | /** |
||
| 236 | * READ-ONLY: Keys and options describing shard key. Only for sharded collections. |
||
| 237 | * @var string|null |
||
| 238 | */ |
||
| 239 | public $shardKey; |
||
| 240 | |||
| 241 | /** |
||
| 242 | * READ-ONLY: The name of the document class. |
||
| 243 | * @var string |
||
| 244 | */ |
||
| 245 | public $name; |
||
| 246 | |||
| 247 | /** |
||
| 248 | * READ-ONLY: The name of the document class that is at the root of the mapped document inheritance |
||
| 249 | * hierarchy. If the document is not part of a mapped inheritance hierarchy this is the same |
||
| 250 | * as {@link $documentName}. |
||
| 251 | * |
||
| 252 | * @var string |
||
| 253 | */ |
||
| 254 | public $rootDocumentName; |
||
| 255 | |||
| 256 | /** |
||
| 257 | * The name of the custom repository class used for the document class. |
||
| 258 | * (Optional). |
||
| 259 | * |
||
| 260 | * @var string |
||
| 261 | */ |
||
| 262 | public $customRepositoryClassName; |
||
| 263 | |||
| 264 | /** |
||
| 265 | * READ-ONLY: The names of the parent classes (ancestors). |
||
| 266 | * |
||
| 267 | * @var array |
||
| 268 | */ |
||
| 269 | public $parentClasses = []; |
||
| 270 | |||
| 271 | /** |
||
| 272 | * READ-ONLY: The names of all subclasses (descendants). |
||
| 273 | * |
||
| 274 | * @var array |
||
| 275 | */ |
||
| 276 | public $subClasses = []; |
||
| 277 | |||
| 278 | /** |
||
| 279 | * The ReflectionProperty instances of the mapped class. |
||
| 280 | * |
||
| 281 | * @var \ReflectionProperty[] |
||
| 282 | */ |
||
| 283 | public $reflFields = []; |
||
| 284 | |||
| 285 | /** |
||
| 286 | * READ-ONLY: The inheritance mapping type used by the class. |
||
| 287 | * |
||
| 288 | * @var int |
||
| 289 | */ |
||
| 290 | public $inheritanceType = self::INHERITANCE_TYPE_NONE; |
||
| 291 | |||
| 292 | /** |
||
| 293 | * READ-ONLY: The Id generator type used by the class. |
||
| 294 | * |
||
| 295 | * @var string |
||
| 296 | */ |
||
| 297 | public $generatorType = self::GENERATOR_TYPE_AUTO; |
||
| 298 | |||
| 299 | /** |
||
| 300 | * READ-ONLY: The Id generator options. |
||
| 301 | * |
||
| 302 | * @var array |
||
| 303 | */ |
||
| 304 | public $generatorOptions = []; |
||
| 305 | |||
| 306 | /** |
||
| 307 | * READ-ONLY: The ID generator used for generating IDs for this class. |
||
| 308 | * |
||
| 309 | * @var AbstractIdGenerator |
||
| 310 | */ |
||
| 311 | public $idGenerator; |
||
| 312 | |||
| 313 | /** |
||
| 314 | * READ-ONLY: The field mappings of the class. |
||
| 315 | * Keys are field names and values are mapping definitions. |
||
| 316 | * |
||
| 317 | * The mapping definition array has the following values: |
||
| 318 | * |
||
| 319 | * - <b>fieldName</b> (string) |
||
| 320 | * The name of the field in the Document. |
||
| 321 | * |
||
| 322 | * - <b>id</b> (boolean, optional) |
||
| 323 | * Marks the field as the primary key of the document. Multiple fields of an |
||
| 324 | * document can have the id attribute, forming a composite key. |
||
| 325 | * |
||
| 326 | * @var array |
||
| 327 | */ |
||
| 328 | public $fieldMappings = []; |
||
| 329 | |||
| 330 | /** |
||
| 331 | * READ-ONLY: The association mappings of the class. |
||
| 332 | * Keys are field names and values are mapping definitions. |
||
| 333 | * |
||
| 334 | * @var array |
||
| 335 | */ |
||
| 336 | public $associationMappings = []; |
||
| 337 | |||
| 338 | /** |
||
| 339 | * READ-ONLY: Array of fields to also load with a given method. |
||
| 340 | * |
||
| 341 | * @var array |
||
| 342 | */ |
||
| 343 | public $alsoLoadMethods = []; |
||
| 344 | |||
| 345 | /** |
||
| 346 | * READ-ONLY: The registered lifecycle callbacks for documents of this class. |
||
| 347 | * |
||
| 348 | * @var array |
||
| 349 | */ |
||
| 350 | public $lifecycleCallbacks = []; |
||
| 351 | |||
| 352 | /** |
||
| 353 | * READ-ONLY: The discriminator value of this class. |
||
| 354 | * |
||
| 355 | * <b>This does only apply to the JOINED and SINGLE_COLLECTION inheritance mapping strategies |
||
| 356 | * where a discriminator field is used.</b> |
||
| 357 | * |
||
| 358 | * @var mixed |
||
| 359 | * @see discriminatorField |
||
| 360 | */ |
||
| 361 | public $discriminatorValue; |
||
| 362 | |||
| 363 | /** |
||
| 364 | * READ-ONLY: The discriminator map of all mapped classes in the hierarchy. |
||
| 365 | * |
||
| 366 | * <b>This does only apply to the SINGLE_COLLECTION inheritance mapping strategy |
||
| 367 | * where a discriminator field is used.</b> |
||
| 368 | * |
||
| 369 | * @var mixed |
||
| 370 | * @see discriminatorField |
||
| 371 | */ |
||
| 372 | public $discriminatorMap = []; |
||
| 373 | |||
| 374 | /** |
||
| 375 | * READ-ONLY: The definition of the discriminator field used in SINGLE_COLLECTION |
||
| 376 | * inheritance mapping. |
||
| 377 | * |
||
| 378 | * @var string |
||
| 379 | */ |
||
| 380 | public $discriminatorField; |
||
| 381 | |||
| 382 | /** |
||
| 383 | * READ-ONLY: The default value for discriminatorField in case it's not set in the document |
||
| 384 | * |
||
| 385 | * @var string |
||
| 386 | * @see discriminatorField |
||
| 387 | */ |
||
| 388 | public $defaultDiscriminatorValue; |
||
| 389 | |||
| 390 | /** |
||
| 391 | * READ-ONLY: Whether this class describes the mapping of a mapped superclass. |
||
| 392 | * |
||
| 393 | * @var bool |
||
| 394 | */ |
||
| 395 | public $isMappedSuperclass = false; |
||
| 396 | |||
| 397 | /** |
||
| 398 | * READ-ONLY: Whether this class describes the mapping of a embedded document. |
||
| 399 | * |
||
| 400 | * @var bool |
||
| 401 | */ |
||
| 402 | public $isEmbeddedDocument = false; |
||
| 403 | |||
| 404 | /** |
||
| 405 | * READ-ONLY: Whether this class describes the mapping of an aggregation result document. |
||
| 406 | * |
||
| 407 | * @var bool |
||
| 408 | */ |
||
| 409 | public $isQueryResultDocument = false; |
||
| 410 | |||
| 411 | /** |
||
| 412 | * READ-ONLY: The policy used for change-tracking on entities of this class. |
||
| 413 | * |
||
| 414 | * @var int |
||
| 415 | */ |
||
| 416 | public $changeTrackingPolicy = self::CHANGETRACKING_DEFERRED_IMPLICIT; |
||
| 417 | |||
| 418 | /** |
||
| 419 | * READ-ONLY: A flag for whether or not instances of this class are to be versioned |
||
| 420 | * with optimistic locking. |
||
| 421 | * |
||
| 422 | * @var bool $isVersioned |
||
| 423 | */ |
||
| 424 | public $isVersioned; |
||
| 425 | |||
| 426 | /** |
||
| 427 | * READ-ONLY: The name of the field which is used for versioning in optimistic locking (if any). |
||
| 428 | * |
||
| 429 | * @var mixed $versionField |
||
| 430 | */ |
||
| 431 | public $versionField; |
||
| 432 | |||
| 433 | /** |
||
| 434 | * READ-ONLY: A flag for whether or not instances of this class are to allow pessimistic |
||
| 435 | * locking. |
||
| 436 | * |
||
| 437 | * @var bool $isLockable |
||
| 438 | */ |
||
| 439 | public $isLockable; |
||
| 440 | |||
| 441 | /** |
||
| 442 | * READ-ONLY: The name of the field which is used for locking a document. |
||
| 443 | * |
||
| 444 | * @var mixed $lockField |
||
| 445 | */ |
||
| 446 | public $lockField; |
||
| 447 | |||
| 448 | /** |
||
| 449 | * The ReflectionClass instance of the mapped class. |
||
| 450 | * |
||
| 451 | * @var \ReflectionClass |
||
| 452 | */ |
||
| 453 | public $reflClass; |
||
| 454 | |||
| 455 | /** |
||
| 456 | * READ_ONLY: A flag for whether or not this document is read-only. |
||
| 457 | * |
||
| 458 | * @var bool |
||
| 459 | */ |
||
| 460 | public $isReadOnly; |
||
| 461 | |||
| 462 | /** @var InstantiatorInterface|null */ |
||
| 463 | private $instantiator; |
||
| 464 | |||
| 465 | /** |
||
| 466 | * Initializes a new ClassMetadata instance that will hold the object-document mapping |
||
| 467 | * metadata of the class with the given name. |
||
| 468 | * |
||
| 469 | * @param string $documentName The name of the document class the new instance is used for. |
||
| 470 | */ |
||
| 471 | 1502 | public function __construct($documentName) |
|
| 479 | |||
| 480 | /** |
||
| 481 | * Helper method to get reference id of ref* type references |
||
| 482 | * @param mixed $reference |
||
| 483 | * @param string $storeAs |
||
| 484 | * @return mixed |
||
| 485 | * @internal |
||
| 486 | */ |
||
| 487 | 121 | public static function getReferenceId($reference, $storeAs) |
|
| 491 | |||
| 492 | /** |
||
| 493 | * Returns the reference prefix used for a reference |
||
| 494 | * @param string $storeAs |
||
| 495 | * @return string |
||
| 496 | */ |
||
| 497 | 186 | private static function getReferencePrefix($storeAs) |
|
| 505 | |||
| 506 | /** |
||
| 507 | * Returns a fully qualified field name for a given reference |
||
| 508 | * @param string $storeAs |
||
| 509 | * @param string $pathPrefix The field path prefix |
||
| 510 | * @return string |
||
| 511 | * @internal |
||
| 512 | */ |
||
| 513 | 134 | public static function getReferenceFieldName($storeAs, $pathPrefix = '') |
|
| 521 | |||
| 522 | /** |
||
| 523 | * {@inheritDoc} |
||
| 524 | */ |
||
| 525 | 1389 | public function getReflectionClass() |
|
| 533 | |||
| 534 | /** |
||
| 535 | * {@inheritDoc} |
||
| 536 | */ |
||
| 537 | 326 | public function isIdentifier($fieldName) |
|
| 541 | |||
| 542 | /** |
||
| 543 | * INTERNAL: |
||
| 544 | * Sets the mapped identifier field of this class. |
||
| 545 | * |
||
| 546 | * @param string $identifier |
||
| 547 | */ |
||
| 548 | 907 | public function setIdentifier($identifier) |
|
| 552 | |||
| 553 | /** |
||
| 554 | * {@inheritDoc} |
||
| 555 | * |
||
| 556 | * Since MongoDB only allows exactly one identifier field |
||
| 557 | * this will always return an array with only one value |
||
| 558 | */ |
||
| 559 | 39 | public function getIdentifier() |
|
| 563 | |||
| 564 | /** |
||
| 565 | * {@inheritDoc} |
||
| 566 | * |
||
| 567 | * Since MongoDB only allows exactly one identifier field |
||
| 568 | * this will always return an array with only one value |
||
| 569 | */ |
||
| 570 | 98 | public function getIdentifierFieldNames() |
|
| 574 | |||
| 575 | /** |
||
| 576 | * {@inheritDoc} |
||
| 577 | */ |
||
| 578 | 893 | public function hasField($fieldName) |
|
| 582 | |||
| 583 | /** |
||
| 584 | * Sets the inheritance type used by the class and it's subclasses. |
||
| 585 | * |
||
| 586 | * @param int $type |
||
| 587 | */ |
||
| 588 | 923 | public function setInheritanceType($type) |
|
| 592 | |||
| 593 | /** |
||
| 594 | * Checks whether a mapped field is inherited from an entity superclass. |
||
| 595 | * |
||
| 596 | * @param string $fieldName |
||
| 597 | * |
||
| 598 | * @return bool TRUE if the field is inherited, FALSE otherwise. |
||
| 599 | */ |
||
| 600 | 1385 | public function isInheritedField($fieldName) |
|
| 604 | |||
| 605 | /** |
||
| 606 | * Registers a custom repository class for the document class. |
||
| 607 | * |
||
| 608 | * @param string $repositoryClassName The class name of the custom repository. |
||
| 609 | */ |
||
| 610 | 855 | public function setCustomRepositoryClass($repositoryClassName) |
|
| 618 | |||
| 619 | /** |
||
| 620 | * Dispatches the lifecycle event of the given document by invoking all |
||
| 621 | * registered callbacks. |
||
| 622 | * |
||
| 623 | * @param string $event Lifecycle event |
||
| 624 | * @param object $document Document on which the event occurred |
||
| 625 | * @param array $arguments Arguments to pass to all callbacks |
||
| 626 | * @throws \InvalidArgumentException If document class is not this class or |
||
| 627 | * a Proxy of this class. |
||
| 628 | */ |
||
| 629 | 604 | public function invokeLifecycleCallbacks($event, $document, ?array $arguments = null) |
|
| 647 | |||
| 648 | /** |
||
| 649 | * Checks whether the class has callbacks registered for a lifecycle event. |
||
| 650 | * |
||
| 651 | * @param string $event Lifecycle event |
||
| 652 | * |
||
| 653 | * @return bool |
||
| 654 | */ |
||
| 655 | public function hasLifecycleCallbacks($event) |
||
| 659 | |||
| 660 | /** |
||
| 661 | * Gets the registered lifecycle callbacks for an event. |
||
| 662 | * |
||
| 663 | * @param string $event |
||
| 664 | * @return array |
||
| 665 | */ |
||
| 666 | public function getLifecycleCallbacks($event) |
||
| 670 | |||
| 671 | /** |
||
| 672 | * Adds a lifecycle callback for documents of this class. |
||
| 673 | * |
||
| 674 | * If the callback is already registered, this is a NOOP. |
||
| 675 | * |
||
| 676 | * @param string $callback |
||
| 677 | * @param string $event |
||
| 678 | */ |
||
| 679 | 822 | public function addLifecycleCallback($callback, $event) |
|
| 687 | |||
| 688 | /** |
||
| 689 | * Sets the lifecycle callbacks for documents of this class. |
||
| 690 | * |
||
| 691 | * Any previously registered callbacks are overwritten. |
||
| 692 | * |
||
| 693 | * @param array $callbacks |
||
| 694 | */ |
||
| 695 | 906 | public function setLifecycleCallbacks(array $callbacks) |
|
| 699 | |||
| 700 | /** |
||
| 701 | * Registers a method for loading document data before field hydration. |
||
| 702 | * |
||
| 703 | * Note: A method may be registered multiple times for different fields. |
||
| 704 | * it will be invoked only once for the first field found. |
||
| 705 | * |
||
| 706 | * @param string $method Method name |
||
| 707 | * @param array|string $fields Database field name(s) |
||
| 708 | */ |
||
| 709 | 14 | public function registerAlsoLoadMethod($method, $fields) |
|
| 713 | |||
| 714 | /** |
||
| 715 | * Sets the AlsoLoad methods for documents of this class. |
||
| 716 | * |
||
| 717 | * Any previously registered methods are overwritten. |
||
| 718 | * |
||
| 719 | * @param array $methods |
||
| 720 | */ |
||
| 721 | 906 | public function setAlsoLoadMethods(array $methods) |
|
| 725 | |||
| 726 | /** |
||
| 727 | * Sets the discriminator field. |
||
| 728 | * |
||
| 729 | * The field name is the the unmapped database field. Discriminator values |
||
| 730 | * are only used to discern the hydration class and are not mapped to class |
||
| 731 | * properties. |
||
| 732 | * |
||
| 733 | * @param string $discriminatorField |
||
| 734 | * |
||
| 735 | * @throws MappingException If the discriminator field conflicts with the |
||
| 736 | * "name" attribute of a mapped field. |
||
| 737 | */ |
||
| 738 | 932 | public function setDiscriminatorField($discriminatorField) |
|
| 763 | |||
| 764 | /** |
||
| 765 | * Sets the discriminator values used by this class. |
||
| 766 | * Used for JOINED and SINGLE_TABLE inheritance mapping strategies. |
||
| 767 | * |
||
| 768 | * @param array $map |
||
| 769 | * |
||
| 770 | * @throws MappingException |
||
| 771 | */ |
||
| 772 | 925 | public function setDiscriminatorMap(array $map) |
|
| 788 | |||
| 789 | /** |
||
| 790 | * Sets the default discriminator value to be used for this class |
||
| 791 | * Used for JOINED and SINGLE_TABLE inheritance mapping strategies if the document has no discriminator value |
||
| 792 | * |
||
| 793 | * @param string $defaultDiscriminatorValue |
||
| 794 | * |
||
| 795 | * @throws MappingException |
||
| 796 | */ |
||
| 797 | 909 | public function setDefaultDiscriminatorValue($defaultDiscriminatorValue) |
|
| 811 | |||
| 812 | /** |
||
| 813 | * Sets the discriminator value for this class. |
||
| 814 | * Used for JOINED/SINGLE_TABLE inheritance and multiple document types in a single |
||
| 815 | * collection. |
||
| 816 | * |
||
| 817 | * @param string $value |
||
| 818 | */ |
||
| 819 | 3 | public function setDiscriminatorValue($value) |
|
| 824 | |||
| 825 | /** |
||
| 826 | * Add a index for this Document. |
||
| 827 | * |
||
| 828 | * @param array $keys Array of keys for the index. |
||
| 829 | * @param array $options Array of options for the index. |
||
| 830 | */ |
||
| 831 | 199 | public function addIndex($keys, array $options = []) |
|
| 853 | |||
| 854 | /** |
||
| 855 | * Returns the array of indexes for this Document. |
||
| 856 | * |
||
| 857 | * @return array $indexes The array of indexes. |
||
| 858 | */ |
||
| 859 | 22 | public function getIndexes() |
|
| 863 | |||
| 864 | /** |
||
| 865 | * Checks whether this document has indexes or not. |
||
| 866 | * |
||
| 867 | * @return bool |
||
| 868 | */ |
||
| 869 | public function hasIndexes() |
||
| 873 | |||
| 874 | /** |
||
| 875 | * Set shard key for this Document. |
||
| 876 | * |
||
| 877 | * @param array $keys Array of document keys. |
||
| 878 | * @param array $options Array of sharding options. |
||
| 879 | * |
||
| 880 | * @throws MappingException |
||
| 881 | */ |
||
| 882 | 88 | public function setShardKey(array $keys, array $options = []) |
|
| 926 | |||
| 927 | /** |
||
| 928 | * @return array |
||
| 929 | */ |
||
| 930 | 17 | public function getShardKey() |
|
| 934 | |||
| 935 | /** |
||
| 936 | * Checks whether this document has shard key or not. |
||
| 937 | * |
||
| 938 | * @return bool |
||
| 939 | */ |
||
| 940 | 1118 | public function isSharded() |
|
| 944 | |||
| 945 | /** |
||
| 946 | * Sets the read preference used by this class. |
||
| 947 | * |
||
| 948 | * @param string $readPreference |
||
| 949 | * @param array|null $tags |
||
| 950 | */ |
||
| 951 | 906 | public function setReadPreference($readPreference, $tags) |
|
| 956 | |||
| 957 | /** |
||
| 958 | * Sets the write concern used by this class. |
||
| 959 | * |
||
| 960 | * @param string $writeConcern |
||
| 961 | */ |
||
| 962 | 916 | public function setWriteConcern($writeConcern) |
|
| 966 | |||
| 967 | /** |
||
| 968 | * @return string |
||
| 969 | */ |
||
| 970 | 11 | public function getWriteConcern() |
|
| 974 | |||
| 975 | /** |
||
| 976 | * Whether there is a write concern configured for this class. |
||
| 977 | * |
||
| 978 | * @return bool |
||
| 979 | */ |
||
| 980 | 553 | public function hasWriteConcern() |
|
| 984 | |||
| 985 | /** |
||
| 986 | * Sets the change tracking policy used by this class. |
||
| 987 | * |
||
| 988 | * @param int $policy |
||
| 989 | */ |
||
| 990 | 908 | public function setChangeTrackingPolicy($policy) |
|
| 994 | |||
| 995 | /** |
||
| 996 | * Whether the change tracking policy of this class is "deferred explicit". |
||
| 997 | * |
||
| 998 | * @return bool |
||
| 999 | */ |
||
| 1000 | 62 | public function isChangeTrackingDeferredExplicit() |
|
| 1004 | |||
| 1005 | /** |
||
| 1006 | * Whether the change tracking policy of this class is "deferred implicit". |
||
| 1007 | * |
||
| 1008 | * @return bool |
||
| 1009 | */ |
||
| 1010 | 573 | public function isChangeTrackingDeferredImplicit() |
|
| 1014 | |||
| 1015 | /** |
||
| 1016 | * Whether the change tracking policy of this class is "notify". |
||
| 1017 | * |
||
| 1018 | * @return bool |
||
| 1019 | */ |
||
| 1020 | 312 | public function isChangeTrackingNotify() |
|
| 1024 | |||
| 1025 | /** |
||
| 1026 | * Gets the ReflectionProperties of the mapped class. |
||
| 1027 | * |
||
| 1028 | * @return array An array of ReflectionProperty instances. |
||
| 1029 | */ |
||
| 1030 | 98 | public function getReflectionProperties() |
|
| 1034 | |||
| 1035 | /** |
||
| 1036 | * Gets a ReflectionProperty for a specific field of the mapped class. |
||
| 1037 | * |
||
| 1038 | * @param string $name |
||
| 1039 | * |
||
| 1040 | * @return \ReflectionProperty |
||
| 1041 | */ |
||
| 1042 | public function getReflectionProperty($name) |
||
| 1046 | |||
| 1047 | /** |
||
| 1048 | * {@inheritDoc} |
||
| 1049 | */ |
||
| 1050 | 1394 | public function getName() |
|
| 1054 | |||
| 1055 | /** |
||
| 1056 | * Returns the database this Document is mapped to. |
||
| 1057 | * |
||
| 1058 | * @return string $db The database name. |
||
| 1059 | */ |
||
| 1060 | 1318 | public function getDatabase() |
|
| 1064 | |||
| 1065 | /** |
||
| 1066 | * Set the database this Document is mapped to. |
||
| 1067 | * |
||
| 1068 | * @param string $db The database name |
||
| 1069 | */ |
||
| 1070 | 108 | public function setDatabase($db) |
|
| 1074 | |||
| 1075 | /** |
||
| 1076 | * Get the collection this Document is mapped to. |
||
| 1077 | * |
||
| 1078 | * @return string $collection The collection name. |
||
| 1079 | */ |
||
| 1080 | 1319 | public function getCollection() |
|
| 1084 | |||
| 1085 | /** |
||
| 1086 | * Sets the collection this Document is mapped to. |
||
| 1087 | * |
||
| 1088 | * @param array|string $name |
||
| 1089 | * |
||
| 1090 | * @throws \InvalidArgumentException |
||
| 1091 | */ |
||
| 1092 | 1502 | public function setCollection($name) |
|
| 1106 | |||
| 1107 | /** |
||
| 1108 | * Get whether or not the documents collection is capped. |
||
| 1109 | * |
||
| 1110 | * @return bool |
||
| 1111 | */ |
||
| 1112 | 5 | public function getCollectionCapped() |
|
| 1116 | |||
| 1117 | /** |
||
| 1118 | * Set whether or not the documents collection is capped. |
||
| 1119 | * |
||
| 1120 | * @param bool $bool |
||
| 1121 | */ |
||
| 1122 | 1 | public function setCollectionCapped($bool) |
|
| 1126 | |||
| 1127 | /** |
||
| 1128 | * Get the collection size |
||
| 1129 | * |
||
| 1130 | * @return int |
||
| 1131 | */ |
||
| 1132 | 5 | public function getCollectionSize() |
|
| 1136 | |||
| 1137 | /** |
||
| 1138 | * Set the collection size. |
||
| 1139 | * |
||
| 1140 | * @param int $size |
||
| 1141 | */ |
||
| 1142 | 1 | public function setCollectionSize($size) |
|
| 1146 | |||
| 1147 | /** |
||
| 1148 | * Get the collection max. |
||
| 1149 | * |
||
| 1150 | * @return int |
||
| 1151 | */ |
||
| 1152 | 5 | public function getCollectionMax() |
|
| 1156 | |||
| 1157 | /** |
||
| 1158 | * Set the collection max. |
||
| 1159 | * |
||
| 1160 | * @param int $max |
||
| 1161 | */ |
||
| 1162 | 1 | public function setCollectionMax($max) |
|
| 1166 | |||
| 1167 | /** |
||
| 1168 | * Returns TRUE if this Document is mapped to a collection FALSE otherwise. |
||
| 1169 | * |
||
| 1170 | * @return bool |
||
| 1171 | */ |
||
| 1172 | public function isMappedToCollection() |
||
| 1176 | |||
| 1177 | /** |
||
| 1178 | * Validates the storage strategy of a mapping for consistency |
||
| 1179 | * @param array $mapping |
||
| 1180 | * @throws MappingException |
||
| 1181 | */ |
||
| 1182 | 1410 | private function applyStorageStrategy(array &$mapping) |
|
| 1225 | |||
| 1226 | /** |
||
| 1227 | * Map a single embedded document. |
||
| 1228 | * |
||
| 1229 | * @param array $mapping The mapping information. |
||
| 1230 | */ |
||
| 1231 | 6 | public function mapOneEmbedded(array $mapping) |
|
| 1237 | |||
| 1238 | /** |
||
| 1239 | * Map a collection of embedded documents. |
||
| 1240 | * |
||
| 1241 | * @param array $mapping The mapping information. |
||
| 1242 | */ |
||
| 1243 | 5 | public function mapManyEmbedded(array $mapping) |
|
| 1249 | |||
| 1250 | /** |
||
| 1251 | * Map a single document reference. |
||
| 1252 | * |
||
| 1253 | * @param array $mapping The mapping information. |
||
| 1254 | */ |
||
| 1255 | 2 | public function mapOneReference(array $mapping) |
|
| 1261 | |||
| 1262 | /** |
||
| 1263 | * Map a collection of document references. |
||
| 1264 | * |
||
| 1265 | * @param array $mapping The mapping information. |
||
| 1266 | */ |
||
| 1267 | 1 | public function mapManyReference(array $mapping) |
|
| 1273 | |||
| 1274 | /** |
||
| 1275 | * INTERNAL: |
||
| 1276 | * Adds a field mapping without completing/validating it. |
||
| 1277 | * This is mainly used to add inherited field mappings to derived classes. |
||
| 1278 | * |
||
| 1279 | * @param array $fieldMapping |
||
| 1280 | */ |
||
| 1281 | 133 | public function addInheritedFieldMapping(array $fieldMapping) |
|
| 1291 | |||
| 1292 | /** |
||
| 1293 | * INTERNAL: |
||
| 1294 | * Adds an association mapping without completing/validating it. |
||
| 1295 | * This is mainly used to add inherited association mappings to derived classes. |
||
| 1296 | * |
||
| 1297 | * @param array $mapping |
||
| 1298 | * |
||
| 1299 | * |
||
| 1300 | * @throws MappingException |
||
| 1301 | */ |
||
| 1302 | 85 | public function addInheritedAssociationMapping(array $mapping/*, $owningClassName = null*/) |
|
| 1306 | |||
| 1307 | /** |
||
| 1308 | * Checks whether the class has a mapped association with the given field name. |
||
| 1309 | * |
||
| 1310 | * @param string $fieldName |
||
| 1311 | * @return bool |
||
| 1312 | */ |
||
| 1313 | 32 | public function hasReference($fieldName) |
|
| 1317 | |||
| 1318 | /** |
||
| 1319 | * Checks whether the class has a mapped embed with the given field name. |
||
| 1320 | * |
||
| 1321 | * @param string $fieldName |
||
| 1322 | * @return bool |
||
| 1323 | */ |
||
| 1324 | 5 | public function hasEmbed($fieldName) |
|
| 1328 | |||
| 1329 | /** |
||
| 1330 | * {@inheritDoc} |
||
| 1331 | * |
||
| 1332 | * Checks whether the class has a mapped association (embed or reference) with the given field name. |
||
| 1333 | */ |
||
| 1334 | 7 | public function hasAssociation($fieldName) |
|
| 1338 | |||
| 1339 | /** |
||
| 1340 | * {@inheritDoc} |
||
| 1341 | * |
||
| 1342 | * Checks whether the class has a mapped reference or embed for the specified field and |
||
| 1343 | * is a single valued association. |
||
| 1344 | */ |
||
| 1345 | public function isSingleValuedAssociation($fieldName) |
||
| 1349 | |||
| 1350 | /** |
||
| 1351 | * {@inheritDoc} |
||
| 1352 | * |
||
| 1353 | * Checks whether the class has a mapped reference or embed for the specified field and |
||
| 1354 | * is a collection valued association. |
||
| 1355 | */ |
||
| 1356 | public function isCollectionValuedAssociation($fieldName) |
||
| 1360 | |||
| 1361 | /** |
||
| 1362 | * Checks whether the class has a mapped association for the specified field |
||
| 1363 | * and if yes, checks whether it is a single-valued association (to-one). |
||
| 1364 | * |
||
| 1365 | * @param string $fieldName |
||
| 1366 | * @return bool TRUE if the association exists and is single-valued, FALSE otherwise. |
||
| 1367 | */ |
||
| 1368 | public function isSingleValuedReference($fieldName) |
||
| 1373 | |||
| 1374 | /** |
||
| 1375 | * Checks whether the class has a mapped association for the specified field |
||
| 1376 | * and if yes, checks whether it is a collection-valued association (to-many). |
||
| 1377 | * |
||
| 1378 | * @param string $fieldName |
||
| 1379 | * @return bool TRUE if the association exists and is collection-valued, FALSE otherwise. |
||
| 1380 | */ |
||
| 1381 | public function isCollectionValuedReference($fieldName) |
||
| 1386 | |||
| 1387 | /** |
||
| 1388 | * Checks whether the class has a mapped embedded document for the specified field |
||
| 1389 | * and if yes, checks whether it is a single-valued association (to-one). |
||
| 1390 | * |
||
| 1391 | * @param string $fieldName |
||
| 1392 | * @return bool TRUE if the association exists and is single-valued, FALSE otherwise. |
||
| 1393 | */ |
||
| 1394 | public function isSingleValuedEmbed($fieldName) |
||
| 1399 | |||
| 1400 | /** |
||
| 1401 | * Checks whether the class has a mapped embedded document for the specified field |
||
| 1402 | * and if yes, checks whether it is a collection-valued association (to-many). |
||
| 1403 | * |
||
| 1404 | * @param string $fieldName |
||
| 1405 | * @return bool TRUE if the association exists and is collection-valued, FALSE otherwise. |
||
| 1406 | */ |
||
| 1407 | public function isCollectionValuedEmbed($fieldName) |
||
| 1412 | |||
| 1413 | /** |
||
| 1414 | * Sets the ID generator used to generate IDs for instances of this class. |
||
| 1415 | * |
||
| 1416 | * @param AbstractIdGenerator $generator |
||
| 1417 | */ |
||
| 1418 | 1330 | public function setIdGenerator($generator) |
|
| 1422 | |||
| 1423 | /** |
||
| 1424 | * Casts the identifier to its portable PHP type. |
||
| 1425 | * |
||
| 1426 | * @param mixed $id |
||
| 1427 | * @return mixed $id |
||
| 1428 | */ |
||
| 1429 | 596 | public function getPHPIdentifierValue($id) |
|
| 1434 | |||
| 1435 | /** |
||
| 1436 | * Casts the identifier to its database type. |
||
| 1437 | * |
||
| 1438 | * @param mixed $id |
||
| 1439 | * @return mixed $id |
||
| 1440 | */ |
||
| 1441 | 659 | public function getDatabaseIdentifierValue($id) |
|
| 1446 | |||
| 1447 | /** |
||
| 1448 | * Sets the document identifier of a document. |
||
| 1449 | * |
||
| 1450 | * The value will be converted to a PHP type before being set. |
||
| 1451 | * |
||
| 1452 | * @param object $document |
||
| 1453 | * @param mixed $id |
||
| 1454 | */ |
||
| 1455 | 525 | public function setIdentifierValue($document, $id) |
|
| 1460 | |||
| 1461 | /** |
||
| 1462 | * Gets the document identifier as a PHP type. |
||
| 1463 | * |
||
| 1464 | * @param object $document |
||
| 1465 | * @return mixed $id |
||
| 1466 | */ |
||
| 1467 | 608 | public function getIdentifierValue($document) |
|
| 1471 | |||
| 1472 | /** |
||
| 1473 | * {@inheritDoc} |
||
| 1474 | * |
||
| 1475 | * Since MongoDB only allows exactly one identifier field this is a proxy |
||
| 1476 | * to {@see getIdentifierValue()} and returns an array with the identifier |
||
| 1477 | * field as a key. |
||
| 1478 | */ |
||
| 1479 | public function getIdentifierValues($object) |
||
| 1483 | |||
| 1484 | /** |
||
| 1485 | * Get the document identifier object as a database type. |
||
| 1486 | * |
||
| 1487 | * @param object $document |
||
| 1488 | * |
||
| 1489 | * @return ObjectId $id The ObjectId |
||
| 1490 | */ |
||
| 1491 | 31 | public function getIdentifierObject($document) |
|
| 1495 | |||
| 1496 | /** |
||
| 1497 | * Sets the specified field to the specified value on the given document. |
||
| 1498 | * |
||
| 1499 | * @param object $document |
||
| 1500 | * @param string $field |
||
| 1501 | * @param mixed $value |
||
| 1502 | */ |
||
| 1503 | 8 | public function setFieldValue($document, $field, $value) |
|
| 1513 | |||
| 1514 | /** |
||
| 1515 | * Gets the specified field's value off the given document. |
||
| 1516 | * |
||
| 1517 | * @param object $document |
||
| 1518 | * @param string $field |
||
| 1519 | * |
||
| 1520 | * @return mixed |
||
| 1521 | */ |
||
| 1522 | 27 | public function getFieldValue($document, $field) |
|
| 1530 | |||
| 1531 | /** |
||
| 1532 | * Gets the mapping of a field. |
||
| 1533 | * |
||
| 1534 | * @param string $fieldName The field name. |
||
| 1535 | * |
||
| 1536 | * @return array The field mapping. |
||
| 1537 | * |
||
| 1538 | * @throws MappingException If the $fieldName is not found in the fieldMappings array. |
||
| 1539 | */ |
||
| 1540 | 169 | public function getFieldMapping($fieldName) |
|
| 1547 | |||
| 1548 | /** |
||
| 1549 | * Gets mappings of fields holding embedded document(s). |
||
| 1550 | * |
||
| 1551 | * @return array of field mappings |
||
| 1552 | */ |
||
| 1553 | 564 | public function getEmbeddedFieldsMappings() |
|
| 1562 | |||
| 1563 | /** |
||
| 1564 | * Gets the field mapping by its DB name. |
||
| 1565 | * E.g. it returns identifier's mapping when called with _id. |
||
| 1566 | * |
||
| 1567 | * @param string $dbFieldName |
||
| 1568 | * |
||
| 1569 | * @return array |
||
| 1570 | * @throws MappingException |
||
| 1571 | */ |
||
| 1572 | 4 | public function getFieldMappingByDbFieldName($dbFieldName) |
|
| 1582 | |||
| 1583 | /** |
||
| 1584 | * Check if the field is not null. |
||
| 1585 | * |
||
| 1586 | * @param string $fieldName The field name |
||
| 1587 | * |
||
| 1588 | * @return bool TRUE if the field is not null, FALSE otherwise. |
||
| 1589 | */ |
||
| 1590 | 1 | public function isNullable($fieldName) |
|
| 1598 | |||
| 1599 | /** |
||
| 1600 | * Checks whether the document has a discriminator field and value configured. |
||
| 1601 | * |
||
| 1602 | * @return bool |
||
| 1603 | */ |
||
| 1604 | 499 | public function hasDiscriminator() |
|
| 1608 | |||
| 1609 | /** |
||
| 1610 | * Sets the type of Id generator to use for the mapped class. |
||
| 1611 | * |
||
| 1612 | * @param string $generatorType Generator type. |
||
| 1613 | */ |
||
| 1614 | 906 | public function setIdGeneratorType($generatorType) |
|
| 1618 | |||
| 1619 | /** |
||
| 1620 | * Sets the Id generator options. |
||
| 1621 | * |
||
| 1622 | * @param array $generatorOptions Generator options. |
||
| 1623 | */ |
||
| 1624 | public function setIdGeneratorOptions($generatorOptions) |
||
| 1628 | |||
| 1629 | /** |
||
| 1630 | * @return bool |
||
| 1631 | */ |
||
| 1632 | 571 | public function isInheritanceTypeNone() |
|
| 1636 | |||
| 1637 | /** |
||
| 1638 | * Checks whether the mapped class uses the SINGLE_COLLECTION inheritance mapping strategy. |
||
| 1639 | * |
||
| 1640 | * @return bool |
||
| 1641 | */ |
||
| 1642 | 905 | public function isInheritanceTypeSingleCollection() |
|
| 1646 | |||
| 1647 | /** |
||
| 1648 | * Checks whether the mapped class uses the COLLECTION_PER_CLASS inheritance mapping strategy. |
||
| 1649 | * |
||
| 1650 | * @return bool |
||
| 1651 | */ |
||
| 1652 | public function isInheritanceTypeCollectionPerClass() |
||
| 1656 | |||
| 1657 | /** |
||
| 1658 | * Sets the mapped subclasses of this class. |
||
| 1659 | * |
||
| 1660 | * @param string[] $subclasses The names of all mapped subclasses. |
||
| 1661 | */ |
||
| 1662 | 2 | public function setSubclasses(array $subclasses) |
|
| 1668 | |||
| 1669 | /** |
||
| 1670 | * Sets the parent class names. |
||
| 1671 | * Assumes that the class names in the passed array are in the order: |
||
| 1672 | * directParent -> directParentParent -> directParentParentParent ... -> root. |
||
| 1673 | * |
||
| 1674 | * @param string[] $classNames |
||
| 1675 | */ |
||
| 1676 | 1385 | public function setParentClasses(array $classNames) |
|
| 1686 | |||
| 1687 | /** |
||
| 1688 | * Checks whether the class will generate a new \MongoDB\BSON\ObjectId instance for us. |
||
| 1689 | * |
||
| 1690 | * @return bool TRUE if the class uses the AUTO generator, FALSE otherwise. |
||
| 1691 | */ |
||
| 1692 | public function isIdGeneratorAuto() |
||
| 1696 | |||
| 1697 | /** |
||
| 1698 | * Checks whether the class will use a collection to generate incremented identifiers. |
||
| 1699 | * |
||
| 1700 | * @return bool TRUE if the class uses the INCREMENT generator, FALSE otherwise. |
||
| 1701 | */ |
||
| 1702 | public function isIdGeneratorIncrement() |
||
| 1706 | |||
| 1707 | /** |
||
| 1708 | * Checks whether the class will generate a uuid id. |
||
| 1709 | * |
||
| 1710 | * @return bool TRUE if the class uses the UUID generator, FALSE otherwise. |
||
| 1711 | */ |
||
| 1712 | public function isIdGeneratorUuid() |
||
| 1716 | |||
| 1717 | /** |
||
| 1718 | * Checks whether the class uses no id generator. |
||
| 1719 | * |
||
| 1720 | * @return bool TRUE if the class does not use any id generator, FALSE otherwise. |
||
| 1721 | */ |
||
| 1722 | public function isIdGeneratorNone() |
||
| 1726 | |||
| 1727 | /** |
||
| 1728 | * Sets the version field mapping used for versioning. Sets the default |
||
| 1729 | * value to use depending on the column type. |
||
| 1730 | * |
||
| 1731 | * @param array $mapping The version field mapping array |
||
| 1732 | * |
||
| 1733 | * @throws LockException |
||
| 1734 | */ |
||
| 1735 | 84 | public function setVersionMapping(array &$mapping) |
|
| 1744 | |||
| 1745 | /** |
||
| 1746 | * Sets whether this class is to be versioned for optimistic locking. |
||
| 1747 | * |
||
| 1748 | * @param bool $bool |
||
| 1749 | */ |
||
| 1750 | 906 | public function setVersioned($bool) |
|
| 1754 | |||
| 1755 | /** |
||
| 1756 | * Sets the name of the field that is to be used for versioning if this class is |
||
| 1757 | * versioned for optimistic locking. |
||
| 1758 | * |
||
| 1759 | * @param string $versionField |
||
| 1760 | */ |
||
| 1761 | 906 | public function setVersionField($versionField) |
|
| 1765 | |||
| 1766 | /** |
||
| 1767 | * Sets the version field mapping used for versioning. Sets the default |
||
| 1768 | * value to use depending on the column type. |
||
| 1769 | * |
||
| 1770 | * @param array $mapping The version field mapping array |
||
| 1771 | * |
||
| 1772 | * @throws LockException |
||
| 1773 | */ |
||
| 1774 | 22 | public function setLockMapping(array &$mapping) |
|
| 1783 | |||
| 1784 | /** |
||
| 1785 | * Sets whether this class is to allow pessimistic locking. |
||
| 1786 | * |
||
| 1787 | * @param bool $bool |
||
| 1788 | */ |
||
| 1789 | public function setLockable($bool) |
||
| 1793 | |||
| 1794 | /** |
||
| 1795 | * Sets the name of the field that is to be used for storing whether a document |
||
| 1796 | * is currently locked or not. |
||
| 1797 | * |
||
| 1798 | * @param string $lockField |
||
| 1799 | */ |
||
| 1800 | public function setLockField($lockField) |
||
| 1804 | |||
| 1805 | /** |
||
| 1806 | * Marks this class as read only, no change tracking is applied to it. |
||
| 1807 | */ |
||
| 1808 | 5 | public function markReadOnly() |
|
| 1812 | |||
| 1813 | /** |
||
| 1814 | * {@inheritDoc} |
||
| 1815 | */ |
||
| 1816 | public function getFieldNames() |
||
| 1820 | |||
| 1821 | /** |
||
| 1822 | * {@inheritDoc} |
||
| 1823 | */ |
||
| 1824 | public function getAssociationNames() |
||
| 1828 | |||
| 1829 | /** |
||
| 1830 | * {@inheritDoc} |
||
| 1831 | */ |
||
| 1832 | 23 | public function getTypeOfField($fieldName) |
|
| 1837 | |||
| 1838 | /** |
||
| 1839 | * {@inheritDoc} |
||
| 1840 | */ |
||
| 1841 | 4 | public function getAssociationTargetClass($assocName) |
|
| 1849 | |||
| 1850 | /** |
||
| 1851 | * Retrieve the collectionClass associated with an association |
||
| 1852 | * |
||
| 1853 | * @param string $assocName |
||
| 1854 | */ |
||
| 1855 | 1 | public function getAssociationCollectionClass($assocName) |
|
| 1867 | |||
| 1868 | /** |
||
| 1869 | * {@inheritDoc} |
||
| 1870 | */ |
||
| 1871 | public function isAssociationInverseSide($fieldName) |
||
| 1875 | |||
| 1876 | /** |
||
| 1877 | * {@inheritDoc} |
||
| 1878 | */ |
||
| 1879 | public function getAssociationMappedByTargetField($fieldName) |
||
| 1883 | |||
| 1884 | /** |
||
| 1885 | * Map a field. |
||
| 1886 | * |
||
| 1887 | * @param array $mapping The mapping information. |
||
| 1888 | * |
||
| 1889 | * @return array |
||
| 1890 | * |
||
| 1891 | * @throws MappingException |
||
| 1892 | */ |
||
| 1893 | 1425 | public function mapField(array $mapping) |
|
| 2055 | |||
| 2056 | /** |
||
| 2057 | * Determines which fields get serialized. |
||
| 2058 | * |
||
| 2059 | * It is only serialized what is necessary for best unserialization performance. |
||
| 2060 | * That means any metadata properties that are not set or empty or simply have |
||
| 2061 | * their default value are NOT serialized. |
||
| 2062 | * |
||
| 2063 | * Parts that are also NOT serialized because they can not be properly unserialized: |
||
| 2064 | * - reflClass (ReflectionClass) |
||
| 2065 | * - reflFields (ReflectionProperty array) |
||
| 2066 | * |
||
| 2067 | * @return array The names of all the fields that should be serialized. |
||
| 2068 | */ |
||
| 2069 | 6 | public function __sleep() |
|
| 2142 | |||
| 2143 | /** |
||
| 2144 | * Restores some state that can not be serialized/unserialized. |
||
| 2145 | * |
||
| 2146 | */ |
||
| 2147 | 6 | public function __wakeup() |
|
| 2163 | |||
| 2164 | /** |
||
| 2165 | * Creates a new instance of the mapped class, without invoking the constructor. |
||
| 2166 | * |
||
| 2167 | * @return object |
||
| 2168 | */ |
||
| 2169 | 355 | public function newInstance() |
|
| 2173 | } |
||
| 2174 |
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..