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 |
||
| 52 | class ClassMetadataInfo implements ClassMetadata |
||
| 53 | { |
||
| 54 | /* The inheritance mapping types */ |
||
| 55 | /** |
||
| 56 | * NONE means the class does not participate in an inheritance hierarchy |
||
| 57 | * and therefore does not need an inheritance mapping type. |
||
| 58 | */ |
||
| 59 | const INHERITANCE_TYPE_NONE = 1; |
||
| 60 | |||
| 61 | /** |
||
| 62 | * JOINED means the class will be persisted according to the rules of |
||
| 63 | * <tt>Class Table Inheritance</tt>. |
||
| 64 | */ |
||
| 65 | const INHERITANCE_TYPE_JOINED = 2; |
||
| 66 | |||
| 67 | /** |
||
| 68 | * SINGLE_TABLE means the class will be persisted according to the rules of |
||
| 69 | * <tt>Single Table Inheritance</tt>. |
||
| 70 | */ |
||
| 71 | const INHERITANCE_TYPE_SINGLE_TABLE = 3; |
||
| 72 | |||
| 73 | /** |
||
| 74 | * TABLE_PER_CLASS means the class will be persisted according to the rules |
||
| 75 | * of <tt>Concrete Table Inheritance</tt>. |
||
| 76 | */ |
||
| 77 | const INHERITANCE_TYPE_TABLE_PER_CLASS = 4; |
||
| 78 | |||
| 79 | /* The Id generator types. */ |
||
| 80 | /** |
||
| 81 | * AUTO means the generator type will depend on what the used platform prefers. |
||
| 82 | * Offers full portability. |
||
| 83 | */ |
||
| 84 | const GENERATOR_TYPE_AUTO = 1; |
||
| 85 | |||
| 86 | /** |
||
| 87 | * SEQUENCE means a separate sequence object will be used. Platforms that do |
||
| 88 | * not have native sequence support may emulate it. Full portability is currently |
||
| 89 | * not guaranteed. |
||
| 90 | */ |
||
| 91 | const GENERATOR_TYPE_SEQUENCE = 2; |
||
| 92 | |||
| 93 | /** |
||
| 94 | * TABLE means a separate table is used for id generation. |
||
| 95 | * Offers full portability. |
||
| 96 | */ |
||
| 97 | const GENERATOR_TYPE_TABLE = 3; |
||
| 98 | |||
| 99 | /** |
||
| 100 | * IDENTITY means an identity column is used for id generation. The database |
||
| 101 | * will fill in the id column on insertion. Platforms that do not support |
||
| 102 | * native identity columns may emulate them. Full portability is currently |
||
| 103 | * not guaranteed. |
||
| 104 | */ |
||
| 105 | const GENERATOR_TYPE_IDENTITY = 4; |
||
| 106 | |||
| 107 | /** |
||
| 108 | * NONE means the class does not have a generated id. That means the class |
||
| 109 | * must have a natural, manually assigned id. |
||
| 110 | */ |
||
| 111 | const GENERATOR_TYPE_NONE = 5; |
||
| 112 | |||
| 113 | /** |
||
| 114 | * UUID means that a UUID/GUID expression is used for id generation. Full |
||
| 115 | * portability is currently not guaranteed. |
||
| 116 | */ |
||
| 117 | const GENERATOR_TYPE_UUID = 6; |
||
| 118 | |||
| 119 | /** |
||
| 120 | * CUSTOM means that customer will use own ID generator that supposedly work |
||
| 121 | */ |
||
| 122 | const GENERATOR_TYPE_CUSTOM = 7; |
||
| 123 | |||
| 124 | /** |
||
| 125 | * DEFERRED_IMPLICIT means that changes of entities are calculated at commit-time |
||
| 126 | * by doing a property-by-property comparison with the original data. This will |
||
| 127 | * be done for all entities that are in MANAGED state at commit-time. |
||
| 128 | * |
||
| 129 | * This is the default change tracking policy. |
||
| 130 | */ |
||
| 131 | const CHANGETRACKING_DEFERRED_IMPLICIT = 1; |
||
| 132 | |||
| 133 | /** |
||
| 134 | * DEFERRED_EXPLICIT means that changes of entities are calculated at commit-time |
||
| 135 | * by doing a property-by-property comparison with the original data. This will |
||
| 136 | * be done only for entities that were explicitly saved (through persist() or a cascade). |
||
| 137 | */ |
||
| 138 | const CHANGETRACKING_DEFERRED_EXPLICIT = 2; |
||
| 139 | |||
| 140 | /** |
||
| 141 | * NOTIFY means that Doctrine relies on the entities sending out notifications |
||
| 142 | * when their properties change. Such entity classes must implement |
||
| 143 | * the <tt>NotifyPropertyChanged</tt> interface. |
||
| 144 | */ |
||
| 145 | const CHANGETRACKING_NOTIFY = 3; |
||
| 146 | |||
| 147 | /** |
||
| 148 | * Specifies that an association is to be fetched when it is first accessed. |
||
| 149 | */ |
||
| 150 | const FETCH_LAZY = 2; |
||
| 151 | |||
| 152 | /** |
||
| 153 | * Specifies that an association is to be fetched when the owner of the |
||
| 154 | * association is fetched. |
||
| 155 | */ |
||
| 156 | const FETCH_EAGER = 3; |
||
| 157 | |||
| 158 | /** |
||
| 159 | * Specifies that an association is to be fetched lazy (on first access) and that |
||
| 160 | * commands such as Collection#count, Collection#slice are issued directly against |
||
| 161 | * the database if the collection is not yet initialized. |
||
| 162 | */ |
||
| 163 | const FETCH_EXTRA_LAZY = 4; |
||
| 164 | |||
| 165 | /** |
||
| 166 | * Identifies a one-to-one association. |
||
| 167 | */ |
||
| 168 | const ONE_TO_ONE = 1; |
||
| 169 | |||
| 170 | /** |
||
| 171 | * Identifies a many-to-one association. |
||
| 172 | */ |
||
| 173 | const MANY_TO_ONE = 2; |
||
| 174 | |||
| 175 | /** |
||
| 176 | * Identifies a one-to-many association. |
||
| 177 | */ |
||
| 178 | const ONE_TO_MANY = 4; |
||
| 179 | |||
| 180 | /** |
||
| 181 | * Identifies a many-to-many association. |
||
| 182 | */ |
||
| 183 | const MANY_TO_MANY = 8; |
||
| 184 | |||
| 185 | /** |
||
| 186 | * Combined bitmask for to-one (single-valued) associations. |
||
| 187 | */ |
||
| 188 | const TO_ONE = 3; |
||
| 189 | |||
| 190 | /** |
||
| 191 | * Combined bitmask for to-many (collection-valued) associations. |
||
| 192 | */ |
||
| 193 | const TO_MANY = 12; |
||
| 194 | |||
| 195 | /** |
||
| 196 | * ReadOnly cache can do reads, inserts and deletes, cannot perform updates or employ any locks, |
||
| 197 | */ |
||
| 198 | const CACHE_USAGE_READ_ONLY = 1; |
||
| 199 | |||
| 200 | /** |
||
| 201 | * Nonstrict Read Write Cache doesn’t employ any locks but can do inserts, update and deletes. |
||
| 202 | */ |
||
| 203 | const CACHE_USAGE_NONSTRICT_READ_WRITE = 2; |
||
| 204 | |||
| 205 | /** |
||
| 206 | * Read Write Attempts to lock the entity before update/delete. |
||
| 207 | */ |
||
| 208 | const CACHE_USAGE_READ_WRITE = 3; |
||
| 209 | |||
| 210 | /** |
||
| 211 | * READ-ONLY: The name of the entity class. |
||
| 212 | * |
||
| 213 | * @var string |
||
| 214 | */ |
||
| 215 | public $name; |
||
| 216 | |||
| 217 | /** |
||
| 218 | * READ-ONLY: The namespace the entity class is contained in. |
||
| 219 | * |
||
| 220 | * @var string |
||
| 221 | * |
||
| 222 | * @todo Not really needed. Usage could be localized. |
||
| 223 | */ |
||
| 224 | public $namespace; |
||
| 225 | |||
| 226 | /** |
||
| 227 | * READ-ONLY: The name of the entity class that is at the root of the mapped entity inheritance |
||
| 228 | * hierarchy. If the entity is not part of a mapped inheritance hierarchy this is the same |
||
| 229 | * as {@link $name}. |
||
| 230 | * |
||
| 231 | * @var string |
||
| 232 | */ |
||
| 233 | public $rootEntityName; |
||
| 234 | |||
| 235 | /** |
||
| 236 | * READ-ONLY: The definition of custom generator. Only used for CUSTOM |
||
| 237 | * generator type |
||
| 238 | * |
||
| 239 | * The definition has the following structure: |
||
| 240 | * <code> |
||
| 241 | * array( |
||
| 242 | * 'class' => 'ClassName', |
||
| 243 | * ) |
||
| 244 | * </code> |
||
| 245 | * |
||
| 246 | * @var array |
||
| 247 | * |
||
| 248 | * @todo Merge with tableGeneratorDefinition into generic generatorDefinition |
||
| 249 | */ |
||
| 250 | public $customGeneratorDefinition; |
||
| 251 | |||
| 252 | /** |
||
| 253 | * The name of the custom repository class used for the entity class. |
||
| 254 | * (Optional). |
||
| 255 | * |
||
| 256 | * @var string |
||
| 257 | */ |
||
| 258 | public $customRepositoryClassName; |
||
| 259 | |||
| 260 | /** |
||
| 261 | * READ-ONLY: Whether this class describes the mapping of a mapped superclass. |
||
| 262 | * |
||
| 263 | * @var boolean |
||
| 264 | */ |
||
| 265 | public $isMappedSuperclass = false; |
||
| 266 | |||
| 267 | /** |
||
| 268 | * READ-ONLY: Whether this class describes the mapping of an embeddable class. |
||
| 269 | * |
||
| 270 | * @var boolean |
||
| 271 | */ |
||
| 272 | public $isEmbeddedClass = false; |
||
| 273 | |||
| 274 | /** |
||
| 275 | * READ-ONLY: The names of the parent classes (ancestors). |
||
| 276 | * |
||
| 277 | * @var array |
||
| 278 | */ |
||
| 279 | public $parentClasses = []; |
||
| 280 | |||
| 281 | /** |
||
| 282 | * READ-ONLY: The names of all subclasses (descendants). |
||
| 283 | * |
||
| 284 | * @var array |
||
| 285 | */ |
||
| 286 | public $subClasses = []; |
||
| 287 | |||
| 288 | /** |
||
| 289 | * READ-ONLY: The names of all embedded classes based on properties. |
||
| 290 | * |
||
| 291 | * @var array |
||
| 292 | */ |
||
| 293 | public $embeddedClasses = []; |
||
| 294 | |||
| 295 | /** |
||
| 296 | * READ-ONLY: The named queries allowed to be called directly from Repository. |
||
| 297 | * |
||
| 298 | * @var array |
||
| 299 | */ |
||
| 300 | public $namedQueries = []; |
||
| 301 | |||
| 302 | /** |
||
| 303 | * READ-ONLY: The named native queries allowed to be called directly from Repository. |
||
| 304 | * |
||
| 305 | * A native SQL named query definition has the following structure: |
||
| 306 | * <pre> |
||
| 307 | * array( |
||
| 308 | * 'name' => <query name>, |
||
| 309 | * 'query' => <sql query>, |
||
| 310 | * 'resultClass' => <class of the result>, |
||
| 311 | * 'resultSetMapping' => <name of a SqlResultSetMapping> |
||
| 312 | * ) |
||
| 313 | * </pre> |
||
| 314 | * |
||
| 315 | * @var array |
||
| 316 | */ |
||
| 317 | public $namedNativeQueries = []; |
||
| 318 | |||
| 319 | /** |
||
| 320 | * READ-ONLY: The mappings of the results of native SQL queries. |
||
| 321 | * |
||
| 322 | * A native result mapping definition has the following structure: |
||
| 323 | * <pre> |
||
| 324 | * array( |
||
| 325 | * 'name' => <result name>, |
||
| 326 | * 'entities' => array(<entity result mapping>), |
||
| 327 | * 'columns' => array(<column result mapping>) |
||
| 328 | * ) |
||
| 329 | * </pre> |
||
| 330 | * |
||
| 331 | * @var array |
||
| 332 | */ |
||
| 333 | public $sqlResultSetMappings = []; |
||
| 334 | |||
| 335 | /** |
||
| 336 | * READ-ONLY: The field names of all fields that are part of the identifier/primary key |
||
| 337 | * of the mapped entity class. |
||
| 338 | * |
||
| 339 | * @var array |
||
| 340 | */ |
||
| 341 | public $identifier = []; |
||
| 342 | |||
| 343 | /** |
||
| 344 | * READ-ONLY: The inheritance mapping type used by the class. |
||
| 345 | * |
||
| 346 | * @var integer |
||
| 347 | */ |
||
| 348 | public $inheritanceType = self::INHERITANCE_TYPE_NONE; |
||
| 349 | |||
| 350 | /** |
||
| 351 | * READ-ONLY: The Id generator type used by the class. |
||
| 352 | * |
||
| 353 | * @var int |
||
| 354 | */ |
||
| 355 | public $generatorType = self::GENERATOR_TYPE_NONE; |
||
| 356 | |||
| 357 | /** |
||
| 358 | * READ-ONLY: The field mappings of the class. |
||
| 359 | * Keys are field names and values are mapping definitions. |
||
| 360 | * |
||
| 361 | * The mapping definition array has the following values: |
||
| 362 | * |
||
| 363 | * - <b>fieldName</b> (string) |
||
| 364 | * The name of the field in the Entity. |
||
| 365 | * |
||
| 366 | * - <b>type</b> (string) |
||
| 367 | * The type name of the mapped field. Can be one of Doctrine's mapping types |
||
| 368 | * or a custom mapping type. |
||
| 369 | * |
||
| 370 | * - <b>columnName</b> (string, optional) |
||
| 371 | * The column name. Optional. Defaults to the field name. |
||
| 372 | * |
||
| 373 | * - <b>length</b> (integer, optional) |
||
| 374 | * The database length of the column. Optional. Default value taken from |
||
| 375 | * the type. |
||
| 376 | * |
||
| 377 | * - <b>id</b> (boolean, optional) |
||
| 378 | * Marks the field as the primary key of the entity. Multiple fields of an |
||
| 379 | * entity can have the id attribute, forming a composite key. |
||
| 380 | * |
||
| 381 | * - <b>nullable</b> (boolean, optional) |
||
| 382 | * Whether the column is nullable. Defaults to FALSE. |
||
| 383 | * |
||
| 384 | * - <b>columnDefinition</b> (string, optional, schema-only) |
||
| 385 | * The SQL fragment that is used when generating the DDL for the column. |
||
| 386 | * |
||
| 387 | * - <b>precision</b> (integer, optional, schema-only) |
||
| 388 | * The precision of a decimal column. Only valid if the column type is decimal. |
||
| 389 | * |
||
| 390 | * - <b>scale</b> (integer, optional, schema-only) |
||
| 391 | * The scale of a decimal column. Only valid if the column type is decimal. |
||
| 392 | * |
||
| 393 | * - <b>'unique'</b> (string, optional, schema-only) |
||
| 394 | * Whether a unique constraint should be generated for the column. |
||
| 395 | * |
||
| 396 | * @var array |
||
| 397 | */ |
||
| 398 | public $fieldMappings = []; |
||
| 399 | |||
| 400 | /** |
||
| 401 | * READ-ONLY: An array of field names. Used to look up field names from column names. |
||
| 402 | * Keys are column names and values are field names. |
||
| 403 | * |
||
| 404 | * @var array |
||
| 405 | */ |
||
| 406 | public $fieldNames = []; |
||
| 407 | |||
| 408 | /** |
||
| 409 | * READ-ONLY: A map of field names to column names. Keys are field names and values column names. |
||
| 410 | * Used to look up column names from field names. |
||
| 411 | * This is the reverse lookup map of $_fieldNames. |
||
| 412 | * |
||
| 413 | * @var array |
||
| 414 | * |
||
| 415 | * @deprecated 3.0 Remove this. |
||
| 416 | */ |
||
| 417 | public $columnNames = []; |
||
| 418 | |||
| 419 | /** |
||
| 420 | * READ-ONLY: The discriminator value of this class. |
||
| 421 | * |
||
| 422 | * <b>This does only apply to the JOINED and SINGLE_TABLE inheritance mapping strategies |
||
| 423 | * where a discriminator column is used.</b> |
||
| 424 | * |
||
| 425 | * @var mixed |
||
| 426 | * |
||
| 427 | * @see discriminatorColumn |
||
| 428 | */ |
||
| 429 | public $discriminatorValue; |
||
| 430 | |||
| 431 | /** |
||
| 432 | * READ-ONLY: The discriminator map of all mapped classes in the hierarchy. |
||
| 433 | * |
||
| 434 | * <b>This does only apply to the JOINED and SINGLE_TABLE inheritance mapping strategies |
||
| 435 | * where a discriminator column is used.</b> |
||
| 436 | * |
||
| 437 | * @var mixed |
||
| 438 | * |
||
| 439 | * @see discriminatorColumn |
||
| 440 | */ |
||
| 441 | public $discriminatorMap = []; |
||
| 442 | |||
| 443 | /** |
||
| 444 | * READ-ONLY: The definition of the discriminator column used in JOINED and SINGLE_TABLE |
||
| 445 | * inheritance mappings. |
||
| 446 | * |
||
| 447 | * @var array |
||
| 448 | */ |
||
| 449 | public $discriminatorColumn; |
||
| 450 | |||
| 451 | /** |
||
| 452 | * READ-ONLY: The primary table definition. The definition is an array with the |
||
| 453 | * following entries: |
||
| 454 | * |
||
| 455 | * name => <tableName> |
||
| 456 | * schema => <schemaName> |
||
| 457 | * indexes => array |
||
| 458 | * uniqueConstraints => array |
||
| 459 | * |
||
| 460 | * @var array |
||
| 461 | */ |
||
| 462 | public $table; |
||
| 463 | |||
| 464 | /** |
||
| 465 | * READ-ONLY: The registered lifecycle callbacks for entities of this class. |
||
| 466 | * |
||
| 467 | * @var array[] |
||
| 468 | */ |
||
| 469 | public $lifecycleCallbacks = []; |
||
| 470 | |||
| 471 | /** |
||
| 472 | * READ-ONLY: The registered entity listeners. |
||
| 473 | * |
||
| 474 | * @var array |
||
| 475 | */ |
||
| 476 | public $entityListeners = []; |
||
| 477 | |||
| 478 | /** |
||
| 479 | * READ-ONLY: The association mappings of this class. |
||
| 480 | * |
||
| 481 | * The mapping definition array supports the following keys: |
||
| 482 | * |
||
| 483 | * - <b>fieldName</b> (string) |
||
| 484 | * The name of the field in the entity the association is mapped to. |
||
| 485 | * |
||
| 486 | * - <b>targetEntity</b> (string) |
||
| 487 | * The class name of the target entity. If it is fully-qualified it is used as is. |
||
| 488 | * If it is a simple, unqualified class name the namespace is assumed to be the same |
||
| 489 | * as the namespace of the source entity. |
||
| 490 | * |
||
| 491 | * - <b>mappedBy</b> (string, required for bidirectional associations) |
||
| 492 | * The name of the field that completes the bidirectional association on the owning side. |
||
| 493 | * This key must be specified on the inverse side of a bidirectional association. |
||
| 494 | * |
||
| 495 | * - <b>inversedBy</b> (string, required for bidirectional associations) |
||
| 496 | * The name of the field that completes the bidirectional association on the inverse side. |
||
| 497 | * This key must be specified on the owning side of a bidirectional association. |
||
| 498 | * |
||
| 499 | * - <b>cascade</b> (array, optional) |
||
| 500 | * The names of persistence operations to cascade on the association. The set of possible |
||
| 501 | * values are: "persist", "remove", "detach", "merge", "refresh", "all" (implies all others). |
||
| 502 | * |
||
| 503 | * - <b>orderBy</b> (array, one-to-many/many-to-many only) |
||
| 504 | * A map of field names (of the target entity) to sorting directions (ASC/DESC). |
||
| 505 | * Example: array('priority' => 'desc') |
||
| 506 | * |
||
| 507 | * - <b>fetch</b> (integer, optional) |
||
| 508 | * The fetching strategy to use for the association, usually defaults to FETCH_LAZY. |
||
| 509 | * Possible values are: ClassMetadata::FETCH_EAGER, ClassMetadata::FETCH_LAZY. |
||
| 510 | * |
||
| 511 | * - <b>joinTable</b> (array, optional, many-to-many only) |
||
| 512 | * Specification of the join table and its join columns (foreign keys). |
||
| 513 | * Only valid for many-to-many mappings. Note that one-to-many associations can be mapped |
||
| 514 | * through a join table by simply mapping the association as many-to-many with a unique |
||
| 515 | * constraint on the join table. |
||
| 516 | * |
||
| 517 | * - <b>indexBy</b> (string, optional, to-many only) |
||
| 518 | * Specification of a field on target-entity that is used to index the collection by. |
||
| 519 | * This field HAS to be either the primary key or a unique column. Otherwise the collection |
||
| 520 | * does not contain all the entities that are actually related. |
||
| 521 | * |
||
| 522 | * A join table definition has the following structure: |
||
| 523 | * <pre> |
||
| 524 | * array( |
||
| 525 | * 'name' => <join table name>, |
||
| 526 | * 'joinColumns' => array(<join column mapping from join table to source table>), |
||
| 527 | * 'inverseJoinColumns' => array(<join column mapping from join table to target table>) |
||
| 528 | * ) |
||
| 529 | * </pre> |
||
| 530 | * |
||
| 531 | * @var array |
||
| 532 | */ |
||
| 533 | public $associationMappings = []; |
||
| 534 | |||
| 535 | /** |
||
| 536 | * READ-ONLY: Flag indicating whether the identifier/primary key of the class is composite. |
||
| 537 | * |
||
| 538 | * @var boolean |
||
| 539 | */ |
||
| 540 | public $isIdentifierComposite = false; |
||
| 541 | |||
| 542 | /** |
||
| 543 | * READ-ONLY: Flag indicating whether the identifier/primary key contains at least one foreign key association. |
||
| 544 | * |
||
| 545 | * This flag is necessary because some code blocks require special treatment of this cases. |
||
| 546 | * |
||
| 547 | * @var boolean |
||
| 548 | */ |
||
| 549 | public $containsForeignIdentifier = false; |
||
| 550 | |||
| 551 | /** |
||
| 552 | * READ-ONLY: The ID generator used for generating IDs for this class. |
||
| 553 | * |
||
| 554 | * @var \Doctrine\ORM\Id\AbstractIdGenerator |
||
| 555 | * |
||
| 556 | * @todo Remove! |
||
| 557 | */ |
||
| 558 | public $idGenerator; |
||
| 559 | |||
| 560 | /** |
||
| 561 | * READ-ONLY: The definition of the sequence generator of this class. Only used for the |
||
| 562 | * SEQUENCE generation strategy. |
||
| 563 | * |
||
| 564 | * The definition has the following structure: |
||
| 565 | * <code> |
||
| 566 | * array( |
||
| 567 | * 'sequenceName' => 'name', |
||
| 568 | * 'allocationSize' => 20, |
||
| 569 | * 'initialValue' => 1 |
||
| 570 | * ) |
||
| 571 | * </code> |
||
| 572 | * |
||
| 573 | * @var array |
||
| 574 | * |
||
| 575 | * @todo Merge with tableGeneratorDefinition into generic generatorDefinition |
||
| 576 | */ |
||
| 577 | public $sequenceGeneratorDefinition; |
||
| 578 | |||
| 579 | /** |
||
| 580 | * READ-ONLY: The definition of the table generator of this class. Only used for the |
||
| 581 | * TABLE generation strategy. |
||
| 582 | * |
||
| 583 | * @var array |
||
| 584 | * |
||
| 585 | * @todo Merge with tableGeneratorDefinition into generic generatorDefinition |
||
| 586 | */ |
||
| 587 | public $tableGeneratorDefinition; |
||
| 588 | |||
| 589 | /** |
||
| 590 | * READ-ONLY: The policy used for change-tracking on entities of this class. |
||
| 591 | * |
||
| 592 | * @var integer |
||
| 593 | */ |
||
| 594 | public $changeTrackingPolicy = self::CHANGETRACKING_DEFERRED_IMPLICIT; |
||
| 595 | |||
| 596 | /** |
||
| 597 | * READ-ONLY: A flag for whether or not instances of this class are to be versioned |
||
| 598 | * with optimistic locking. |
||
| 599 | * |
||
| 600 | * @var boolean |
||
| 601 | */ |
||
| 602 | public $isVersioned; |
||
| 603 | |||
| 604 | /** |
||
| 605 | * READ-ONLY: The name of the field which is used for versioning in optimistic locking (if any). |
||
| 606 | * |
||
| 607 | * @var mixed |
||
| 608 | */ |
||
| 609 | public $versionField; |
||
| 610 | |||
| 611 | /** |
||
| 612 | * @var array |
||
| 613 | */ |
||
| 614 | public $cache = null; |
||
| 615 | |||
| 616 | /** |
||
| 617 | * The ReflectionClass instance of the mapped class. |
||
| 618 | * |
||
| 619 | * @var ReflectionClass |
||
| 620 | */ |
||
| 621 | public $reflClass; |
||
| 622 | |||
| 623 | /** |
||
| 624 | * Is this entity marked as "read-only"? |
||
| 625 | * |
||
| 626 | * That means it is never considered for change-tracking in the UnitOfWork. It is a very helpful performance |
||
| 627 | * optimization for entities that are immutable, either in your domain or through the relation database |
||
| 628 | * (coming from a view, or a history table for example). |
||
| 629 | * |
||
| 630 | * @var bool |
||
| 631 | */ |
||
| 632 | public $isReadOnly = false; |
||
| 633 | |||
| 634 | /** |
||
| 635 | * NamingStrategy determining the default column and table names. |
||
| 636 | * |
||
| 637 | * @var \Doctrine\ORM\Mapping\NamingStrategy |
||
| 638 | */ |
||
| 639 | protected $namingStrategy; |
||
| 640 | |||
| 641 | /** |
||
| 642 | * The ReflectionProperty instances of the mapped class. |
||
| 643 | * |
||
| 644 | * @var \ReflectionProperty[] |
||
| 645 | */ |
||
| 646 | public $reflFields = []; |
||
| 647 | |||
| 648 | /** |
||
| 649 | * @var \Doctrine\Instantiator\InstantiatorInterface|null |
||
| 650 | */ |
||
| 651 | private $instantiator; |
||
| 652 | |||
| 653 | /** |
||
| 654 | * Initializes a new ClassMetadata instance that will hold the object-relational mapping |
||
| 655 | * metadata of the class with the given name. |
||
| 656 | * |
||
| 657 | * @param string $entityName The name of the entity class the new instance is used for. |
||
| 658 | * @param NamingStrategy|null $namingStrategy |
||
| 659 | */ |
||
| 660 | 673 | public function __construct($entityName, NamingStrategy $namingStrategy = null) |
|
| 661 | { |
||
| 662 | 673 | $this->name = $entityName; |
|
| 663 | 673 | $this->rootEntityName = $entityName; |
|
| 664 | 673 | $this->namingStrategy = $namingStrategy ?: new DefaultNamingStrategy(); |
|
| 665 | 673 | $this->instantiator = new Instantiator(); |
|
| 666 | 673 | } |
|
| 667 | |||
| 668 | /** |
||
| 669 | * Gets the ReflectionProperties of the mapped class. |
||
| 670 | * |
||
| 671 | * @return array An array of ReflectionProperty instances. |
||
| 672 | */ |
||
| 673 | 229 | public function getReflectionProperties() |
|
| 674 | { |
||
| 675 | 229 | return $this->reflFields; |
|
| 676 | } |
||
| 677 | |||
| 678 | /** |
||
| 679 | * Gets a ReflectionProperty for a specific field of the mapped class. |
||
| 680 | * |
||
| 681 | * @param string $name |
||
| 682 | * |
||
| 683 | * @return \ReflectionProperty |
||
| 684 | */ |
||
| 685 | 1 | public function getReflectionProperty($name) |
|
| 686 | { |
||
| 687 | 1 | return $this->reflFields[$name]; |
|
| 688 | } |
||
| 689 | |||
| 690 | /** |
||
| 691 | * Gets the ReflectionProperty for the single identifier field. |
||
| 692 | * |
||
| 693 | * @return \ReflectionProperty |
||
| 694 | * |
||
| 695 | * @throws BadMethodCallException If the class has a composite identifier. |
||
| 696 | */ |
||
| 697 | public function getSingleIdReflectionProperty() |
||
| 698 | { |
||
| 699 | if ($this->isIdentifierComposite) { |
||
| 700 | throw new BadMethodCallException("Class " . $this->name . " has a composite identifier."); |
||
| 701 | } |
||
| 702 | |||
| 703 | return $this->reflFields[$this->identifier[0]]; |
||
| 704 | } |
||
| 705 | |||
| 706 | /** |
||
| 707 | * Extracts the identifier values of an entity of this class. |
||
| 708 | * |
||
| 709 | * For composite identifiers, the identifier values are returned as an array |
||
| 710 | * with the same order as the field order in {@link identifier}. |
||
| 711 | * |
||
| 712 | * @param object $entity |
||
| 713 | * |
||
| 714 | * @return array |
||
| 715 | */ |
||
| 716 | 475 | public function getIdentifierValues($entity) |
|
| 717 | { |
||
| 718 | 475 | if ($this->isIdentifierComposite) { |
|
| 719 | 92 | $id = []; |
|
| 720 | |||
| 721 | 92 | foreach ($this->identifier as $idField) { |
|
| 722 | 92 | $value = $this->getIndentifierValue($entity, $idField); |
|
| 723 | |||
| 724 | 92 | if (null !== $value) { |
|
| 725 | 92 | $id[$idField] = $value; |
|
| 726 | } |
||
| 727 | } |
||
| 728 | |||
| 729 | 92 | return $id; |
|
| 730 | } |
||
| 731 | |||
| 732 | 456 | $id = $this->identifier[0]; |
|
| 733 | 456 | $value = $this->getIndentifierValue($entity, $id); |
|
| 734 | |||
| 735 | 456 | if (null === $value) { |
|
| 736 | 28 | return []; |
|
| 737 | } |
||
| 738 | |||
| 739 | 432 | return [$id => $value]; |
|
| 740 | } |
||
| 741 | |||
| 742 | 475 | private function getIndentifierValue($entity, $id) |
|
| 743 | { |
||
| 744 | 475 | if ($entity instanceof AssociationCacheEntry) { |
|
| 745 | 1 | return $entity->identifier[$id]; |
|
| 746 | } |
||
| 747 | |||
| 748 | 475 | return $this->reflFields[$id]->getValue($entity); |
|
| 749 | } |
||
| 750 | |||
| 751 | /** |
||
| 752 | * Populates the entity identifier of an entity. |
||
| 753 | * |
||
| 754 | * @param object $entity |
||
| 755 | * @param array $id |
||
| 756 | * |
||
| 757 | * @return void |
||
| 758 | * |
||
| 759 | * @todo Rename to assignIdentifier() |
||
| 760 | */ |
||
| 761 | 7 | public function setIdentifierValues($entity, array $id) |
|
| 767 | |||
| 768 | /** |
||
| 769 | * Sets the specified field to the specified value on the given entity. |
||
| 770 | * |
||
| 771 | * @param object $entity |
||
| 772 | * @param string $field |
||
| 773 | * @param mixed $value |
||
| 774 | * |
||
| 775 | * @return void |
||
| 776 | */ |
||
| 777 | 231 | public function setFieldValue($entity, $field, $value) |
|
| 781 | |||
| 782 | /** |
||
| 783 | * Gets the specified field's value off the given entity. |
||
| 784 | * |
||
| 785 | * @param object $entity |
||
| 786 | * @param string $field |
||
| 787 | * |
||
| 788 | * @return mixed |
||
| 789 | */ |
||
| 790 | 317 | public function getFieldValue($entity, $field) |
|
| 794 | |||
| 795 | /** |
||
| 796 | * Creates a string representation of this instance. |
||
| 797 | * |
||
| 798 | * @return string The string representation of this instance. |
||
| 799 | * |
||
| 800 | * @todo Construct meaningful string representation. |
||
| 801 | */ |
||
| 802 | public function __toString() |
||
| 806 | |||
| 807 | /** |
||
| 808 | * Determines which fields get serialized. |
||
| 809 | * |
||
| 810 | * It is only serialized what is necessary for best unserialization performance. |
||
| 811 | * That means any metadata properties that are not set or empty or simply have |
||
| 812 | * their default value are NOT serialized. |
||
| 813 | * |
||
| 814 | * Parts that are also NOT serialized because they can not be properly unserialized: |
||
| 815 | * - reflClass (ReflectionClass) |
||
| 816 | * - reflFields (ReflectionProperty array) |
||
| 817 | * |
||
| 818 | * @return array The names of all the fields that should be serialized. |
||
| 819 | */ |
||
| 820 | 6 | public function __sleep() |
|
| 914 | |||
| 915 | /** |
||
| 916 | * Creates a new instance of the mapped class, without invoking the constructor. |
||
| 917 | * |
||
| 918 | * @return object |
||
| 919 | */ |
||
| 920 | 684 | public function newInstance() |
|
| 924 | |||
| 925 | /** |
||
| 926 | * Restores some state that can not be serialized/unserialized. |
||
| 927 | * |
||
| 928 | * @param \Doctrine\Common\Persistence\Mapping\ReflectionService $reflService |
||
| 929 | * |
||
| 930 | * @return void |
||
| 931 | */ |
||
| 932 | 2041 | public function wakeupReflection($reflService) |
|
| 984 | |||
| 985 | /** |
||
| 986 | * Initializes a new ClassMetadata instance that will hold the object-relational mapping |
||
| 987 | * metadata of the class with the given name. |
||
| 988 | * |
||
| 989 | * @param \Doctrine\Common\Persistence\Mapping\ReflectionService $reflService The reflection service. |
||
| 990 | * |
||
| 991 | * @return void |
||
| 992 | */ |
||
| 993 | 637 | public function initializeReflection($reflService) |
|
| 1004 | |||
| 1005 | /** |
||
| 1006 | * Validates Identifier. |
||
| 1007 | * |
||
| 1008 | * @return void |
||
| 1009 | * |
||
| 1010 | * @throws MappingException |
||
| 1011 | */ |
||
| 1012 | 426 | public function validateIdentifier() |
|
| 1027 | |||
| 1028 | /** |
||
| 1029 | * Validates association targets actually exist. |
||
| 1030 | * |
||
| 1031 | * @return void |
||
| 1032 | * |
||
| 1033 | * @throws MappingException |
||
| 1034 | */ |
||
| 1035 | 427 | public function validateAssociations() |
|
| 1043 | |||
| 1044 | /** |
||
| 1045 | * Validates lifecycle callbacks. |
||
| 1046 | * |
||
| 1047 | * @param \Doctrine\Common\Persistence\Mapping\ReflectionService $reflService |
||
| 1048 | * |
||
| 1049 | * @return void |
||
| 1050 | * |
||
| 1051 | * @throws MappingException |
||
| 1052 | */ |
||
| 1053 | 427 | public function validateLifecycleCallbacks($reflService) |
|
| 1063 | |||
| 1064 | /** |
||
| 1065 | * {@inheritDoc} |
||
| 1066 | */ |
||
| 1067 | 557 | public function getReflectionClass() |
|
| 1071 | |||
| 1072 | /** |
||
| 1073 | * @param array $cache |
||
| 1074 | * |
||
| 1075 | * @return void |
||
| 1076 | */ |
||
| 1077 | 24 | public function enableCache(array $cache) |
|
| 1089 | |||
| 1090 | /** |
||
| 1091 | * @param string $fieldName |
||
| 1092 | * @param array $cache |
||
| 1093 | * |
||
| 1094 | * @return void |
||
| 1095 | */ |
||
| 1096 | 2 | public function enableAssociationCache($fieldName, array $cache) |
|
| 1100 | |||
| 1101 | /** |
||
| 1102 | * @param string $fieldName |
||
| 1103 | * @param array $cache |
||
| 1104 | * |
||
| 1105 | * @return array |
||
| 1106 | */ |
||
| 1107 | 19 | public function getAssociationCacheDefaults($fieldName, array $cache) |
|
| 1121 | |||
| 1122 | /** |
||
| 1123 | * Sets the change tracking policy used by this class. |
||
| 1124 | * |
||
| 1125 | * @param integer $policy |
||
| 1126 | * |
||
| 1127 | * @return void |
||
| 1128 | */ |
||
| 1129 | 144 | public function setChangeTrackingPolicy($policy) |
|
| 1133 | |||
| 1134 | /** |
||
| 1135 | * Whether the change tracking policy of this class is "deferred explicit". |
||
| 1136 | * |
||
| 1137 | * @return boolean |
||
| 1138 | */ |
||
| 1139 | 270 | public function isChangeTrackingDeferredExplicit() |
|
| 1143 | |||
| 1144 | /** |
||
| 1145 | * Whether the change tracking policy of this class is "deferred implicit". |
||
| 1146 | * |
||
| 1147 | * @return boolean |
||
| 1148 | */ |
||
| 1149 | 465 | public function isChangeTrackingDeferredImplicit() |
|
| 1153 | |||
| 1154 | /** |
||
| 1155 | * Whether the change tracking policy of this class is "notify". |
||
| 1156 | * |
||
| 1157 | * @return boolean |
||
| 1158 | */ |
||
| 1159 | 300 | public function isChangeTrackingNotify() |
|
| 1163 | |||
| 1164 | /** |
||
| 1165 | * Checks whether a field is part of the identifier/primary key field(s). |
||
| 1166 | * |
||
| 1167 | * @param string $fieldName The field name. |
||
| 1168 | * |
||
| 1169 | * @return boolean TRUE if the field is part of the table identifier/primary key field(s), |
||
| 1170 | * FALSE otherwise. |
||
| 1171 | */ |
||
| 1172 | 1087 | public function isIdentifier($fieldName) |
|
| 1184 | |||
| 1185 | /** |
||
| 1186 | * Checks if the field is unique. |
||
| 1187 | * |
||
| 1188 | * @param string $fieldName The field name. |
||
| 1189 | * |
||
| 1190 | * @return boolean TRUE if the field is unique, FALSE otherwise. |
||
| 1191 | */ |
||
| 1192 | public function isUniqueField($fieldName) |
||
| 1198 | |||
| 1199 | /** |
||
| 1200 | * Checks if the field is not null. |
||
| 1201 | * |
||
| 1202 | * @param string $fieldName The field name. |
||
| 1203 | * |
||
| 1204 | * @return boolean TRUE if the field is not null, FALSE otherwise. |
||
| 1205 | */ |
||
| 1206 | 1 | public function isNullable($fieldName) |
|
| 1212 | |||
| 1213 | /** |
||
| 1214 | * Gets a column name for a field name. |
||
| 1215 | * If the column name for the field cannot be found, the given field name |
||
| 1216 | * is returned. |
||
| 1217 | * |
||
| 1218 | * @param string $fieldName The field name. |
||
| 1219 | * |
||
| 1220 | * @return string The column name. |
||
| 1221 | */ |
||
| 1222 | 16 | public function getColumnName($fieldName) |
|
| 1228 | |||
| 1229 | /** |
||
| 1230 | * Gets the mapping of a (regular) field that holds some data but not a |
||
| 1231 | * reference to another object. |
||
| 1232 | * |
||
| 1233 | * @param string $fieldName The field name. |
||
| 1234 | * |
||
| 1235 | * @return array The field mapping. |
||
| 1236 | * |
||
| 1237 | * @throws MappingException |
||
| 1238 | */ |
||
| 1239 | 202 | public function getFieldMapping($fieldName) |
|
| 1247 | |||
| 1248 | /** |
||
| 1249 | * Gets the mapping of an association. |
||
| 1250 | * |
||
| 1251 | * @see ClassMetadataInfo::$associationMappings |
||
| 1252 | * |
||
| 1253 | * @param string $fieldName The field name that represents the association in |
||
| 1254 | * the object model. |
||
| 1255 | * |
||
| 1256 | * @return array The mapping. |
||
| 1257 | * |
||
| 1258 | * @throws MappingException |
||
| 1259 | */ |
||
| 1260 | 489 | public function getAssociationMapping($fieldName) |
|
| 1268 | |||
| 1269 | /** |
||
| 1270 | * Gets all association mappings of the class. |
||
| 1271 | * |
||
| 1272 | * @return array |
||
| 1273 | */ |
||
| 1274 | public function getAssociationMappings() |
||
| 1278 | |||
| 1279 | /** |
||
| 1280 | * Gets the field name for a column name. |
||
| 1281 | * If no field name can be found the column name is returned. |
||
| 1282 | * |
||
| 1283 | * @param string $columnName The column name. |
||
| 1284 | * |
||
| 1285 | * @return string The column alias. |
||
| 1286 | */ |
||
| 1287 | 240 | public function getFieldName($columnName) |
|
| 1293 | |||
| 1294 | /** |
||
| 1295 | * Gets the named query. |
||
| 1296 | * |
||
| 1297 | * @see ClassMetadataInfo::$namedQueries |
||
| 1298 | * |
||
| 1299 | * @param string $queryName The query name. |
||
| 1300 | * |
||
| 1301 | * @return string |
||
| 1302 | * |
||
| 1303 | * @throws MappingException |
||
| 1304 | */ |
||
| 1305 | 4 | public function getNamedQuery($queryName) |
|
| 1313 | |||
| 1314 | /** |
||
| 1315 | * Gets all named queries of the class. |
||
| 1316 | * |
||
| 1317 | * @return array |
||
| 1318 | */ |
||
| 1319 | 7 | public function getNamedQueries() |
|
| 1323 | |||
| 1324 | /** |
||
| 1325 | * Gets the named native query. |
||
| 1326 | * |
||
| 1327 | * @see ClassMetadataInfo::$namedNativeQueries |
||
| 1328 | * |
||
| 1329 | * @param string $queryName The query name. |
||
| 1330 | * |
||
| 1331 | * @return array |
||
| 1332 | * |
||
| 1333 | * @throws MappingException |
||
| 1334 | */ |
||
| 1335 | 17 | public function getNamedNativeQuery($queryName) |
|
| 1343 | |||
| 1344 | /** |
||
| 1345 | * Gets all named native queries of the class. |
||
| 1346 | * |
||
| 1347 | * @return array |
||
| 1348 | */ |
||
| 1349 | 2 | public function getNamedNativeQueries() |
|
| 1353 | |||
| 1354 | /** |
||
| 1355 | * Gets the result set mapping. |
||
| 1356 | * |
||
| 1357 | * @see ClassMetadataInfo::$sqlResultSetMappings |
||
| 1358 | * |
||
| 1359 | * @param string $name The result set mapping name. |
||
| 1360 | * |
||
| 1361 | * @return array |
||
| 1362 | * |
||
| 1363 | * @throws MappingException |
||
| 1364 | */ |
||
| 1365 | 21 | public function getSqlResultSetMapping($name) |
|
| 1373 | |||
| 1374 | /** |
||
| 1375 | * Gets all sql result set mappings of the class. |
||
| 1376 | * |
||
| 1377 | * @return array |
||
| 1378 | */ |
||
| 1379 | 8 | public function getSqlResultSetMappings() |
|
| 1383 | |||
| 1384 | /** |
||
| 1385 | * Validates & completes the given field mapping. |
||
| 1386 | * |
||
| 1387 | * @param array $mapping The field mapping to validate & complete. |
||
| 1388 | * |
||
| 1389 | * @return array The validated and completed field mapping. |
||
| 1390 | * |
||
| 1391 | * @throws MappingException |
||
| 1392 | */ |
||
| 1393 | 554 | protected function _validateAndCompleteFieldMapping(array &$mapping) |
|
| 1447 | |||
| 1448 | /** |
||
| 1449 | * Validates & completes the basic mapping information that is common to all |
||
| 1450 | * association mappings (one-to-one, many-ot-one, one-to-many, many-to-many). |
||
| 1451 | * |
||
| 1452 | * @param array $mapping The mapping. |
||
| 1453 | * |
||
| 1454 | * @return array The updated mapping. |
||
| 1455 | * |
||
| 1456 | * @throws MappingException If something is wrong with the mapping. |
||
| 1457 | */ |
||
| 1458 | 358 | protected function _validateAndCompleteAssociationMapping(array $mapping) |
|
| 1568 | |||
| 1569 | /** |
||
| 1570 | * Validates & completes a one-to-one association mapping. |
||
| 1571 | * |
||
| 1572 | * @param array $mapping The mapping to validate & complete. |
||
| 1573 | * |
||
| 1574 | * @return array The validated & completed mapping. |
||
| 1575 | * |
||
| 1576 | * @throws RuntimeException |
||
| 1577 | * @throws MappingException |
||
| 1578 | */ |
||
| 1579 | 305 | protected function _validateAndCompleteOneToOneMapping(array $mapping) |
|
| 1661 | |||
| 1662 | /** |
||
| 1663 | * Validates & completes a one-to-many association mapping. |
||
| 1664 | * |
||
| 1665 | * @param array $mapping The mapping to validate and complete. |
||
| 1666 | * |
||
| 1667 | * @return array The validated and completed mapping. |
||
| 1668 | * |
||
| 1669 | * @throws MappingException |
||
| 1670 | * @throws InvalidArgumentException |
||
| 1671 | */ |
||
| 1672 | 133 | protected function _validateAndCompleteOneToManyMapping(array $mapping) |
|
| 1688 | |||
| 1689 | /** |
||
| 1690 | * Validates & completes a many-to-many association mapping. |
||
| 1691 | * |
||
| 1692 | * @param array $mapping The mapping to validate & complete. |
||
| 1693 | * |
||
| 1694 | * @return array The validated & completed mapping. |
||
| 1695 | * |
||
| 1696 | * @throws \InvalidArgumentException |
||
| 1697 | */ |
||
| 1698 | 154 | protected function _validateAndCompleteManyToManyMapping(array $mapping) |
|
| 1794 | |||
| 1795 | /** |
||
| 1796 | * {@inheritDoc} |
||
| 1797 | */ |
||
| 1798 | 615 | public function getIdentifierFieldNames() |
|
| 1802 | |||
| 1803 | /** |
||
| 1804 | * Gets the name of the single id field. Note that this only works on |
||
| 1805 | * entity classes that have a single-field pk. |
||
| 1806 | * |
||
| 1807 | * @return string |
||
| 1808 | * |
||
| 1809 | * @throws MappingException If the class has a composite primary key. |
||
| 1810 | */ |
||
| 1811 | 1144 | public function getSingleIdentifierFieldName() |
|
| 1819 | |||
| 1820 | /** |
||
| 1821 | * Gets the column name of the single id column. Note that this only works on |
||
| 1822 | * entity classes that have a single-field pk. |
||
| 1823 | * |
||
| 1824 | * @return string |
||
| 1825 | * |
||
| 1826 | * @throws MappingException If the class has a composite primary key. |
||
| 1827 | */ |
||
| 1828 | 3 | public function getSingleIdentifierColumnName() |
|
| 1832 | |||
| 1833 | /** |
||
| 1834 | * INTERNAL: |
||
| 1835 | * Sets the mapped identifier/primary key fields of this class. |
||
| 1836 | * Mainly used by the ClassMetadataFactory to assign inherited identifiers. |
||
| 1837 | * |
||
| 1838 | * @param array $identifier |
||
| 1839 | * |
||
| 1840 | * @return void |
||
| 1841 | */ |
||
| 1842 | 129 | public function setIdentifier(array $identifier) |
|
| 1847 | |||
| 1848 | /** |
||
| 1849 | * {@inheritDoc} |
||
| 1850 | */ |
||
| 1851 | 63 | public function getIdentifier() |
|
| 1855 | |||
| 1856 | /** |
||
| 1857 | * {@inheritDoc} |
||
| 1858 | */ |
||
| 1859 | 298 | public function hasField($fieldName) |
|
| 1863 | |||
| 1864 | /** |
||
| 1865 | * Gets an array containing all the column names. |
||
| 1866 | * |
||
| 1867 | * @param array|null $fieldNames |
||
| 1868 | * |
||
| 1869 | * @return array |
||
| 1870 | */ |
||
| 1871 | 43 | public function getColumnNames(array $fieldNames = null) |
|
| 1879 | |||
| 1880 | /** |
||
| 1881 | * Returns an array with all the identifier column names. |
||
| 1882 | * |
||
| 1883 | * @return array |
||
| 1884 | */ |
||
| 1885 | 325 | public function getIdentifierColumnNames() |
|
| 1905 | |||
| 1906 | /** |
||
| 1907 | * Sets the type of Id generator to use for the mapped class. |
||
| 1908 | * |
||
| 1909 | * @param int $generatorType |
||
| 1910 | * |
||
| 1911 | * @return void |
||
| 1912 | */ |
||
| 1913 | 469 | public function setIdGeneratorType($generatorType) |
|
| 1917 | |||
| 1918 | /** |
||
| 1919 | * Checks whether the mapped class uses an Id generator. |
||
| 1920 | * |
||
| 1921 | * @return boolean TRUE if the mapped class uses an Id generator, FALSE otherwise. |
||
| 1922 | */ |
||
| 1923 | 418 | public function usesIdGenerator() |
|
| 1927 | |||
| 1928 | /** |
||
| 1929 | * @return boolean |
||
| 1930 | */ |
||
| 1931 | 1357 | public function isInheritanceTypeNone() |
|
| 1935 | |||
| 1936 | /** |
||
| 1937 | * Checks whether the mapped class uses the JOINED inheritance mapping strategy. |
||
| 1938 | * |
||
| 1939 | * @return boolean TRUE if the class participates in a JOINED inheritance mapping, |
||
| 1940 | * FALSE otherwise. |
||
| 1941 | */ |
||
| 1942 | 1062 | public function isInheritanceTypeJoined() |
|
| 1946 | |||
| 1947 | /** |
||
| 1948 | * Checks whether the mapped class uses the SINGLE_TABLE inheritance mapping strategy. |
||
| 1949 | * |
||
| 1950 | * @return boolean TRUE if the class participates in a SINGLE_TABLE inheritance mapping, |
||
| 1951 | * FALSE otherwise. |
||
| 1952 | */ |
||
| 1953 | 1241 | public function isInheritanceTypeSingleTable() |
|
| 1957 | |||
| 1958 | /** |
||
| 1959 | * Checks whether the mapped class uses the TABLE_PER_CLASS inheritance mapping strategy. |
||
| 1960 | * |
||
| 1961 | * @return boolean TRUE if the class participates in a TABLE_PER_CLASS inheritance mapping, |
||
| 1962 | * FALSE otherwise. |
||
| 1963 | */ |
||
| 1964 | 265 | public function isInheritanceTypeTablePerClass() |
|
| 1968 | |||
| 1969 | /** |
||
| 1970 | * Checks whether the class uses an identity column for the Id generation. |
||
| 1971 | * |
||
| 1972 | * @return boolean TRUE if the class uses the IDENTITY generator, FALSE otherwise. |
||
| 1973 | */ |
||
| 1974 | 1076 | public function isIdGeneratorIdentity() |
|
| 1978 | |||
| 1979 | /** |
||
| 1980 | * Checks whether the class uses a sequence for id generation. |
||
| 1981 | * |
||
| 1982 | * @return boolean TRUE if the class uses the SEQUENCE generator, FALSE otherwise. |
||
| 1983 | */ |
||
| 1984 | 323 | public function isIdGeneratorSequence() |
|
| 1988 | |||
| 1989 | /** |
||
| 1990 | * Checks whether the class uses a table for id generation. |
||
| 1991 | * |
||
| 1992 | * @return boolean TRUE if the class uses the TABLE generator, FALSE otherwise. |
||
| 1993 | */ |
||
| 1994 | 85 | public function isIdGeneratorTable() |
|
| 1998 | |||
| 1999 | /** |
||
| 2000 | * Checks whether the class has a natural identifier/pk (which means it does |
||
| 2001 | * not use any Id generator. |
||
| 2002 | * |
||
| 2003 | * @return boolean |
||
| 2004 | */ |
||
| 2005 | 74 | public function isIdentifierNatural() |
|
| 2009 | |||
| 2010 | /** |
||
| 2011 | * Checks whether the class use a UUID for id generation. |
||
| 2012 | * |
||
| 2013 | * @return boolean |
||
| 2014 | */ |
||
| 2015 | public function isIdentifierUuid() |
||
| 2019 | |||
| 2020 | /** |
||
| 2021 | * Gets the type of a field. |
||
| 2022 | * |
||
| 2023 | * @param string $fieldName |
||
| 2024 | * |
||
| 2025 | * @return \Doctrine\DBAL\Types\Type|string|null |
||
| 2026 | * |
||
| 2027 | * @todo 3.0 Remove this. PersisterHelper should fix it somehow |
||
| 2028 | */ |
||
| 2029 | 931 | public function getTypeOfField($fieldName) |
|
| 2035 | |||
| 2036 | /** |
||
| 2037 | * Gets the type of a column. |
||
| 2038 | * |
||
| 2039 | * @param string $columnName |
||
| 2040 | * |
||
| 2041 | * @return \Doctrine\DBAL\Types\Type|string|null |
||
| 2042 | * |
||
| 2043 | * @deprecated 3.0 remove this. this method is bogous and unreliable, since it cannot resolve the type of a column |
||
| 2044 | * that is derived by a referenced field on a different entity. |
||
| 2045 | */ |
||
| 2046 | public function getTypeOfColumn($columnName) |
||
| 2050 | |||
| 2051 | /** |
||
| 2052 | * Gets the name of the primary table. |
||
| 2053 | * |
||
| 2054 | * @return string |
||
| 2055 | */ |
||
| 2056 | 1364 | public function getTableName() |
|
| 2060 | |||
| 2061 | /** |
||
| 2062 | * Gets primary table's schema name. |
||
| 2063 | * |
||
| 2064 | * @return string|null |
||
| 2065 | */ |
||
| 2066 | 13 | public function getSchemaName() |
|
| 2070 | |||
| 2071 | /** |
||
| 2072 | * Gets the table name to use for temporary identifier tables of this class. |
||
| 2073 | * |
||
| 2074 | * @return string |
||
| 2075 | */ |
||
| 2076 | 7 | public function getTemporaryIdTableName() |
|
| 2081 | |||
| 2082 | /** |
||
| 2083 | * Sets the mapped subclasses of this class. |
||
| 2084 | * |
||
| 2085 | * @param array $subclasses The names of all mapped subclasses. |
||
| 2086 | * |
||
| 2087 | * @return void |
||
| 2088 | */ |
||
| 2089 | 2 | public function setSubclasses(array $subclasses) |
|
| 2095 | |||
| 2096 | /** |
||
| 2097 | * Sets the parent class names. |
||
| 2098 | * Assumes that the class names in the passed array are in the order: |
||
| 2099 | * directParent -> directParentParent -> directParentParentParent ... -> root. |
||
| 2100 | * |
||
| 2101 | * @param array $classNames |
||
| 2102 | * |
||
| 2103 | * @return void |
||
| 2104 | */ |
||
| 2105 | 435 | public function setParentClasses(array $classNames) |
|
| 2113 | |||
| 2114 | /** |
||
| 2115 | * Sets the inheritance type used by the class and its subclasses. |
||
| 2116 | * |
||
| 2117 | * @param integer $type |
||
| 2118 | * |
||
| 2119 | * @return void |
||
| 2120 | * |
||
| 2121 | * @throws MappingException |
||
| 2122 | */ |
||
| 2123 | 175 | public function setInheritanceType($type) |
|
| 2131 | |||
| 2132 | /** |
||
| 2133 | * Sets the association to override association mapping of property for an entity relationship. |
||
| 2134 | * |
||
| 2135 | * @param string $fieldName |
||
| 2136 | * @param array $overrideMapping |
||
| 2137 | * |
||
| 2138 | * @return void |
||
| 2139 | * |
||
| 2140 | * @throws MappingException |
||
| 2141 | */ |
||
| 2142 | 20 | public function setAssociationOverride($fieldName, array $overrideMapping) |
|
| 2185 | |||
| 2186 | /** |
||
| 2187 | * Sets the override for a mapped field. |
||
| 2188 | * |
||
| 2189 | * @param string $fieldName |
||
| 2190 | * @param array $overrideMapping |
||
| 2191 | * |
||
| 2192 | * @return void |
||
| 2193 | * |
||
| 2194 | * @throws MappingException |
||
| 2195 | */ |
||
| 2196 | 15 | public function setAttributeOverride($fieldName, array $overrideMapping) |
|
| 2228 | |||
| 2229 | /** |
||
| 2230 | * Checks whether a mapped field is inherited from an entity superclass. |
||
| 2231 | * |
||
| 2232 | * @param string $fieldName |
||
| 2233 | * |
||
| 2234 | * @return bool TRUE if the field is inherited, FALSE otherwise. |
||
| 2235 | */ |
||
| 2236 | 395 | public function isInheritedField($fieldName) |
|
| 2240 | |||
| 2241 | /** |
||
| 2242 | * Checks if this entity is the root in any entity-inheritance-hierarchy. |
||
| 2243 | * |
||
| 2244 | * @return bool |
||
| 2245 | */ |
||
| 2246 | 434 | public function isRootEntity() |
|
| 2250 | |||
| 2251 | /** |
||
| 2252 | * Checks whether a mapped association field is inherited from a superclass. |
||
| 2253 | * |
||
| 2254 | * @param string $fieldName |
||
| 2255 | * |
||
| 2256 | * @return boolean TRUE if the field is inherited, FALSE otherwise. |
||
| 2257 | */ |
||
| 2258 | 374 | public function isInheritedAssociation($fieldName) |
|
| 2262 | |||
| 2263 | 374 | public function isInheritedEmbeddedClass($fieldName) |
|
| 2267 | |||
| 2268 | /** |
||
| 2269 | * Sets the name of the primary table the class is mapped to. |
||
| 2270 | * |
||
| 2271 | * @param string $tableName The table name. |
||
| 2272 | * |
||
| 2273 | * @return void |
||
| 2274 | * |
||
| 2275 | * @deprecated Use {@link setPrimaryTable}. |
||
| 2276 | */ |
||
| 2277 | 5 | public function setTableName($tableName) |
|
| 2281 | |||
| 2282 | /** |
||
| 2283 | * Sets the primary table definition. The provided array supports the |
||
| 2284 | * following structure: |
||
| 2285 | * |
||
| 2286 | * name => <tableName> (optional, defaults to class name) |
||
| 2287 | * indexes => array of indexes (optional) |
||
| 2288 | * uniqueConstraints => array of constraints (optional) |
||
| 2289 | * |
||
| 2290 | * If a key is omitted, the current value is kept. |
||
| 2291 | * |
||
| 2292 | * @param array $table The table description. |
||
| 2293 | * |
||
| 2294 | * @return void |
||
| 2295 | */ |
||
| 2296 | 335 | public function setPrimaryTable(array $table) |
|
| 2328 | |||
| 2329 | /** |
||
| 2330 | * Checks whether the given type identifies an inheritance type. |
||
| 2331 | * |
||
| 2332 | * @param integer $type |
||
| 2333 | * |
||
| 2334 | * @return boolean TRUE if the given type identifies an inheritance type, FALSe otherwise. |
||
| 2335 | */ |
||
| 2336 | 175 | private function _isInheritanceType($type) |
|
| 2343 | |||
| 2344 | /** |
||
| 2345 | * Adds a mapped field to the class. |
||
| 2346 | * |
||
| 2347 | * @param array $mapping The field mapping. |
||
| 2348 | * |
||
| 2349 | * @return void |
||
| 2350 | * |
||
| 2351 | * @throws MappingException |
||
| 2352 | */ |
||
| 2353 | 554 | public function mapField(array $mapping) |
|
| 2360 | |||
| 2361 | /** |
||
| 2362 | * INTERNAL: |
||
| 2363 | * Adds an association mapping without completing/validating it. |
||
| 2364 | * This is mainly used to add inherited association mappings to derived classes. |
||
| 2365 | * |
||
| 2366 | * @param array $mapping |
||
| 2367 | * |
||
| 2368 | * @return void |
||
| 2369 | * |
||
| 2370 | * @throws MappingException |
||
| 2371 | */ |
||
| 2372 | 49 | public function addInheritedAssociationMapping(array $mapping/*, $owningClassName = null*/) |
|
| 2379 | |||
| 2380 | /** |
||
| 2381 | * INTERNAL: |
||
| 2382 | * Adds a field mapping without completing/validating it. |
||
| 2383 | * This is mainly used to add inherited field mappings to derived classes. |
||
| 2384 | * |
||
| 2385 | * @param array $fieldMapping |
||
| 2386 | * |
||
| 2387 | * @return void |
||
| 2388 | */ |
||
| 2389 | 113 | public function addInheritedFieldMapping(array $fieldMapping) |
|
| 2395 | |||
| 2396 | /** |
||
| 2397 | * INTERNAL: |
||
| 2398 | * Adds a named query to this class. |
||
| 2399 | * |
||
| 2400 | * @param array $queryMapping |
||
| 2401 | * |
||
| 2402 | * @return void |
||
| 2403 | * |
||
| 2404 | * @throws MappingException |
||
| 2405 | */ |
||
| 2406 | 30 | public function addNamedQuery(array $queryMapping) |
|
| 2430 | |||
| 2431 | /** |
||
| 2432 | * INTERNAL: |
||
| 2433 | * Adds a named native query to this class. |
||
| 2434 | * |
||
| 2435 | * @param array $queryMapping |
||
| 2436 | * |
||
| 2437 | * @return void |
||
| 2438 | * |
||
| 2439 | * @throws MappingException |
||
| 2440 | */ |
||
| 2441 | 41 | public function addNamedNativeQuery(array $queryMapping) |
|
| 2474 | |||
| 2475 | /** |
||
| 2476 | * INTERNAL: |
||
| 2477 | * Adds a sql result set mapping to this class. |
||
| 2478 | * |
||
| 2479 | * @param array $resultMapping |
||
| 2480 | * |
||
| 2481 | * @return void |
||
| 2482 | * |
||
| 2483 | * @throws MappingException |
||
| 2484 | */ |
||
| 2485 | 41 | public function addSqlResultSetMapping(array $resultMapping) |
|
| 2535 | |||
| 2536 | /** |
||
| 2537 | * Adds a one-to-one mapping. |
||
| 2538 | * |
||
| 2539 | * @param array $mapping The mapping. |
||
| 2540 | * |
||
| 2541 | * @return void |
||
| 2542 | */ |
||
| 2543 | 173 | public function mapOneToOne(array $mapping) |
|
| 2551 | |||
| 2552 | /** |
||
| 2553 | * Adds a one-to-many mapping. |
||
| 2554 | * |
||
| 2555 | * @param array $mapping The mapping. |
||
| 2556 | * |
||
| 2557 | * @return void |
||
| 2558 | */ |
||
| 2559 | 133 | public function mapOneToMany(array $mapping) |
|
| 2567 | |||
| 2568 | /** |
||
| 2569 | * Adds a many-to-one mapping. |
||
| 2570 | * |
||
| 2571 | * @param array $mapping The mapping. |
||
| 2572 | * |
||
| 2573 | * @return void |
||
| 2574 | */ |
||
| 2575 | 165 | public function mapManyToOne(array $mapping) |
|
| 2584 | |||
| 2585 | /** |
||
| 2586 | * Adds a many-to-many mapping. |
||
| 2587 | * |
||
| 2588 | * @param array $mapping The mapping. |
||
| 2589 | * |
||
| 2590 | * @return void |
||
| 2591 | */ |
||
| 2592 | 154 | public function mapManyToMany(array $mapping) |
|
| 2600 | |||
| 2601 | /** |
||
| 2602 | * Stores the association mapping. |
||
| 2603 | * |
||
| 2604 | * @param array $assocMapping |
||
| 2605 | * |
||
| 2606 | * @return void |
||
| 2607 | * |
||
| 2608 | * @throws MappingException |
||
| 2609 | */ |
||
| 2610 | 347 | protected function _storeAssociationMapping(array $assocMapping) |
|
| 2618 | |||
| 2619 | /** |
||
| 2620 | * Registers a custom repository class for the entity class. |
||
| 2621 | * |
||
| 2622 | * @param string $repositoryClassName The class name of the custom mapper. |
||
| 2623 | * |
||
| 2624 | * @return void |
||
| 2625 | */ |
||
| 2626 | 63 | public function setCustomRepositoryClass($repositoryClassName) |
|
| 2630 | |||
| 2631 | /** |
||
| 2632 | * Dispatches the lifecycle event of the given entity to the registered |
||
| 2633 | * lifecycle callbacks and lifecycle listeners. |
||
| 2634 | * |
||
| 2635 | * @deprecated Deprecated since version 2.4 in favor of \Doctrine\ORM\Event\ListenersInvoker |
||
| 2636 | * |
||
| 2637 | * @param string $lifecycleEvent The lifecycle event. |
||
| 2638 | * @param object $entity The Entity on which the event occurred. |
||
| 2639 | * |
||
| 2640 | * @return void |
||
| 2641 | */ |
||
| 2642 | 1 | public function invokeLifecycleCallbacks($lifecycleEvent, $entity) |
|
| 2648 | |||
| 2649 | /** |
||
| 2650 | * Whether the class has any attached lifecycle listeners or callbacks for a lifecycle event. |
||
| 2651 | * |
||
| 2652 | * @param string $lifecycleEvent |
||
| 2653 | * |
||
| 2654 | * @return boolean |
||
| 2655 | */ |
||
| 2656 | public function hasLifecycleCallbacks($lifecycleEvent) |
||
| 2660 | |||
| 2661 | /** |
||
| 2662 | * Gets the registered lifecycle callbacks for an event. |
||
| 2663 | * |
||
| 2664 | * @param string $event |
||
| 2665 | * |
||
| 2666 | * @return array |
||
| 2667 | */ |
||
| 2668 | public function getLifecycleCallbacks($event) |
||
| 2672 | |||
| 2673 | /** |
||
| 2674 | * Adds a lifecycle callback for entities of this class. |
||
| 2675 | * |
||
| 2676 | * @param string $callback |
||
| 2677 | * @param string $event |
||
| 2678 | * |
||
| 2679 | * @return void |
||
| 2680 | */ |
||
| 2681 | 41 | public function addLifecycleCallback($callback, $event) |
|
| 2689 | |||
| 2690 | /** |
||
| 2691 | * Sets the lifecycle callbacks for entities of this class. |
||
| 2692 | * Any previously registered callbacks are overwritten. |
||
| 2693 | * |
||
| 2694 | * @param array $callbacks |
||
| 2695 | * |
||
| 2696 | * @return void |
||
| 2697 | */ |
||
| 2698 | 128 | public function setLifecycleCallbacks(array $callbacks) |
|
| 2702 | |||
| 2703 | /** |
||
| 2704 | * Adds a entity listener for entities of this class. |
||
| 2705 | * |
||
| 2706 | * @param string $eventName The entity lifecycle event. |
||
| 2707 | * @param string $class The listener class. |
||
| 2708 | * @param string $method The listener callback method. |
||
| 2709 | * |
||
| 2710 | * @throws \Doctrine\ORM\Mapping\MappingException |
||
| 2711 | */ |
||
| 2712 | 35 | public function addEntityListener($eventName, $class, $method) |
|
| 2735 | |||
| 2736 | /** |
||
| 2737 | * Sets the discriminator column definition. |
||
| 2738 | * |
||
| 2739 | * @param array $columnDef |
||
| 2740 | * |
||
| 2741 | * @return void |
||
| 2742 | * |
||
| 2743 | * @throws MappingException |
||
| 2744 | * |
||
| 2745 | * @see getDiscriminatorColumn() |
||
| 2746 | */ |
||
| 2747 | 169 | public function setDiscriminatorColumn($columnDef) |
|
| 2773 | |||
| 2774 | /** |
||
| 2775 | * Sets the discriminator values used by this class. |
||
| 2776 | * Used for JOINED and SINGLE_TABLE inheritance mapping strategies. |
||
| 2777 | * |
||
| 2778 | * @param array $map |
||
| 2779 | * |
||
| 2780 | * @return void |
||
| 2781 | */ |
||
| 2782 | 162 | public function setDiscriminatorMap(array $map) |
|
| 2788 | |||
| 2789 | /** |
||
| 2790 | * Adds one entry of the discriminator map with a new class and corresponding name. |
||
| 2791 | * |
||
| 2792 | * @param string $name |
||
| 2793 | * @param string $className |
||
| 2794 | * |
||
| 2795 | * @return void |
||
| 2796 | * |
||
| 2797 | * @throws MappingException |
||
| 2798 | */ |
||
| 2799 | 109 | public function addDiscriminatorMapClass($name, $className) |
|
| 2820 | |||
| 2821 | /** |
||
| 2822 | * Checks whether the class has a named query with the given query name. |
||
| 2823 | * |
||
| 2824 | * @param string $queryName |
||
| 2825 | * |
||
| 2826 | * @return boolean |
||
| 2827 | */ |
||
| 2828 | 1 | public function hasNamedQuery($queryName) |
|
| 2832 | |||
| 2833 | /** |
||
| 2834 | * Checks whether the class has a named native query with the given query name. |
||
| 2835 | * |
||
| 2836 | * @param string $queryName |
||
| 2837 | * |
||
| 2838 | * @return boolean |
||
| 2839 | */ |
||
| 2840 | 1 | public function hasNamedNativeQuery($queryName) |
|
| 2844 | |||
| 2845 | /** |
||
| 2846 | * Checks whether the class has a named native query with the given query name. |
||
| 2847 | * |
||
| 2848 | * @param string $name |
||
| 2849 | * |
||
| 2850 | * @return boolean |
||
| 2851 | */ |
||
| 2852 | 1 | public function hasSqlResultSetMapping($name) |
|
| 2856 | |||
| 2857 | /** |
||
| 2858 | * {@inheritDoc} |
||
| 2859 | */ |
||
| 2860 | 345 | public function hasAssociation($fieldName) |
|
| 2864 | |||
| 2865 | /** |
||
| 2866 | * {@inheritDoc} |
||
| 2867 | */ |
||
| 2868 | 1 | public function isSingleValuedAssociation($fieldName) |
|
| 2873 | |||
| 2874 | /** |
||
| 2875 | * {@inheritDoc} |
||
| 2876 | */ |
||
| 2877 | 1038 | public function isCollectionValuedAssociation($fieldName) |
|
| 2882 | |||
| 2883 | /** |
||
| 2884 | * Is this an association that only has a single join column? |
||
| 2885 | * |
||
| 2886 | * @param string $fieldName |
||
| 2887 | * |
||
| 2888 | * @return bool |
||
| 2889 | */ |
||
| 2890 | 35 | public function isAssociationWithSingleJoinColumn($fieldName) |
|
| 2896 | |||
| 2897 | /** |
||
| 2898 | * Returns the single association join column (if any). |
||
| 2899 | * |
||
| 2900 | * @param string $fieldName |
||
| 2901 | * |
||
| 2902 | * @return string |
||
| 2903 | * |
||
| 2904 | * @throws MappingException |
||
| 2905 | */ |
||
| 2906 | 9 | public function getSingleAssociationJoinColumnName($fieldName) |
|
| 2914 | |||
| 2915 | /** |
||
| 2916 | * Returns the single association referenced join column name (if any). |
||
| 2917 | * |
||
| 2918 | * @param string $fieldName |
||
| 2919 | * |
||
| 2920 | * @return string |
||
| 2921 | * |
||
| 2922 | * @throws MappingException |
||
| 2923 | */ |
||
| 2924 | 9 | public function getSingleAssociationReferencedJoinColumnName($fieldName) |
|
| 2932 | |||
| 2933 | /** |
||
| 2934 | * Used to retrieve a fieldname for either field or association from a given column. |
||
| 2935 | * |
||
| 2936 | * This method is used in foreign-key as primary-key contexts. |
||
| 2937 | * |
||
| 2938 | * @param string $columnName |
||
| 2939 | * |
||
| 2940 | * @return string |
||
| 2941 | * |
||
| 2942 | * @throws MappingException |
||
| 2943 | */ |
||
| 2944 | 639 | public function getFieldForColumn($columnName) |
|
| 2960 | |||
| 2961 | /** |
||
| 2962 | * Sets the ID generator used to generate IDs for instances of this class. |
||
| 2963 | * |
||
| 2964 | * @param \Doctrine\ORM\Id\AbstractIdGenerator $generator |
||
| 2965 | * |
||
| 2966 | * @return void |
||
| 2967 | */ |
||
| 2968 | 437 | public function setIdGenerator($generator) |
|
| 2972 | |||
| 2973 | /** |
||
| 2974 | * Sets definition. |
||
| 2975 | * |
||
| 2976 | * @param array $definition |
||
| 2977 | * |
||
| 2978 | * @return void |
||
| 2979 | */ |
||
| 2980 | 12 | public function setCustomGeneratorDefinition(array $definition) |
|
| 2984 | |||
| 2985 | /** |
||
| 2986 | * Sets the definition of the sequence ID generator for this class. |
||
| 2987 | * |
||
| 2988 | * The definition must have the following structure: |
||
| 2989 | * <code> |
||
| 2990 | * array( |
||
| 2991 | * 'sequenceName' => 'name', |
||
| 2992 | * 'allocationSize' => 20, |
||
| 2993 | * 'initialValue' => 1 |
||
| 2994 | * 'quoted' => 1 |
||
| 2995 | * ) |
||
| 2996 | * </code> |
||
| 2997 | * |
||
| 2998 | * @param array $definition |
||
| 2999 | * |
||
| 3000 | * @return void |
||
| 3001 | * |
||
| 3002 | * @throws MappingException |
||
| 3003 | */ |
||
| 3004 | 23 | public function setSequenceGeneratorDefinition(array $definition) |
|
| 3017 | |||
| 3018 | /** |
||
| 3019 | * Sets the version field mapping used for versioning. Sets the default |
||
| 3020 | * value to use depending on the column type. |
||
| 3021 | * |
||
| 3022 | * @param array $mapping The version field mapping array. |
||
| 3023 | * |
||
| 3024 | * @return void |
||
| 3025 | * |
||
| 3026 | * @throws MappingException |
||
| 3027 | */ |
||
| 3028 | 26 | public function setVersionMapping(array &$mapping) |
|
| 3043 | |||
| 3044 | /** |
||
| 3045 | * Sets whether this class is to be versioned for optimistic locking. |
||
| 3046 | * |
||
| 3047 | * @param boolean $bool |
||
| 3048 | * |
||
| 3049 | * @return void |
||
| 3050 | */ |
||
| 3051 | 128 | public function setVersioned($bool) |
|
| 3055 | |||
| 3056 | /** |
||
| 3057 | * Sets the name of the field that is to be used for versioning if this class is |
||
| 3058 | * versioned for optimistic locking. |
||
| 3059 | * |
||
| 3060 | * @param string $versionField |
||
| 3061 | * |
||
| 3062 | * @return void |
||
| 3063 | */ |
||
| 3064 | 128 | public function setVersionField($versionField) |
|
| 3068 | |||
| 3069 | /** |
||
| 3070 | * Marks this class as read only, no change tracking is applied to it. |
||
| 3071 | * |
||
| 3072 | * @return void |
||
| 3073 | */ |
||
| 3074 | 3 | public function markReadOnly() |
|
| 3078 | |||
| 3079 | /** |
||
| 3080 | * {@inheritDoc} |
||
| 3081 | */ |
||
| 3082 | public function getFieldNames() |
||
| 3086 | |||
| 3087 | /** |
||
| 3088 | * {@inheritDoc} |
||
| 3089 | */ |
||
| 3090 | public function getAssociationNames() |
||
| 3094 | |||
| 3095 | /** |
||
| 3096 | * {@inheritDoc} |
||
| 3097 | * |
||
| 3098 | * @throws InvalidArgumentException |
||
| 3099 | */ |
||
| 3100 | 1 | public function getAssociationTargetClass($assocName) |
|
| 3108 | |||
| 3109 | /** |
||
| 3110 | * {@inheritDoc} |
||
| 3111 | */ |
||
| 3112 | 739 | public function getName() |
|
| 3116 | |||
| 3117 | /** |
||
| 3118 | * Gets the (possibly quoted) identifier column names for safe use in an SQL statement. |
||
| 3119 | * |
||
| 3120 | * @deprecated Deprecated since version 2.3 in favor of \Doctrine\ORM\Mapping\QuoteStrategy |
||
| 3121 | * |
||
| 3122 | * @param \Doctrine\DBAL\Platforms\AbstractPlatform $platform |
||
| 3123 | * |
||
| 3124 | * @return array |
||
| 3125 | */ |
||
| 3126 | public function getQuotedIdentifierColumnNames($platform) |
||
| 3155 | |||
| 3156 | /** |
||
| 3157 | * Gets the (possibly quoted) column name of a mapped field for safe use in an SQL statement. |
||
| 3158 | * |
||
| 3159 | * @deprecated Deprecated since version 2.3 in favor of \Doctrine\ORM\Mapping\QuoteStrategy |
||
| 3160 | * |
||
| 3161 | * @param string $field |
||
| 3162 | * @param \Doctrine\DBAL\Platforms\AbstractPlatform $platform |
||
| 3163 | * |
||
| 3164 | * @return string |
||
| 3165 | */ |
||
| 3166 | public function getQuotedColumnName($field, $platform) |
||
| 3172 | |||
| 3173 | /** |
||
| 3174 | * Gets the (possibly quoted) primary table name of this class for safe use in an SQL statement. |
||
| 3175 | * |
||
| 3176 | * @deprecated Deprecated since version 2.3 in favor of \Doctrine\ORM\Mapping\QuoteStrategy |
||
| 3177 | * |
||
| 3178 | * @param \Doctrine\DBAL\Platforms\AbstractPlatform $platform |
||
| 3179 | * |
||
| 3180 | * @return string |
||
| 3181 | */ |
||
| 3182 | public function getQuotedTableName($platform) |
||
| 3188 | |||
| 3189 | /** |
||
| 3190 | * Gets the (possibly quoted) name of the join table. |
||
| 3191 | * |
||
| 3192 | * @deprecated Deprecated since version 2.3 in favor of \Doctrine\ORM\Mapping\QuoteStrategy |
||
| 3193 | * |
||
| 3194 | * @param array $assoc |
||
| 3195 | * @param \Doctrine\DBAL\Platforms\AbstractPlatform $platform |
||
| 3196 | * |
||
| 3197 | * @return string |
||
| 3198 | */ |
||
| 3199 | public function getQuotedJoinTableName(array $assoc, $platform) |
||
| 3205 | |||
| 3206 | /** |
||
| 3207 | * {@inheritDoc} |
||
| 3208 | */ |
||
| 3209 | 12 | public function isAssociationInverseSide($fieldName) |
|
| 3214 | |||
| 3215 | /** |
||
| 3216 | * {@inheritDoc} |
||
| 3217 | */ |
||
| 3218 | public function getAssociationMappedByTargetField($fieldName) |
||
| 3222 | |||
| 3223 | /** |
||
| 3224 | * @param string $targetClass |
||
| 3225 | * |
||
| 3226 | * @return array |
||
| 3227 | */ |
||
| 3228 | 2 | public function getAssociationsByTargetClass($targetClass) |
|
| 3240 | |||
| 3241 | /** |
||
| 3242 | * @param string|null $className |
||
| 3243 | * |
||
| 3244 | * @return string|null null if the input value is null |
||
| 3245 | */ |
||
| 3246 | 488 | public function fullyQualifiedClassName($className) |
|
| 3258 | |||
| 3259 | /** |
||
| 3260 | * @param string $name |
||
| 3261 | * |
||
| 3262 | * @return mixed |
||
| 3263 | */ |
||
| 3264 | 2 | public function getMetadataValue($name) |
|
| 3273 | |||
| 3274 | /** |
||
| 3275 | * Map Embedded Class |
||
| 3276 | * |
||
| 3277 | * @param array $mapping |
||
| 3278 | * |
||
| 3279 | * @throws MappingException |
||
| 3280 | * @return void |
||
| 3281 | */ |
||
| 3282 | 27 | public function mapEmbedded(array $mapping) |
|
| 3293 | |||
| 3294 | /** |
||
| 3295 | * Inline the embeddable class |
||
| 3296 | * |
||
| 3297 | * @param string $property |
||
| 3298 | * @param ClassMetadataInfo $embeddable |
||
| 3299 | */ |
||
| 3300 | 11 | public function inlineEmbeddable($property, ClassMetadataInfo $embeddable) |
|
| 3329 | |||
| 3330 | /** |
||
| 3331 | * @param string $fieldName |
||
| 3332 | * @throws MappingException |
||
| 3333 | */ |
||
| 3334 | 589 | private function assertFieldNotMapped($fieldName) |
|
| 3343 | |||
| 3344 | /** |
||
| 3345 | * Gets the sequence name based on class metadata. |
||
| 3346 | * |
||
| 3347 | * @param AbstractPlatform $platform |
||
| 3348 | * @return string |
||
| 3349 | * |
||
| 3350 | * @todo Sequence names should be computed in DBAL depending on the platform |
||
| 3351 | */ |
||
| 3352 | 3 | public function getSequenceName(AbstractPlatform $platform) |
|
| 3360 | |||
| 3361 | /** |
||
| 3362 | * Gets the sequence name prefix based on class metadata. |
||
| 3363 | * |
||
| 3364 | * @param AbstractPlatform $platform |
||
| 3365 | * @return string |
||
| 3366 | * |
||
| 3367 | * @todo Sequence names should be computed in DBAL depending on the platform |
||
| 3368 | */ |
||
| 3369 | 3 | public function getSequencePrefix(AbstractPlatform $platform) |
|
| 3385 | |||
| 3386 | /** |
||
| 3387 | * @param array $mapping |
||
| 3388 | */ |
||
| 3389 | 214 | private function assertMappingOrderBy(array $mapping) |
|
| 3395 | } |
||
| 3396 |
Let’s assume that you have a directory layout like this:
. |-- OtherDir | |-- Bar.php | `-- Foo.php `-- SomeDir `-- Foo.phpand let’s assume the following content of
Bar.php:If both files
OtherDir/Foo.phpandSomeDir/Foo.phpare loaded in the same runtime, you will see a PHP error such as the following:PHP Fatal error: Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.phpHowever, as
OtherDir/Foo.phpdoes not necessarily have to be loaded and the error is only triggered if it is loaded beforeOtherDir/Bar.php, this problem might go unnoticed for a while. In order to prevent this error from surfacing, you must import the namespace with a different alias: