Complex classes like ClassMetadataInfo often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use ClassMetadataInfo, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 51 | class ClassMetadataInfo implements ClassMetadata |
||
| 52 | { |
||
| 53 | /* The inheritance mapping types */ |
||
| 54 | /** |
||
| 55 | * NONE means the class does not participate in an inheritance hierarchy |
||
| 56 | * and therefore does not need an inheritance mapping type. |
||
| 57 | */ |
||
| 58 | const INHERITANCE_TYPE_NONE = 1; |
||
| 59 | |||
| 60 | /** |
||
| 61 | * JOINED means the class will be persisted according to the rules of |
||
| 62 | * <tt>Class Table Inheritance</tt>. |
||
| 63 | */ |
||
| 64 | const INHERITANCE_TYPE_JOINED = 2; |
||
| 65 | |||
| 66 | /** |
||
| 67 | * SINGLE_TABLE means the class will be persisted according to the rules of |
||
| 68 | * <tt>Single Table Inheritance</tt>. |
||
| 69 | */ |
||
| 70 | const INHERITANCE_TYPE_SINGLE_TABLE = 3; |
||
| 71 | |||
| 72 | /** |
||
| 73 | * TABLE_PER_CLASS means the class will be persisted according to the rules |
||
| 74 | * of <tt>Concrete Table Inheritance</tt>. |
||
| 75 | */ |
||
| 76 | const INHERITANCE_TYPE_TABLE_PER_CLASS = 4; |
||
| 77 | |||
| 78 | /* The Id generator types. */ |
||
| 79 | /** |
||
| 80 | * AUTO means the generator type will depend on what the used platform prefers. |
||
| 81 | * Offers full portability. |
||
| 82 | */ |
||
| 83 | const GENERATOR_TYPE_AUTO = 1; |
||
| 84 | |||
| 85 | /** |
||
| 86 | * SEQUENCE means a separate sequence object will be used. Platforms that do |
||
| 87 | * not have native sequence support may emulate it. Full portability is currently |
||
| 88 | * not guaranteed. |
||
| 89 | */ |
||
| 90 | const GENERATOR_TYPE_SEQUENCE = 2; |
||
| 91 | |||
| 92 | /** |
||
| 93 | * TABLE means a separate table is used for id generation. |
||
| 94 | * Offers full portability. |
||
| 95 | */ |
||
| 96 | const GENERATOR_TYPE_TABLE = 3; |
||
| 97 | |||
| 98 | /** |
||
| 99 | * IDENTITY means an identity column is used for id generation. The database |
||
| 100 | * will fill in the id column on insertion. Platforms that do not support |
||
| 101 | * native identity columns may emulate them. Full portability is currently |
||
| 102 | * not guaranteed. |
||
| 103 | */ |
||
| 104 | const GENERATOR_TYPE_IDENTITY = 4; |
||
| 105 | |||
| 106 | /** |
||
| 107 | * NONE means the class does not have a generated id. That means the class |
||
| 108 | * must have a natural, manually assigned id. |
||
| 109 | */ |
||
| 110 | const GENERATOR_TYPE_NONE = 5; |
||
| 111 | |||
| 112 | /** |
||
| 113 | * UUID means that a UUID/GUID expression is used for id generation. Full |
||
| 114 | * portability is currently not guaranteed. |
||
| 115 | */ |
||
| 116 | const GENERATOR_TYPE_UUID = 6; |
||
| 117 | |||
| 118 | /** |
||
| 119 | * CUSTOM means that customer will use own ID generator that supposedly work |
||
| 120 | */ |
||
| 121 | const GENERATOR_TYPE_CUSTOM = 7; |
||
| 122 | |||
| 123 | /** |
||
| 124 | * DEFERRED_IMPLICIT means that changes of entities are calculated at commit-time |
||
| 125 | * by doing a property-by-property comparison with the original data. This will |
||
| 126 | * be done for all entities that are in MANAGED state at commit-time. |
||
| 127 | * |
||
| 128 | * This is the default change tracking policy. |
||
| 129 | */ |
||
| 130 | const CHANGETRACKING_DEFERRED_IMPLICIT = 1; |
||
| 131 | |||
| 132 | /** |
||
| 133 | * DEFERRED_EXPLICIT means that changes of entities are calculated at commit-time |
||
| 134 | * by doing a property-by-property comparison with the original data. This will |
||
| 135 | * be done only for entities that were explicitly saved (through persist() or a cascade). |
||
| 136 | */ |
||
| 137 | const CHANGETRACKING_DEFERRED_EXPLICIT = 2; |
||
| 138 | |||
| 139 | /** |
||
| 140 | * NOTIFY means that Doctrine relies on the entities sending out notifications |
||
| 141 | * when their properties change. Such entity classes must implement |
||
| 142 | * the <tt>NotifyPropertyChanged</tt> interface. |
||
| 143 | */ |
||
| 144 | const CHANGETRACKING_NOTIFY = 3; |
||
| 145 | |||
| 146 | /** |
||
| 147 | * Specifies that an association is to be fetched when it is first accessed. |
||
| 148 | */ |
||
| 149 | const FETCH_LAZY = 2; |
||
| 150 | |||
| 151 | /** |
||
| 152 | * Specifies that an association is to be fetched when the owner of the |
||
| 153 | * association is fetched. |
||
| 154 | */ |
||
| 155 | const FETCH_EAGER = 3; |
||
| 156 | |||
| 157 | /** |
||
| 158 | * Specifies that an association is to be fetched lazy (on first access) and that |
||
| 159 | * commands such as Collection#count, Collection#slice are issued directly against |
||
| 160 | * the database if the collection is not yet initialized. |
||
| 161 | */ |
||
| 162 | const FETCH_EXTRA_LAZY = 4; |
||
| 163 | |||
| 164 | /** |
||
| 165 | * Identifies a one-to-one association. |
||
| 166 | */ |
||
| 167 | const ONE_TO_ONE = 1; |
||
| 168 | |||
| 169 | /** |
||
| 170 | * Identifies a many-to-one association. |
||
| 171 | */ |
||
| 172 | const MANY_TO_ONE = 2; |
||
| 173 | |||
| 174 | /** |
||
| 175 | * Identifies a one-to-many association. |
||
| 176 | */ |
||
| 177 | const ONE_TO_MANY = 4; |
||
| 178 | |||
| 179 | /** |
||
| 180 | * Identifies a many-to-many association. |
||
| 181 | */ |
||
| 182 | const MANY_TO_MANY = 8; |
||
| 183 | |||
| 184 | /** |
||
| 185 | * Combined bitmask for to-one (single-valued) associations. |
||
| 186 | */ |
||
| 187 | const TO_ONE = 3; |
||
| 188 | |||
| 189 | /** |
||
| 190 | * Combined bitmask for to-many (collection-valued) associations. |
||
| 191 | */ |
||
| 192 | const TO_MANY = 12; |
||
| 193 | |||
| 194 | /** |
||
| 195 | * ReadOnly cache can do reads, inserts and deletes, cannot perform updates or employ any locks, |
||
| 196 | */ |
||
| 197 | const CACHE_USAGE_READ_ONLY = 1; |
||
| 198 | |||
| 199 | /** |
||
| 200 | * Nonstrict Read Write Cache doesn’t employ any locks but can do inserts, update and deletes. |
||
| 201 | */ |
||
| 202 | const CACHE_USAGE_NONSTRICT_READ_WRITE = 2; |
||
| 203 | |||
| 204 | /** |
||
| 205 | * Read Write Attempts to lock the entity before update/delete. |
||
| 206 | */ |
||
| 207 | const CACHE_USAGE_READ_WRITE = 3; |
||
| 208 | |||
| 209 | /** |
||
| 210 | * READ-ONLY: The name of the entity class. |
||
| 211 | * |
||
| 212 | * @var string |
||
| 213 | */ |
||
| 214 | public $name; |
||
| 215 | |||
| 216 | /** |
||
| 217 | * READ-ONLY: The namespace the entity class is contained in. |
||
| 218 | * |
||
| 219 | * @var string |
||
| 220 | * |
||
| 221 | * @todo Not really needed. Usage could be localized. |
||
| 222 | */ |
||
| 223 | public $namespace; |
||
| 224 | |||
| 225 | /** |
||
| 226 | * READ-ONLY: The name of the entity class that is at the root of the mapped entity inheritance |
||
| 227 | * hierarchy. If the entity is not part of a mapped inheritance hierarchy this is the same |
||
| 228 | * as {@link $name}. |
||
| 229 | * |
||
| 230 | * @var string |
||
| 231 | */ |
||
| 232 | public $rootEntityName; |
||
| 233 | |||
| 234 | /** |
||
| 235 | * READ-ONLY: The definition of custom generator. Only used for CUSTOM |
||
| 236 | * generator type |
||
| 237 | * |
||
| 238 | * The definition has the following structure: |
||
| 239 | * <code> |
||
| 240 | * array( |
||
| 241 | * 'class' => 'ClassName', |
||
| 242 | * ) |
||
| 243 | * </code> |
||
| 244 | * |
||
| 245 | * @var array |
||
| 246 | * |
||
| 247 | * @todo Merge with tableGeneratorDefinition into generic generatorDefinition |
||
| 248 | */ |
||
| 249 | public $customGeneratorDefinition; |
||
| 250 | |||
| 251 | /** |
||
| 252 | * The name of the custom repository class used for the entity class. |
||
| 253 | * (Optional). |
||
| 254 | * |
||
| 255 | * @var string |
||
| 256 | */ |
||
| 257 | public $customRepositoryClassName; |
||
| 258 | |||
| 259 | /** |
||
| 260 | * READ-ONLY: Whether this class describes the mapping of a mapped superclass. |
||
| 261 | * |
||
| 262 | * @var boolean |
||
| 263 | */ |
||
| 264 | public $isMappedSuperclass = false; |
||
| 265 | |||
| 266 | /** |
||
| 267 | * READ-ONLY: Whether this class describes the mapping of an embeddable class. |
||
| 268 | * |
||
| 269 | * @var boolean |
||
| 270 | */ |
||
| 271 | public $isEmbeddedClass = false; |
||
| 272 | |||
| 273 | /** |
||
| 274 | * READ-ONLY: The names of the parent classes (ancestors). |
||
| 275 | * |
||
| 276 | * @var array |
||
| 277 | */ |
||
| 278 | public $parentClasses = []; |
||
| 279 | |||
| 280 | /** |
||
| 281 | * READ-ONLY: The names of all subclasses (descendants). |
||
| 282 | * |
||
| 283 | * @var array |
||
| 284 | */ |
||
| 285 | public $subClasses = []; |
||
| 286 | |||
| 287 | /** |
||
| 288 | * READ-ONLY: The names of all embedded classes based on properties. |
||
| 289 | * |
||
| 290 | * @var array |
||
| 291 | */ |
||
| 292 | public $embeddedClasses = []; |
||
| 293 | |||
| 294 | /** |
||
| 295 | * READ-ONLY: The named queries allowed to be called directly from Repository. |
||
| 296 | * |
||
| 297 | * @var array |
||
| 298 | */ |
||
| 299 | public $namedQueries = []; |
||
| 300 | |||
| 301 | /** |
||
| 302 | * READ-ONLY: The named native queries allowed to be called directly from Repository. |
||
| 303 | * |
||
| 304 | * A native SQL named query definition has the following structure: |
||
| 305 | * <pre> |
||
| 306 | * array( |
||
| 307 | * 'name' => <query name>, |
||
| 308 | * 'query' => <sql query>, |
||
| 309 | * 'resultClass' => <class of the result>, |
||
| 310 | * 'resultSetMapping' => <name of a SqlResultSetMapping> |
||
| 311 | * ) |
||
| 312 | * </pre> |
||
| 313 | * |
||
| 314 | * @var array |
||
| 315 | */ |
||
| 316 | public $namedNativeQueries = []; |
||
| 317 | |||
| 318 | /** |
||
| 319 | * READ-ONLY: The mappings of the results of native SQL queries. |
||
| 320 | * |
||
| 321 | * A native result mapping definition has the following structure: |
||
| 322 | * <pre> |
||
| 323 | * array( |
||
| 324 | * 'name' => <result name>, |
||
| 325 | * 'entities' => array(<entity result mapping>), |
||
| 326 | * 'columns' => array(<column result mapping>) |
||
| 327 | * ) |
||
| 328 | * </pre> |
||
| 329 | * |
||
| 330 | * @var array |
||
| 331 | */ |
||
| 332 | public $sqlResultSetMappings = []; |
||
| 333 | |||
| 334 | /** |
||
| 335 | * READ-ONLY: The field names of all fields that are part of the identifier/primary key |
||
| 336 | * of the mapped entity class. |
||
| 337 | * |
||
| 338 | * @var array |
||
| 339 | */ |
||
| 340 | public $identifier = []; |
||
| 341 | |||
| 342 | /** |
||
| 343 | * READ-ONLY: The inheritance mapping type used by the class. |
||
| 344 | * |
||
| 345 | * @var integer |
||
| 346 | */ |
||
| 347 | public $inheritanceType = self::INHERITANCE_TYPE_NONE; |
||
| 348 | |||
| 349 | /** |
||
| 350 | * READ-ONLY: The Id generator type used by the class. |
||
| 351 | * |
||
| 352 | * @var int |
||
| 353 | */ |
||
| 354 | public $generatorType = self::GENERATOR_TYPE_NONE; |
||
| 355 | |||
| 356 | /** |
||
| 357 | * READ-ONLY: The field mappings of the class. |
||
| 358 | * Keys are field names and values are mapping definitions. |
||
| 359 | * |
||
| 360 | * The mapping definition array has the following values: |
||
| 361 | * |
||
| 362 | * - <b>fieldName</b> (string) |
||
| 363 | * The name of the field in the Entity. |
||
| 364 | * |
||
| 365 | * - <b>type</b> (string) |
||
| 366 | * The type name of the mapped field. Can be one of Doctrine's mapping types |
||
| 367 | * or a custom mapping type. |
||
| 368 | * |
||
| 369 | * - <b>columnName</b> (string, optional) |
||
| 370 | * The column name. Optional. Defaults to the field name. |
||
| 371 | * |
||
| 372 | * - <b>length</b> (integer, optional) |
||
| 373 | * The database length of the column. Optional. Default value taken from |
||
| 374 | * the type. |
||
| 375 | * |
||
| 376 | * - <b>id</b> (boolean, optional) |
||
| 377 | * Marks the field as the primary key of the entity. Multiple fields of an |
||
| 378 | * entity can have the id attribute, forming a composite key. |
||
| 379 | * |
||
| 380 | * - <b>nullable</b> (boolean, optional) |
||
| 381 | * Whether the column is nullable. Defaults to FALSE. |
||
| 382 | * |
||
| 383 | * - <b>columnDefinition</b> (string, optional, schema-only) |
||
| 384 | * The SQL fragment that is used when generating the DDL for the column. |
||
| 385 | * |
||
| 386 | * - <b>precision</b> (integer, optional, schema-only) |
||
| 387 | * The precision of a decimal column. Only valid if the column type is decimal. |
||
| 388 | * |
||
| 389 | * - <b>scale</b> (integer, optional, schema-only) |
||
| 390 | * The scale of a decimal column. Only valid if the column type is decimal. |
||
| 391 | * |
||
| 392 | * - <b>'unique'</b> (string, optional, schema-only) |
||
| 393 | * Whether a unique constraint should be generated for the column. |
||
| 394 | * |
||
| 395 | * @var array |
||
| 396 | */ |
||
| 397 | public $fieldMappings = []; |
||
| 398 | |||
| 399 | /** |
||
| 400 | * READ-ONLY: An array of field names. Used to look up field names from column names. |
||
| 401 | * Keys are column names and values are field names. |
||
| 402 | * |
||
| 403 | * @var array |
||
| 404 | */ |
||
| 405 | public $fieldNames = []; |
||
| 406 | |||
| 407 | /** |
||
| 408 | * READ-ONLY: A map of field names to column names. Keys are field names and values column names. |
||
| 409 | * Used to look up column names from field names. |
||
| 410 | * This is the reverse lookup map of $_fieldNames. |
||
| 411 | * |
||
| 412 | * @var array |
||
| 413 | * |
||
| 414 | * @deprecated 3.0 Remove this. |
||
| 415 | */ |
||
| 416 | public $columnNames = []; |
||
| 417 | |||
| 418 | /** |
||
| 419 | * READ-ONLY: The discriminator value of this class. |
||
| 420 | * |
||
| 421 | * <b>This does only apply to the JOINED and SINGLE_TABLE inheritance mapping strategies |
||
| 422 | * where a discriminator column is used.</b> |
||
| 423 | * |
||
| 424 | * @var mixed |
||
| 425 | * |
||
| 426 | * @see discriminatorColumn |
||
| 427 | */ |
||
| 428 | public $discriminatorValue; |
||
| 429 | |||
| 430 | /** |
||
| 431 | * READ-ONLY: The discriminator map of all mapped classes in the hierarchy. |
||
| 432 | * |
||
| 433 | * <b>This does only apply to the JOINED and SINGLE_TABLE inheritance mapping strategies |
||
| 434 | * where a discriminator column is used.</b> |
||
| 435 | * |
||
| 436 | * @var mixed |
||
| 437 | * |
||
| 438 | * @see discriminatorColumn |
||
| 439 | */ |
||
| 440 | public $discriminatorMap = []; |
||
| 441 | |||
| 442 | /** |
||
| 443 | * READ-ONLY: The definition of the discriminator column used in JOINED and SINGLE_TABLE |
||
| 444 | * inheritance mappings. |
||
| 445 | * |
||
| 446 | * @var array |
||
| 447 | */ |
||
| 448 | public $discriminatorColumn; |
||
| 449 | |||
| 450 | /** |
||
| 451 | * READ-ONLY: The primary table definition. The definition is an array with the |
||
| 452 | * following entries: |
||
| 453 | * |
||
| 454 | * name => <tableName> |
||
| 455 | * schema => <schemaName> |
||
| 456 | * indexes => array |
||
| 457 | * uniqueConstraints => array |
||
| 458 | * |
||
| 459 | * @var array |
||
| 460 | */ |
||
| 461 | public $table; |
||
| 462 | |||
| 463 | /** |
||
| 464 | * READ-ONLY: The registered lifecycle callbacks for entities of this class. |
||
| 465 | * |
||
| 466 | * @var array[] |
||
| 467 | */ |
||
| 468 | public $lifecycleCallbacks = []; |
||
| 469 | |||
| 470 | /** |
||
| 471 | * READ-ONLY: The registered entity listeners. |
||
| 472 | * |
||
| 473 | * @var array |
||
| 474 | */ |
||
| 475 | public $entityListeners = []; |
||
| 476 | |||
| 477 | /** |
||
| 478 | * READ-ONLY: The association mappings of this class. |
||
| 479 | * |
||
| 480 | * The mapping definition array supports the following keys: |
||
| 481 | * |
||
| 482 | * - <b>fieldName</b> (string) |
||
| 483 | * The name of the field in the entity the association is mapped to. |
||
| 484 | * |
||
| 485 | * - <b>targetEntity</b> (string) |
||
| 486 | * The class name of the target entity. If it is fully-qualified it is used as is. |
||
| 487 | * If it is a simple, unqualified class name the namespace is assumed to be the same |
||
| 488 | * as the namespace of the source entity. |
||
| 489 | * |
||
| 490 | * - <b>mappedBy</b> (string, required for bidirectional associations) |
||
| 491 | * The name of the field that completes the bidirectional association on the owning side. |
||
| 492 | * This key must be specified on the inverse side of a bidirectional association. |
||
| 493 | * |
||
| 494 | * - <b>inversedBy</b> (string, required for bidirectional associations) |
||
| 495 | * The name of the field that completes the bidirectional association on the inverse side. |
||
| 496 | * This key must be specified on the owning side of a bidirectional association. |
||
| 497 | * |
||
| 498 | * - <b>cascade</b> (array, optional) |
||
| 499 | * The names of persistence operations to cascade on the association. The set of possible |
||
| 500 | * values are: "persist", "remove", "detach", "merge", "refresh", "all" (implies all others). |
||
| 501 | * |
||
| 502 | * - <b>orderBy</b> (array, one-to-many/many-to-many only) |
||
| 503 | * A map of field names (of the target entity) to sorting directions (ASC/DESC). |
||
| 504 | * Example: array('priority' => 'desc') |
||
| 505 | * |
||
| 506 | * - <b>fetch</b> (integer, optional) |
||
| 507 | * The fetching strategy to use for the association, usually defaults to FETCH_LAZY. |
||
| 508 | * Possible values are: ClassMetadata::FETCH_EAGER, ClassMetadata::FETCH_LAZY. |
||
| 509 | * |
||
| 510 | * - <b>joinTable</b> (array, optional, many-to-many only) |
||
| 511 | * Specification of the join table and its join columns (foreign keys). |
||
| 512 | * Only valid for many-to-many mappings. Note that one-to-many associations can be mapped |
||
| 513 | * through a join table by simply mapping the association as many-to-many with a unique |
||
| 514 | * constraint on the join table. |
||
| 515 | * |
||
| 516 | * - <b>indexBy</b> (string, optional, to-many only) |
||
| 517 | * Specification of a field on target-entity that is used to index the collection by. |
||
| 518 | * This field HAS to be either the primary key or a unique column. Otherwise the collection |
||
| 519 | * does not contain all the entities that are actually related. |
||
| 520 | * |
||
| 521 | * A join table definition has the following structure: |
||
| 522 | * <pre> |
||
| 523 | * array( |
||
| 524 | * 'name' => <join table name>, |
||
| 525 | * 'joinColumns' => array(<join column mapping from join table to source table>), |
||
| 526 | * 'inverseJoinColumns' => array(<join column mapping from join table to target table>) |
||
| 527 | * ) |
||
| 528 | * </pre> |
||
| 529 | * |
||
| 530 | * @var array |
||
| 531 | */ |
||
| 532 | public $associationMappings = []; |
||
| 533 | |||
| 534 | /** |
||
| 535 | * READ-ONLY: Flag indicating whether the identifier/primary key of the class is composite. |
||
| 536 | * |
||
| 537 | * @var boolean |
||
| 538 | */ |
||
| 539 | public $isIdentifierComposite = false; |
||
| 540 | |||
| 541 | /** |
||
| 542 | * READ-ONLY: Flag indicating whether the identifier/primary key contains at least one foreign key association. |
||
| 543 | * |
||
| 544 | * This flag is necessary because some code blocks require special treatment of this cases. |
||
| 545 | * |
||
| 546 | * @var boolean |
||
| 547 | */ |
||
| 548 | public $containsForeignIdentifier = false; |
||
| 549 | |||
| 550 | /** |
||
| 551 | * READ-ONLY: The ID generator used for generating IDs for this class. |
||
| 552 | * |
||
| 553 | * @var \Doctrine\ORM\Id\AbstractIdGenerator |
||
| 554 | * |
||
| 555 | * @todo Remove! |
||
| 556 | */ |
||
| 557 | public $idGenerator; |
||
| 558 | |||
| 559 | /** |
||
| 560 | * READ-ONLY: The definition of the sequence generator of this class. Only used for the |
||
| 561 | * SEQUENCE generation strategy. |
||
| 562 | * |
||
| 563 | * The definition has the following structure: |
||
| 564 | * <code> |
||
| 565 | * array( |
||
| 566 | * 'sequenceName' => 'name', |
||
| 567 | * 'allocationSize' => 20, |
||
| 568 | * 'initialValue' => 1 |
||
| 569 | * ) |
||
| 570 | * </code> |
||
| 571 | * |
||
| 572 | * @var array |
||
| 573 | * |
||
| 574 | * @todo Merge with tableGeneratorDefinition into generic generatorDefinition |
||
| 575 | */ |
||
| 576 | public $sequenceGeneratorDefinition; |
||
| 577 | |||
| 578 | /** |
||
| 579 | * READ-ONLY: The definition of the table generator of this class. Only used for the |
||
| 580 | * TABLE generation strategy. |
||
| 581 | * |
||
| 582 | * @var array |
||
| 583 | * |
||
| 584 | * @todo Merge with tableGeneratorDefinition into generic generatorDefinition |
||
| 585 | */ |
||
| 586 | public $tableGeneratorDefinition; |
||
| 587 | |||
| 588 | /** |
||
| 589 | * READ-ONLY: The policy used for change-tracking on entities of this class. |
||
| 590 | * |
||
| 591 | * @var integer |
||
| 592 | */ |
||
| 593 | public $changeTrackingPolicy = self::CHANGETRACKING_DEFERRED_IMPLICIT; |
||
| 594 | |||
| 595 | /** |
||
| 596 | * READ-ONLY: A flag for whether or not instances of this class are to be versioned |
||
| 597 | * with optimistic locking. |
||
| 598 | * |
||
| 599 | * @var boolean |
||
| 600 | */ |
||
| 601 | public $isVersioned; |
||
| 602 | |||
| 603 | /** |
||
| 604 | * READ-ONLY: The name of the field which is used for versioning in optimistic locking (if any). |
||
| 605 | * |
||
| 606 | * @var mixed |
||
| 607 | */ |
||
| 608 | public $versionField; |
||
| 609 | |||
| 610 | /** |
||
| 611 | * @var array |
||
| 612 | */ |
||
| 613 | public $cache = null; |
||
| 614 | |||
| 615 | /** |
||
| 616 | * The ReflectionClass instance of the mapped class. |
||
| 617 | * |
||
| 618 | * @var ReflectionClass |
||
| 619 | */ |
||
| 620 | public $reflClass; |
||
| 621 | |||
| 622 | /** |
||
| 623 | * Is this entity marked as "read-only"? |
||
| 624 | * |
||
| 625 | * That means it is never considered for change-tracking in the UnitOfWork. It is a very helpful performance |
||
| 626 | * optimization for entities that are immutable, either in your domain or through the relation database |
||
| 627 | * (coming from a view, or a history table for example). |
||
| 628 | * |
||
| 629 | * @var bool |
||
| 630 | */ |
||
| 631 | public $isReadOnly = false; |
||
| 632 | |||
| 633 | /** |
||
| 634 | * NamingStrategy determining the default column and table names. |
||
| 635 | * |
||
| 636 | * @var \Doctrine\ORM\Mapping\NamingStrategy |
||
| 637 | */ |
||
| 638 | protected $namingStrategy; |
||
| 639 | |||
| 640 | /** |
||
| 641 | * The ReflectionProperty instances of the mapped class. |
||
| 642 | * |
||
| 643 | * @var \ReflectionProperty[] |
||
| 644 | */ |
||
| 645 | public $reflFields = []; |
||
| 646 | |||
| 647 | /** |
||
| 648 | * @var \Doctrine\Instantiator\InstantiatorInterface|null |
||
| 649 | */ |
||
| 650 | private $instantiator; |
||
| 651 | |||
| 652 | /** |
||
| 653 | * Initializes a new ClassMetadata instance that will hold the object-relational mapping |
||
| 654 | * metadata of the class with the given name. |
||
| 655 | * |
||
| 656 | * @param string $entityName The name of the entity class the new instance is used for. |
||
| 657 | * @param NamingStrategy|null $namingStrategy |
||
| 658 | */ |
||
| 659 | 640 | public function __construct($entityName, NamingStrategy $namingStrategy = null) |
|
| 666 | |||
| 667 | /** |
||
| 668 | * Gets the ReflectionProperties of the mapped class. |
||
| 669 | * |
||
| 670 | * @return array An array of ReflectionProperty instances. |
||
| 671 | */ |
||
| 672 | 226 | public function getReflectionProperties() |
|
| 676 | |||
| 677 | /** |
||
| 678 | * Gets a ReflectionProperty for a specific field of the mapped class. |
||
| 679 | * |
||
| 680 | * @param string $name |
||
| 681 | * |
||
| 682 | * @return \ReflectionProperty |
||
| 683 | */ |
||
| 684 | 1 | public function getReflectionProperty($name) |
|
| 688 | |||
| 689 | /** |
||
| 690 | * Gets the ReflectionProperty for the single identifier field. |
||
| 691 | * |
||
| 692 | * @return \ReflectionProperty |
||
| 693 | * |
||
| 694 | * @throws BadMethodCallException If the class has a composite identifier. |
||
| 695 | */ |
||
| 696 | public function getSingleIdReflectionProperty() |
||
| 697 | { |
||
| 698 | if ($this->isIdentifierComposite) { |
||
| 699 | throw new BadMethodCallException("Class " . $this->name . " has a composite identifier."); |
||
| 700 | } |
||
| 701 | |||
| 702 | return $this->reflFields[$this->identifier[0]]; |
||
| 703 | } |
||
| 704 | |||
| 705 | /** |
||
| 706 | * Extracts the identifier values of an entity of this class. |
||
| 707 | * |
||
| 708 | * For composite identifiers, the identifier values are returned as an array |
||
| 709 | * with the same order as the field order in {@link identifier}. |
||
| 710 | * |
||
| 711 | * @param object $entity |
||
| 712 | * |
||
| 713 | * @return array |
||
| 714 | */ |
||
| 715 | 463 | public function getIdentifierValues($entity) |
|
| 740 | |||
| 741 | /** |
||
| 742 | * Populates the entity identifier of an entity. |
||
| 743 | * |
||
| 744 | * @param object $entity |
||
| 745 | * @param array $id |
||
| 746 | * |
||
| 747 | * @return void |
||
| 748 | * |
||
| 749 | * @todo Rename to assignIdentifier() |
||
| 750 | */ |
||
| 751 | 7 | public function setIdentifierValues($entity, array $id) |
|
| 757 | |||
| 758 | /** |
||
| 759 | * Sets the specified field to the specified value on the given entity. |
||
| 760 | * |
||
| 761 | * @param object $entity |
||
| 762 | * @param string $field |
||
| 763 | * @param mixed $value |
||
| 764 | * |
||
| 765 | * @return void |
||
| 766 | */ |
||
| 767 | 223 | public function setFieldValue($entity, $field, $value) |
|
| 771 | |||
| 772 | /** |
||
| 773 | * Gets the specified field's value off the given entity. |
||
| 774 | * |
||
| 775 | * @param object $entity |
||
| 776 | * @param string $field |
||
| 777 | * |
||
| 778 | * @return mixed |
||
| 779 | */ |
||
| 780 | 308 | public function getFieldValue($entity, $field) |
|
| 784 | |||
| 785 | /** |
||
| 786 | * Creates a string representation of this instance. |
||
| 787 | * |
||
| 788 | * @return string The string representation of this instance. |
||
| 789 | * |
||
| 790 | * @todo Construct meaningful string representation. |
||
| 791 | */ |
||
| 792 | public function __toString() |
||
| 796 | |||
| 797 | /** |
||
| 798 | * Determines which fields get serialized. |
||
| 799 | * |
||
| 800 | * It is only serialized what is necessary for best unserialization performance. |
||
| 801 | * That means any metadata properties that are not set or empty or simply have |
||
| 802 | * their default value are NOT serialized. |
||
| 803 | * |
||
| 804 | * Parts that are also NOT serialized because they can not be properly unserialized: |
||
| 805 | * - reflClass (ReflectionClass) |
||
| 806 | * - reflFields (ReflectionProperty array) |
||
| 807 | * |
||
| 808 | * @return array The names of all the fields that should be serialized. |
||
| 809 | */ |
||
| 810 | 5 | public function __sleep() |
|
| 811 | { |
||
| 812 | // This metadata is always serialized/cached. |
||
| 813 | $serialized = [ |
||
| 814 | 5 | 'associationMappings', |
|
| 815 | 'columnNames', //TODO: 3.0 Remove this. Can use fieldMappings[$fieldName]['columnName'] |
||
| 816 | 'fieldMappings', |
||
| 817 | 'fieldNames', |
||
| 818 | 'embeddedClasses', |
||
| 819 | 'identifier', |
||
| 820 | 'isIdentifierComposite', // TODO: REMOVE |
||
| 821 | 'name', |
||
| 822 | 'namespace', // TODO: REMOVE |
||
| 823 | 'table', |
||
| 824 | 'rootEntityName', |
||
| 825 | 'idGenerator', //TODO: Does not really need to be serialized. Could be moved to runtime. |
||
| 826 | ]; |
||
| 827 | |||
| 828 | // The rest of the metadata is only serialized if necessary. |
||
| 829 | 5 | if ($this->changeTrackingPolicy != self::CHANGETRACKING_DEFERRED_IMPLICIT) { |
|
| 830 | $serialized[] = 'changeTrackingPolicy'; |
||
| 831 | } |
||
| 832 | |||
| 833 | 5 | if ($this->customRepositoryClassName) { |
|
| 834 | 1 | $serialized[] = 'customRepositoryClassName'; |
|
| 835 | } |
||
| 836 | |||
| 837 | 5 | if ($this->inheritanceType != self::INHERITANCE_TYPE_NONE) { |
|
| 838 | 1 | $serialized[] = 'inheritanceType'; |
|
| 839 | 1 | $serialized[] = 'discriminatorColumn'; |
|
| 840 | 1 | $serialized[] = 'discriminatorValue'; |
|
| 841 | 1 | $serialized[] = 'discriminatorMap'; |
|
| 842 | 1 | $serialized[] = 'parentClasses'; |
|
| 843 | 1 | $serialized[] = 'subClasses'; |
|
| 844 | } |
||
| 845 | |||
| 846 | 5 | if ($this->generatorType != self::GENERATOR_TYPE_NONE) { |
|
| 847 | $serialized[] = 'generatorType'; |
||
| 848 | if ($this->generatorType == self::GENERATOR_TYPE_SEQUENCE) { |
||
| 849 | $serialized[] = 'sequenceGeneratorDefinition'; |
||
| 850 | } |
||
| 851 | } |
||
| 852 | |||
| 853 | 5 | if ($this->isMappedSuperclass) { |
|
| 854 | $serialized[] = 'isMappedSuperclass'; |
||
| 855 | } |
||
| 856 | |||
| 857 | 5 | if ($this->isEmbeddedClass) { |
|
| 858 | 1 | $serialized[] = 'isEmbeddedClass'; |
|
| 859 | } |
||
| 860 | |||
| 861 | 5 | if ($this->containsForeignIdentifier) { |
|
| 862 | $serialized[] = 'containsForeignIdentifier'; |
||
| 863 | } |
||
| 864 | |||
| 865 | 5 | if ($this->isVersioned) { |
|
| 866 | $serialized[] = 'isVersioned'; |
||
| 867 | $serialized[] = 'versionField'; |
||
| 868 | } |
||
| 869 | |||
| 870 | 5 | if ($this->lifecycleCallbacks) { |
|
| 871 | $serialized[] = 'lifecycleCallbacks'; |
||
| 872 | } |
||
| 873 | |||
| 874 | 5 | if ($this->entityListeners) { |
|
| 875 | 1 | $serialized[] = 'entityListeners'; |
|
| 876 | } |
||
| 877 | |||
| 878 | 5 | if ($this->namedQueries) { |
|
| 879 | 1 | $serialized[] = 'namedQueries'; |
|
| 880 | } |
||
| 881 | |||
| 882 | 5 | if ($this->namedNativeQueries) { |
|
| 883 | $serialized[] = 'namedNativeQueries'; |
||
| 884 | } |
||
| 885 | |||
| 886 | 5 | if ($this->sqlResultSetMappings) { |
|
| 887 | $serialized[] = 'sqlResultSetMappings'; |
||
| 888 | } |
||
| 889 | |||
| 890 | 5 | if ($this->isReadOnly) { |
|
| 891 | 1 | $serialized[] = 'isReadOnly'; |
|
| 892 | } |
||
| 893 | |||
| 894 | 5 | if ($this->customGeneratorDefinition) { |
|
| 895 | $serialized[] = "customGeneratorDefinition"; |
||
| 896 | } |
||
| 897 | |||
| 898 | 5 | if ($this->cache) { |
|
| 899 | $serialized[] = 'cache'; |
||
| 900 | } |
||
| 901 | |||
| 902 | 5 | return $serialized; |
|
| 903 | } |
||
| 904 | |||
| 905 | /** |
||
| 906 | * Creates a new instance of the mapped class, without invoking the constructor. |
||
| 907 | * |
||
| 908 | * @return object |
||
| 909 | */ |
||
| 910 | 673 | public function newInstance() |
|
| 914 | |||
| 915 | /** |
||
| 916 | * Restores some state that can not be serialized/unserialized. |
||
| 917 | * |
||
| 918 | * @param \Doctrine\Common\Persistence\Mapping\ReflectionService $reflService |
||
| 919 | * |
||
| 920 | * @return void |
||
| 921 | */ |
||
| 922 | 1989 | public function wakeupReflection($reflService) |
|
| 923 | { |
||
| 924 | // Restore ReflectionClass and properties |
||
| 925 | 1989 | $this->reflClass = $reflService->getClass($this->name); |
|
| 926 | 1989 | $this->instantiator = $this->instantiator ?: new Instantiator(); |
|
| 927 | |||
| 928 | 1989 | $parentReflFields = []; |
|
| 929 | |||
| 930 | 1989 | foreach ($this->embeddedClasses as $property => $embeddedClass) { |
|
| 931 | 21 | if (isset($embeddedClass['declaredField'])) { |
|
| 932 | 15 | $parentReflFields[$property] = new ReflectionEmbeddedProperty( |
|
| 933 | 15 | $parentReflFields[$embeddedClass['declaredField']], |
|
| 934 | 15 | $reflService->getAccessibleProperty( |
|
| 935 | 15 | $this->embeddedClasses[$embeddedClass['declaredField']]['class'], |
|
| 936 | 15 | $embeddedClass['originalField'] |
|
| 937 | ), |
||
| 938 | 15 | $this->embeddedClasses[$embeddedClass['declaredField']]['class'] |
|
| 939 | ); |
||
| 940 | |||
| 941 | 15 | continue; |
|
| 942 | } |
||
| 943 | |||
| 944 | 21 | $fieldRefl = $reflService->getAccessibleProperty( |
|
| 945 | 21 | isset($embeddedClass['declared']) ? $embeddedClass['declared'] : $this->name, |
|
| 946 | $property |
||
| 947 | ); |
||
| 948 | |||
| 949 | 21 | $parentReflFields[$property] = $fieldRefl; |
|
| 950 | 21 | $this->reflFields[$property] = $fieldRefl; |
|
| 951 | } |
||
| 952 | |||
| 953 | 1989 | foreach ($this->fieldMappings as $field => $mapping) { |
|
| 954 | 1984 | if (isset($mapping['declaredField']) && isset($parentReflFields[$mapping['declaredField']])) { |
|
| 955 | 20 | $this->reflFields[$field] = new ReflectionEmbeddedProperty( |
|
| 956 | 20 | $parentReflFields[$mapping['declaredField']], |
|
| 957 | 20 | $reflService->getAccessibleProperty($mapping['originalClass'], $mapping['originalField']), |
|
| 958 | 20 | $mapping['originalClass'] |
|
| 959 | ); |
||
| 960 | 20 | continue; |
|
| 961 | } |
||
| 962 | |||
| 963 | 1984 | $this->reflFields[$field] = isset($mapping['declared']) |
|
| 964 | 482 | ? $reflService->getAccessibleProperty($mapping['declared'], $field) |
|
| 965 | 1984 | : $reflService->getAccessibleProperty($this->name, $field); |
|
| 966 | } |
||
| 967 | |||
| 968 | 1989 | foreach ($this->associationMappings as $field => $mapping) { |
|
| 969 | 1669 | $this->reflFields[$field] = isset($mapping['declared']) |
|
| 970 | 395 | ? $reflService->getAccessibleProperty($mapping['declared'], $field) |
|
| 971 | 1669 | : $reflService->getAccessibleProperty($this->name, $field); |
|
| 972 | } |
||
| 973 | 1989 | } |
|
| 974 | |||
| 975 | /** |
||
| 976 | * Initializes a new ClassMetadata instance that will hold the object-relational mapping |
||
| 977 | * metadata of the class with the given name. |
||
| 978 | * |
||
| 979 | * @param \Doctrine\Common\Persistence\Mapping\ReflectionService $reflService The reflection service. |
||
| 980 | * |
||
| 981 | * @return void |
||
| 982 | */ |
||
| 983 | 604 | public function initializeReflection($reflService) |
|
| 994 | |||
| 995 | /** |
||
| 996 | * Validates Identifier. |
||
| 997 | * |
||
| 998 | * @return void |
||
| 999 | * |
||
| 1000 | * @throws MappingException |
||
| 1001 | */ |
||
| 1002 | 401 | public function validateIdentifier() |
|
| 1017 | |||
| 1018 | /** |
||
| 1019 | * Validates association targets actually exist. |
||
| 1020 | * |
||
| 1021 | * @return void |
||
| 1022 | * |
||
| 1023 | * @throws MappingException |
||
| 1024 | */ |
||
| 1025 | 402 | public function validateAssociations() |
|
| 1033 | |||
| 1034 | /** |
||
| 1035 | * Validates lifecycle callbacks. |
||
| 1036 | * |
||
| 1037 | * @param \Doctrine\Common\Persistence\Mapping\ReflectionService $reflService |
||
| 1038 | * |
||
| 1039 | * @return void |
||
| 1040 | * |
||
| 1041 | * @throws MappingException |
||
| 1042 | */ |
||
| 1043 | 402 | public function validateLifecycleCallbacks($reflService) |
|
| 1053 | |||
| 1054 | /** |
||
| 1055 | * {@inheritDoc} |
||
| 1056 | */ |
||
| 1057 | 529 | public function getReflectionClass() |
|
| 1061 | |||
| 1062 | /** |
||
| 1063 | * @param array $cache |
||
| 1064 | * |
||
| 1065 | * @return void |
||
| 1066 | */ |
||
| 1067 | 23 | public function enableCache(array $cache) |
|
| 1079 | |||
| 1080 | /** |
||
| 1081 | * @param string $fieldName |
||
| 1082 | * @param array $cache |
||
| 1083 | * |
||
| 1084 | * @return void |
||
| 1085 | */ |
||
| 1086 | 2 | public function enableAssociationCache($fieldName, array $cache) |
|
| 1090 | |||
| 1091 | /** |
||
| 1092 | * @param string $fieldName |
||
| 1093 | * @param array $cache |
||
| 1094 | * |
||
| 1095 | * @return array |
||
| 1096 | */ |
||
| 1097 | 18 | public function getAssociationCacheDefaults($fieldName, array $cache) |
|
| 1111 | |||
| 1112 | /** |
||
| 1113 | * Sets the change tracking policy used by this class. |
||
| 1114 | * |
||
| 1115 | * @param integer $policy |
||
| 1116 | * |
||
| 1117 | * @return void |
||
| 1118 | */ |
||
| 1119 | 134 | public function setChangeTrackingPolicy($policy) |
|
| 1123 | |||
| 1124 | /** |
||
| 1125 | * Whether the change tracking policy of this class is "deferred explicit". |
||
| 1126 | * |
||
| 1127 | * @return boolean |
||
| 1128 | */ |
||
| 1129 | 266 | public function isChangeTrackingDeferredExplicit() |
|
| 1133 | |||
| 1134 | /** |
||
| 1135 | * Whether the change tracking policy of this class is "deferred implicit". |
||
| 1136 | * |
||
| 1137 | * @return boolean |
||
| 1138 | */ |
||
| 1139 | 443 | public function isChangeTrackingDeferredImplicit() |
|
| 1143 | |||
| 1144 | /** |
||
| 1145 | * Whether the change tracking policy of this class is "notify". |
||
| 1146 | * |
||
| 1147 | * @return boolean |
||
| 1148 | */ |
||
| 1149 | 287 | public function isChangeTrackingNotify() |
|
| 1153 | |||
| 1154 | /** |
||
| 1155 | * Checks whether a field is part of the identifier/primary key field(s). |
||
| 1156 | * |
||
| 1157 | * @param string $fieldName The field name. |
||
| 1158 | * |
||
| 1159 | * @return boolean TRUE if the field is part of the table identifier/primary key field(s), |
||
| 1160 | * FALSE otherwise. |
||
| 1161 | */ |
||
| 1162 | 1050 | public function isIdentifier($fieldName) |
|
| 1174 | |||
| 1175 | /** |
||
| 1176 | * Checks if the field is unique. |
||
| 1177 | * |
||
| 1178 | * @param string $fieldName The field name. |
||
| 1179 | * |
||
| 1180 | * @return boolean TRUE if the field is unique, FALSE otherwise. |
||
| 1181 | */ |
||
| 1182 | public function isUniqueField($fieldName) |
||
| 1188 | |||
| 1189 | /** |
||
| 1190 | * Checks if the field is not null. |
||
| 1191 | * |
||
| 1192 | * @param string $fieldName The field name. |
||
| 1193 | * |
||
| 1194 | * @return boolean TRUE if the field is not null, FALSE otherwise. |
||
| 1195 | */ |
||
| 1196 | 1 | public function isNullable($fieldName) |
|
| 1202 | |||
| 1203 | /** |
||
| 1204 | * Gets a column name for a field name. |
||
| 1205 | * If the column name for the field cannot be found, the given field name |
||
| 1206 | * is returned. |
||
| 1207 | * |
||
| 1208 | * @param string $fieldName The field name. |
||
| 1209 | * |
||
| 1210 | * @return string The column name. |
||
| 1211 | */ |
||
| 1212 | 16 | public function getColumnName($fieldName) |
|
| 1218 | |||
| 1219 | /** |
||
| 1220 | * Gets the mapping of a (regular) field that holds some data but not a |
||
| 1221 | * reference to another object. |
||
| 1222 | * |
||
| 1223 | * @param string $fieldName The field name. |
||
| 1224 | * |
||
| 1225 | * @return array The field mapping. |
||
| 1226 | * |
||
| 1227 | * @throws MappingException |
||
| 1228 | */ |
||
| 1229 | 187 | public function getFieldMapping($fieldName) |
|
| 1237 | |||
| 1238 | /** |
||
| 1239 | * Gets the mapping of an association. |
||
| 1240 | * |
||
| 1241 | * @see ClassMetadataInfo::$associationMappings |
||
| 1242 | * |
||
| 1243 | * @param string $fieldName The field name that represents the association in |
||
| 1244 | * the object model. |
||
| 1245 | * |
||
| 1246 | * @return array The mapping. |
||
| 1247 | * |
||
| 1248 | * @throws MappingException |
||
| 1249 | */ |
||
| 1250 | 487 | public function getAssociationMapping($fieldName) |
|
| 1258 | |||
| 1259 | /** |
||
| 1260 | * Gets all association mappings of the class. |
||
| 1261 | * |
||
| 1262 | * @return array |
||
| 1263 | */ |
||
| 1264 | public function getAssociationMappings() |
||
| 1268 | |||
| 1269 | /** |
||
| 1270 | * Gets the field name for a column name. |
||
| 1271 | * If no field name can be found the column name is returned. |
||
| 1272 | * |
||
| 1273 | * @param string $columnName The column name. |
||
| 1274 | * |
||
| 1275 | * @return string The column alias. |
||
| 1276 | */ |
||
| 1277 | 223 | public function getFieldName($columnName) |
|
| 1283 | |||
| 1284 | /** |
||
| 1285 | * Gets the named query. |
||
| 1286 | * |
||
| 1287 | * @see ClassMetadataInfo::$namedQueries |
||
| 1288 | * |
||
| 1289 | * @param string $queryName The query name. |
||
| 1290 | * |
||
| 1291 | * @return string |
||
| 1292 | * |
||
| 1293 | * @throws MappingException |
||
| 1294 | */ |
||
| 1295 | 4 | public function getNamedQuery($queryName) |
|
| 1303 | |||
| 1304 | /** |
||
| 1305 | * Gets all named queries of the class. |
||
| 1306 | * |
||
| 1307 | * @return array |
||
| 1308 | */ |
||
| 1309 | 7 | public function getNamedQueries() |
|
| 1313 | |||
| 1314 | /** |
||
| 1315 | * Gets the named native query. |
||
| 1316 | * |
||
| 1317 | * @see ClassMetadataInfo::$namedNativeQueries |
||
| 1318 | * |
||
| 1319 | * @param string $queryName The query name. |
||
| 1320 | * |
||
| 1321 | * @return array |
||
| 1322 | * |
||
| 1323 | * @throws MappingException |
||
| 1324 | */ |
||
| 1325 | 17 | public function getNamedNativeQuery($queryName) |
|
| 1333 | |||
| 1334 | /** |
||
| 1335 | * Gets all named native queries of the class. |
||
| 1336 | * |
||
| 1337 | * @return array |
||
| 1338 | */ |
||
| 1339 | 2 | public function getNamedNativeQueries() |
|
| 1343 | |||
| 1344 | /** |
||
| 1345 | * Gets the result set mapping. |
||
| 1346 | * |
||
| 1347 | * @see ClassMetadataInfo::$sqlResultSetMappings |
||
| 1348 | * |
||
| 1349 | * @param string $name The result set mapping name. |
||
| 1350 | * |
||
| 1351 | * @return array |
||
| 1352 | * |
||
| 1353 | * @throws MappingException |
||
| 1354 | */ |
||
| 1355 | 21 | public function getSqlResultSetMapping($name) |
|
| 1363 | |||
| 1364 | /** |
||
| 1365 | * Gets all sql result set mappings of the class. |
||
| 1366 | * |
||
| 1367 | * @return array |
||
| 1368 | */ |
||
| 1369 | 8 | public function getSqlResultSetMappings() |
|
| 1373 | |||
| 1374 | /** |
||
| 1375 | * Validates & completes the given field mapping. |
||
| 1376 | * |
||
| 1377 | * @param array $mapping The field mapping to validate & complete. |
||
| 1378 | * |
||
| 1379 | * @return array The validated and completed field mapping. |
||
| 1380 | * |
||
| 1381 | * @throws MappingException |
||
| 1382 | */ |
||
| 1383 | 521 | protected function _validateAndCompleteFieldMapping(array &$mapping) |
|
| 1437 | |||
| 1438 | /** |
||
| 1439 | * Validates & completes the basic mapping information that is common to all |
||
| 1440 | * association mappings (one-to-one, many-ot-one, one-to-many, many-to-many). |
||
| 1441 | * |
||
| 1442 | * @param array $mapping The mapping. |
||
| 1443 | * |
||
| 1444 | * @return array The updated mapping. |
||
| 1445 | * |
||
| 1446 | * @throws MappingException If something is wrong with the mapping. |
||
| 1447 | */ |
||
| 1448 | 336 | protected function _validateAndCompleteAssociationMapping(array $mapping) |
|
| 1558 | |||
| 1559 | /** |
||
| 1560 | * Validates & completes a one-to-one association mapping. |
||
| 1561 | * |
||
| 1562 | * @param array $mapping The mapping to validate & complete. |
||
| 1563 | * |
||
| 1564 | * @return array The validated & completed mapping. |
||
| 1565 | * |
||
| 1566 | * @throws RuntimeException |
||
| 1567 | * @throws MappingException |
||
| 1568 | */ |
||
| 1569 | 287 | protected function _validateAndCompleteOneToOneMapping(array $mapping) |
|
| 1570 | { |
||
| 1571 | 287 | $mapping = $this->_validateAndCompleteAssociationMapping($mapping); |
|
| 1572 | |||
| 1573 | 281 | if (isset($mapping['joinColumns']) && $mapping['joinColumns']) { |
|
| 1574 | 203 | $mapping['isOwningSide'] = true; |
|
| 1575 | } |
||
| 1576 | |||
| 1577 | 281 | if ($mapping['isOwningSide']) { |
|
| 1578 | 268 | if (empty($mapping['joinColumns'])) { |
|
| 1579 | // Apply default join column |
||
| 1580 | 85 | $mapping['joinColumns'] = [ |
|
| 1581 | [ |
||
| 1582 | 85 | 'name' => $this->namingStrategy->joinColumnName($mapping['fieldName'], $this->name), |
|
| 1583 | 85 | 'referencedColumnName' => $this->namingStrategy->referenceColumnName() |
|
| 1584 | ] |
||
| 1585 | ]; |
||
| 1586 | } |
||
| 1587 | |||
| 1588 | 268 | $uniqueConstraintColumns = []; |
|
| 1589 | |||
| 1590 | 268 | foreach ($mapping['joinColumns'] as &$joinColumn) { |
|
| 1591 | 268 | if ($mapping['type'] === self::ONE_TO_ONE && ! $this->isInheritanceTypeSingleTable()) { |
|
| 1592 | 146 | if (count($mapping['joinColumns']) === 1) { |
|
| 1593 | 144 | if (empty($mapping['id'])) { |
|
| 1594 | 144 | $joinColumn['unique'] = true; |
|
| 1595 | } |
||
| 1596 | } else { |
||
| 1597 | 2 | $uniqueConstraintColumns[] = $joinColumn['name']; |
|
| 1598 | } |
||
| 1599 | } |
||
| 1600 | |||
| 1601 | 268 | if (empty($joinColumn['name'])) { |
|
| 1602 | 27 | $joinColumn['name'] = $this->namingStrategy->joinColumnName($mapping['fieldName'], $this->name); |
|
| 1603 | } |
||
| 1604 | |||
| 1605 | 268 | if (empty($joinColumn['referencedColumnName'])) { |
|
| 1606 | 5 | $joinColumn['referencedColumnName'] = $this->namingStrategy->referenceColumnName(); |
|
| 1607 | } |
||
| 1608 | |||
| 1609 | 268 | if ($joinColumn['name'][0] === '`') { |
|
| 1610 | 7 | $joinColumn['name'] = trim($joinColumn['name'], '`'); |
|
| 1611 | 7 | $joinColumn['quoted'] = true; |
|
| 1612 | } |
||
| 1613 | |||
| 1614 | 268 | if ($joinColumn['referencedColumnName'][0] === '`') { |
|
| 1615 | 4 | $joinColumn['referencedColumnName'] = trim($joinColumn['referencedColumnName'], '`'); |
|
| 1616 | 4 | $joinColumn['quoted'] = true; |
|
| 1617 | } |
||
| 1618 | |||
| 1619 | 268 | $mapping['sourceToTargetKeyColumns'][$joinColumn['name']] = $joinColumn['referencedColumnName']; |
|
| 1620 | 268 | $mapping['joinColumnFieldNames'][$joinColumn['name']] = isset($joinColumn['fieldName']) |
|
| 1621 | ? $joinColumn['fieldName'] |
||
| 1622 | 268 | : $joinColumn['name']; |
|
| 1623 | } |
||
| 1624 | |||
| 1625 | 268 | if ($uniqueConstraintColumns) { |
|
| 1626 | 2 | if ( ! $this->table) { |
|
| 1627 | throw new RuntimeException("ClassMetadataInfo::setTable() has to be called before defining a one to one relationship."); |
||
| 1628 | } |
||
| 1629 | |||
| 1630 | 2 | $this->table['uniqueConstraints'][$mapping['fieldName'] . "_uniq"] = [ |
|
| 1631 | 2 | 'columns' => $uniqueConstraintColumns |
|
| 1632 | ]; |
||
| 1633 | } |
||
| 1634 | |||
| 1635 | 268 | $mapping['targetToSourceKeyColumns'] = array_flip($mapping['sourceToTargetKeyColumns']); |
|
| 1636 | } |
||
| 1637 | |||
| 1638 | 281 | $mapping['orphanRemoval'] = isset($mapping['orphanRemoval']) && $mapping['orphanRemoval']; |
|
| 1639 | 281 | $mapping['isCascadeRemove'] = $mapping['orphanRemoval'] || $mapping['isCascadeRemove']; |
|
| 1640 | |||
| 1641 | 281 | if ($mapping['orphanRemoval']) { |
|
| 1642 | 22 | unset($mapping['unique']); |
|
| 1643 | } |
||
| 1644 | |||
| 1645 | 281 | if (isset($mapping['id']) && $mapping['id'] === true && !$mapping['isOwningSide']) { |
|
| 1646 | 2 | throw MappingException::illegalInverseIdentifierAssociation($this->name, $mapping['fieldName']); |
|
| 1647 | } |
||
| 1648 | |||
| 1649 | 279 | return $mapping; |
|
| 1650 | } |
||
| 1651 | |||
| 1652 | /** |
||
| 1653 | * Validates & completes a one-to-many association mapping. |
||
| 1654 | * |
||
| 1655 | * @param array $mapping The mapping to validate and complete. |
||
| 1656 | * |
||
| 1657 | * @return array The validated and completed mapping. |
||
| 1658 | * |
||
| 1659 | * @throws MappingException |
||
| 1660 | * @throws InvalidArgumentException |
||
| 1661 | */ |
||
| 1662 | 121 | protected function _validateAndCompleteOneToManyMapping(array $mapping) |
|
| 1678 | |||
| 1679 | /** |
||
| 1680 | * Validates & completes a many-to-many association mapping. |
||
| 1681 | * |
||
| 1682 | * @param array $mapping The mapping to validate & complete. |
||
| 1683 | * |
||
| 1684 | * @return array The validated & completed mapping. |
||
| 1685 | * |
||
| 1686 | * @throws \InvalidArgumentException |
||
| 1687 | */ |
||
| 1688 | 143 | protected function _validateAndCompleteManyToManyMapping(array $mapping) |
|
| 1689 | { |
||
| 1690 | 143 | $mapping = $this->_validateAndCompleteAssociationMapping($mapping); |
|
| 1691 | |||
| 1692 | 141 | if ($mapping['isOwningSide']) { |
|
| 1693 | // owning side MUST have a join table |
||
| 1694 | 123 | if ( ! isset($mapping['joinTable']['name'])) { |
|
| 1695 | 22 | $mapping['joinTable']['name'] = $this->namingStrategy->joinTableName($mapping['sourceEntity'], $mapping['targetEntity'], $mapping['fieldName']); |
|
| 1696 | } |
||
| 1697 | |||
| 1698 | 123 | $selfReferencingEntityWithoutJoinColumns = $mapping['sourceEntity'] == $mapping['targetEntity'] |
|
| 1699 | 123 | && (! (isset($mapping['joinTable']['joinColumns']) || isset($mapping['joinTable']['inverseJoinColumns']))); |
|
| 1700 | |||
| 1701 | 123 | if ( ! isset($mapping['joinTable']['joinColumns'])) { |
|
| 1702 | 21 | $mapping['joinTable']['joinColumns'] = [ |
|
| 1703 | [ |
||
| 1704 | 21 | 'name' => $this->namingStrategy->joinKeyColumnName($mapping['sourceEntity'], $selfReferencingEntityWithoutJoinColumns ? 'source' : null), |
|
| 1705 | 21 | 'referencedColumnName' => $this->namingStrategy->referenceColumnName(), |
|
| 1706 | 21 | 'onDelete' => 'CASCADE' |
|
| 1707 | ] |
||
| 1708 | ]; |
||
| 1709 | } |
||
| 1710 | |||
| 1711 | 123 | if ( ! isset($mapping['joinTable']['inverseJoinColumns'])) { |
|
| 1712 | 22 | $mapping['joinTable']['inverseJoinColumns'] = [ |
|
| 1713 | [ |
||
| 1714 | 22 | 'name' => $this->namingStrategy->joinKeyColumnName($mapping['targetEntity'], $selfReferencingEntityWithoutJoinColumns ? 'target' : null), |
|
| 1715 | 22 | 'referencedColumnName' => $this->namingStrategy->referenceColumnName(), |
|
| 1716 | 22 | 'onDelete' => 'CASCADE' |
|
| 1717 | ] |
||
| 1718 | ]; |
||
| 1719 | } |
||
| 1720 | |||
| 1721 | 123 | $mapping['joinTableColumns'] = []; |
|
| 1722 | |||
| 1723 | 123 | foreach ($mapping['joinTable']['joinColumns'] as &$joinColumn) { |
|
| 1724 | 123 | if (empty($joinColumn['name'])) { |
|
| 1725 | 2 | $joinColumn['name'] = $this->namingStrategy->joinKeyColumnName($mapping['sourceEntity'], $joinColumn['referencedColumnName']); |
|
| 1726 | } |
||
| 1727 | |||
| 1728 | 123 | if (empty($joinColumn['referencedColumnName'])) { |
|
| 1729 | 6 | $joinColumn['referencedColumnName'] = $this->namingStrategy->referenceColumnName(); |
|
| 1730 | } |
||
| 1731 | |||
| 1732 | 123 | if ($joinColumn['name'][0] === '`') { |
|
| 1733 | 3 | $joinColumn['name'] = trim($joinColumn['name'], '`'); |
|
| 1734 | 3 | $joinColumn['quoted'] = true; |
|
| 1735 | } |
||
| 1736 | |||
| 1737 | 123 | if ($joinColumn['referencedColumnName'][0] === '`') { |
|
| 1738 | 3 | $joinColumn['referencedColumnName'] = trim($joinColumn['referencedColumnName'], '`'); |
|
| 1739 | 3 | $joinColumn['quoted'] = true; |
|
| 1740 | } |
||
| 1741 | |||
| 1742 | 123 | if (isset($joinColumn['onDelete']) && strtolower($joinColumn['onDelete']) == 'cascade') { |
|
| 1743 | 31 | $mapping['isOnDeleteCascade'] = true; |
|
| 1744 | } |
||
| 1745 | |||
| 1746 | 123 | $mapping['relationToSourceKeyColumns'][$joinColumn['name']] = $joinColumn['referencedColumnName']; |
|
| 1747 | 123 | $mapping['joinTableColumns'][] = $joinColumn['name']; |
|
| 1748 | } |
||
| 1749 | |||
| 1750 | 123 | foreach ($mapping['joinTable']['inverseJoinColumns'] as &$inverseJoinColumn) { |
|
| 1751 | 123 | if (empty($inverseJoinColumn['name'])) { |
|
| 1752 | 2 | $inverseJoinColumn['name'] = $this->namingStrategy->joinKeyColumnName($mapping['targetEntity'], $inverseJoinColumn['referencedColumnName']); |
|
| 1753 | } |
||
| 1754 | |||
| 1755 | 123 | if (empty($inverseJoinColumn['referencedColumnName'])) { |
|
| 1756 | 6 | $inverseJoinColumn['referencedColumnName'] = $this->namingStrategy->referenceColumnName(); |
|
| 1757 | } |
||
| 1758 | |||
| 1759 | 123 | if ($inverseJoinColumn['name'][0] === '`') { |
|
| 1760 | 3 | $inverseJoinColumn['name'] = trim($inverseJoinColumn['name'], '`'); |
|
| 1761 | 3 | $inverseJoinColumn['quoted'] = true; |
|
| 1762 | } |
||
| 1763 | |||
| 1764 | 123 | if ($inverseJoinColumn['referencedColumnName'][0] === '`') { |
|
| 1765 | 3 | $inverseJoinColumn['referencedColumnName'] = trim($inverseJoinColumn['referencedColumnName'], '`'); |
|
| 1766 | 3 | $inverseJoinColumn['quoted'] = true; |
|
| 1767 | } |
||
| 1768 | |||
| 1769 | 123 | if (isset($inverseJoinColumn['onDelete']) && strtolower($inverseJoinColumn['onDelete']) == 'cascade') { |
|
| 1770 | 27 | $mapping['isOnDeleteCascade'] = true; |
|
| 1771 | } |
||
| 1772 | |||
| 1773 | 123 | $mapping['relationToTargetKeyColumns'][$inverseJoinColumn['name']] = $inverseJoinColumn['referencedColumnName']; |
|
| 1774 | 123 | $mapping['joinTableColumns'][] = $inverseJoinColumn['name']; |
|
| 1775 | } |
||
| 1776 | } |
||
| 1777 | |||
| 1778 | 141 | $mapping['orphanRemoval'] = isset($mapping['orphanRemoval']) && $mapping['orphanRemoval']; |
|
| 1779 | |||
| 1780 | 141 | $this->assertMappingOrderBy($mapping); |
|
| 1781 | |||
| 1782 | 141 | return $mapping; |
|
| 1783 | } |
||
| 1784 | |||
| 1785 | /** |
||
| 1786 | * {@inheritDoc} |
||
| 1787 | */ |
||
| 1788 | 585 | public function getIdentifierFieldNames() |
|
| 1792 | |||
| 1793 | /** |
||
| 1794 | * Gets the name of the single id field. Note that this only works on |
||
| 1795 | * entity classes that have a single-field pk. |
||
| 1796 | * |
||
| 1797 | * @return string |
||
| 1798 | * |
||
| 1799 | * @throws MappingException If the class has a composite primary key. |
||
| 1800 | */ |
||
| 1801 | 1108 | public function getSingleIdentifierFieldName() |
|
| 1809 | |||
| 1810 | /** |
||
| 1811 | * Gets the column name of the single id column. Note that this only works on |
||
| 1812 | * entity classes that have a single-field pk. |
||
| 1813 | * |
||
| 1814 | * @return string |
||
| 1815 | * |
||
| 1816 | * @throws MappingException If the class has a composite primary key. |
||
| 1817 | */ |
||
| 1818 | 3 | public function getSingleIdentifierColumnName() |
|
| 1822 | |||
| 1823 | /** |
||
| 1824 | * INTERNAL: |
||
| 1825 | * Sets the mapped identifier/primary key fields of this class. |
||
| 1826 | * Mainly used by the ClassMetadataFactory to assign inherited identifiers. |
||
| 1827 | * |
||
| 1828 | * @param array $identifier |
||
| 1829 | * |
||
| 1830 | * @return void |
||
| 1831 | */ |
||
| 1832 | 121 | public function setIdentifier(array $identifier) |
|
| 1837 | |||
| 1838 | /** |
||
| 1839 | * {@inheritDoc} |
||
| 1840 | */ |
||
| 1841 | 61 | public function getIdentifier() |
|
| 1845 | |||
| 1846 | /** |
||
| 1847 | * {@inheritDoc} |
||
| 1848 | */ |
||
| 1849 | 275 | public function hasField($fieldName) |
|
| 1853 | |||
| 1854 | /** |
||
| 1855 | * Gets an array containing all the column names. |
||
| 1856 | * |
||
| 1857 | * @param array|null $fieldNames |
||
| 1858 | * |
||
| 1859 | * @return array |
||
| 1860 | */ |
||
| 1861 | 41 | public function getColumnNames(array $fieldNames = null) |
|
| 1869 | |||
| 1870 | /** |
||
| 1871 | * Returns an array with all the identifier column names. |
||
| 1872 | * |
||
| 1873 | * @return array |
||
| 1874 | */ |
||
| 1875 | 310 | public function getIdentifierColumnNames() |
|
| 1895 | |||
| 1896 | /** |
||
| 1897 | * Sets the type of Id generator to use for the mapped class. |
||
| 1898 | * |
||
| 1899 | * @param int $generatorType |
||
| 1900 | * |
||
| 1901 | * @return void |
||
| 1902 | */ |
||
| 1903 | 439 | public function setIdGeneratorType($generatorType) |
|
| 1907 | |||
| 1908 | /** |
||
| 1909 | * Checks whether the mapped class uses an Id generator. |
||
| 1910 | * |
||
| 1911 | * @return boolean TRUE if the mapped class uses an Id generator, FALSE otherwise. |
||
| 1912 | */ |
||
| 1913 | 393 | public function usesIdGenerator() |
|
| 1917 | |||
| 1918 | /** |
||
| 1919 | * @return boolean |
||
| 1920 | */ |
||
| 1921 | 1313 | public function isInheritanceTypeNone() |
|
| 1925 | |||
| 1926 | /** |
||
| 1927 | * Checks whether the mapped class uses the JOINED inheritance mapping strategy. |
||
| 1928 | * |
||
| 1929 | * @return boolean TRUE if the class participates in a JOINED inheritance mapping, |
||
| 1930 | * FALSE otherwise. |
||
| 1931 | */ |
||
| 1932 | 1029 | public function isInheritanceTypeJoined() |
|
| 1936 | |||
| 1937 | /** |
||
| 1938 | * Checks whether the mapped class uses the SINGLE_TABLE inheritance mapping strategy. |
||
| 1939 | * |
||
| 1940 | * @return boolean TRUE if the class participates in a SINGLE_TABLE inheritance mapping, |
||
| 1941 | * FALSE otherwise. |
||
| 1942 | */ |
||
| 1943 | 1197 | public function isInheritanceTypeSingleTable() |
|
| 1947 | |||
| 1948 | /** |
||
| 1949 | * Checks whether the mapped class uses the TABLE_PER_CLASS inheritance mapping strategy. |
||
| 1950 | * |
||
| 1951 | * @return boolean TRUE if the class participates in a TABLE_PER_CLASS inheritance mapping, |
||
| 1952 | * FALSE otherwise. |
||
| 1953 | */ |
||
| 1954 | 241 | public function isInheritanceTypeTablePerClass() |
|
| 1958 | |||
| 1959 | /** |
||
| 1960 | * Checks whether the class uses an identity column for the Id generation. |
||
| 1961 | * |
||
| 1962 | * @return boolean TRUE if the class uses the IDENTITY generator, FALSE otherwise. |
||
| 1963 | */ |
||
| 1964 | 1039 | public function isIdGeneratorIdentity() |
|
| 1968 | |||
| 1969 | /** |
||
| 1970 | * Checks whether the class uses a sequence for id generation. |
||
| 1971 | * |
||
| 1972 | * @return boolean TRUE if the class uses the SEQUENCE generator, FALSE otherwise. |
||
| 1973 | */ |
||
| 1974 | 294 | public function isIdGeneratorSequence() |
|
| 1978 | |||
| 1979 | /** |
||
| 1980 | * Checks whether the class uses a table for id generation. |
||
| 1981 | * |
||
| 1982 | * @return boolean TRUE if the class uses the TABLE generator, FALSE otherwise. |
||
| 1983 | */ |
||
| 1984 | 77 | public function isIdGeneratorTable() |
|
| 1988 | |||
| 1989 | /** |
||
| 1990 | * Checks whether the class has a natural identifier/pk (which means it does |
||
| 1991 | * not use any Id generator. |
||
| 1992 | * |
||
| 1993 | * @return boolean |
||
| 1994 | */ |
||
| 1995 | 62 | public function isIdentifierNatural() |
|
| 1999 | |||
| 2000 | /** |
||
| 2001 | * Checks whether the class use a UUID for id generation. |
||
| 2002 | * |
||
| 2003 | * @return boolean |
||
| 2004 | */ |
||
| 2005 | public function isIdentifierUuid() |
||
| 2009 | |||
| 2010 | /** |
||
| 2011 | * Gets the type of a field. |
||
| 2012 | * |
||
| 2013 | * @param string $fieldName |
||
| 2014 | * |
||
| 2015 | * @return \Doctrine\DBAL\Types\Type|string|null |
||
| 2016 | * |
||
| 2017 | * @todo 3.0 Remove this. PersisterHelper should fix it somehow |
||
| 2018 | */ |
||
| 2019 | 901 | public function getTypeOfField($fieldName) |
|
| 2025 | |||
| 2026 | /** |
||
| 2027 | * Gets the type of a column. |
||
| 2028 | * |
||
| 2029 | * @param string $columnName |
||
| 2030 | * |
||
| 2031 | * @return \Doctrine\DBAL\Types\Type|string|null |
||
| 2032 | * |
||
| 2033 | * @deprecated 3.0 remove this. this method is bogous and unreliable, since it cannot resolve the type of a column |
||
| 2034 | * that is derived by a referenced field on a different entity. |
||
| 2035 | */ |
||
| 2036 | public function getTypeOfColumn($columnName) |
||
| 2040 | |||
| 2041 | /** |
||
| 2042 | * Gets the name of the primary table. |
||
| 2043 | * |
||
| 2044 | * @return string |
||
| 2045 | */ |
||
| 2046 | 1322 | public function getTableName() |
|
| 2050 | |||
| 2051 | /** |
||
| 2052 | * Gets primary table's schema name. |
||
| 2053 | * |
||
| 2054 | * @return string|null |
||
| 2055 | */ |
||
| 2056 | 13 | public function getSchemaName() |
|
| 2060 | |||
| 2061 | /** |
||
| 2062 | * Gets the table name to use for temporary identifier tables of this class. |
||
| 2063 | * |
||
| 2064 | * @return string |
||
| 2065 | */ |
||
| 2066 | 6 | public function getTemporaryIdTableName() |
|
| 2071 | |||
| 2072 | /** |
||
| 2073 | * Sets the mapped subclasses of this class. |
||
| 2074 | * |
||
| 2075 | * @param array $subclasses The names of all mapped subclasses. |
||
| 2076 | * |
||
| 2077 | * @return void |
||
| 2078 | */ |
||
| 2079 | 2 | public function setSubclasses(array $subclasses) |
|
| 2085 | |||
| 2086 | /** |
||
| 2087 | * Sets the parent class names. |
||
| 2088 | * Assumes that the class names in the passed array are in the order: |
||
| 2089 | * directParent -> directParentParent -> directParentParentParent ... -> root. |
||
| 2090 | * |
||
| 2091 | * @param array $classNames |
||
| 2092 | * |
||
| 2093 | * @return void |
||
| 2094 | */ |
||
| 2095 | 410 | public function setParentClasses(array $classNames) |
|
| 2103 | |||
| 2104 | /** |
||
| 2105 | * Sets the inheritance type used by the class and its subclasses. |
||
| 2106 | * |
||
| 2107 | * @param integer $type |
||
| 2108 | * |
||
| 2109 | * @return void |
||
| 2110 | * |
||
| 2111 | * @throws MappingException |
||
| 2112 | */ |
||
| 2113 | 165 | public function setInheritanceType($type) |
|
| 2121 | |||
| 2122 | /** |
||
| 2123 | * Sets the association to override association mapping of property for an entity relationship. |
||
| 2124 | * |
||
| 2125 | * @param string $fieldName |
||
| 2126 | * @param array $overrideMapping |
||
| 2127 | * |
||
| 2128 | * @return void |
||
| 2129 | * |
||
| 2130 | * @throws MappingException |
||
| 2131 | */ |
||
| 2132 | 20 | public function setAssociationOverride($fieldName, array $overrideMapping) |
|
| 2175 | |||
| 2176 | /** |
||
| 2177 | * Sets the override for a mapped field. |
||
| 2178 | * |
||
| 2179 | * @param string $fieldName |
||
| 2180 | * @param array $overrideMapping |
||
| 2181 | * |
||
| 2182 | * @return void |
||
| 2183 | * |
||
| 2184 | * @throws MappingException |
||
| 2185 | */ |
||
| 2186 | 15 | public function setAttributeOverride($fieldName, array $overrideMapping) |
|
| 2218 | |||
| 2219 | /** |
||
| 2220 | * Checks whether a mapped field is inherited from an entity superclass. |
||
| 2221 | * |
||
| 2222 | * @param string $fieldName |
||
| 2223 | * |
||
| 2224 | * @return bool TRUE if the field is inherited, FALSE otherwise. |
||
| 2225 | */ |
||
| 2226 | 369 | public function isInheritedField($fieldName) |
|
| 2230 | |||
| 2231 | /** |
||
| 2232 | * Checks if this entity is the root in any entity-inheritance-hierarchy. |
||
| 2233 | * |
||
| 2234 | * @return bool |
||
| 2235 | */ |
||
| 2236 | 409 | public function isRootEntity() |
|
| 2240 | |||
| 2241 | /** |
||
| 2242 | * Checks whether a mapped association field is inherited from a superclass. |
||
| 2243 | * |
||
| 2244 | * @param string $fieldName |
||
| 2245 | * |
||
| 2246 | * @return boolean TRUE if the field is inherited, FALSE otherwise. |
||
| 2247 | */ |
||
| 2248 | 348 | public function isInheritedAssociation($fieldName) |
|
| 2252 | |||
| 2253 | 348 | public function isInheritedEmbeddedClass($fieldName) |
|
| 2257 | |||
| 2258 | /** |
||
| 2259 | * Sets the name of the primary table the class is mapped to. |
||
| 2260 | * |
||
| 2261 | * @param string $tableName The table name. |
||
| 2262 | * |
||
| 2263 | * @return void |
||
| 2264 | * |
||
| 2265 | * @deprecated Use {@link setPrimaryTable}. |
||
| 2266 | */ |
||
| 2267 | 5 | public function setTableName($tableName) |
|
| 2271 | |||
| 2272 | /** |
||
| 2273 | * Sets the primary table definition. The provided array supports the |
||
| 2274 | * following structure: |
||
| 2275 | * |
||
| 2276 | * name => <tableName> (optional, defaults to class name) |
||
| 2277 | * indexes => array of indexes (optional) |
||
| 2278 | * uniqueConstraints => array of constraints (optional) |
||
| 2279 | * |
||
| 2280 | * If a key is omitted, the current value is kept. |
||
| 2281 | * |
||
| 2282 | * @param array $table The table description. |
||
| 2283 | * |
||
| 2284 | * @return void |
||
| 2285 | */ |
||
| 2286 | 314 | public function setPrimaryTable(array $table) |
|
| 2318 | |||
| 2319 | /** |
||
| 2320 | * Checks whether the given type identifies an inheritance type. |
||
| 2321 | * |
||
| 2322 | * @param integer $type |
||
| 2323 | * |
||
| 2324 | * @return boolean TRUE if the given type identifies an inheritance type, FALSe otherwise. |
||
| 2325 | */ |
||
| 2326 | 165 | private function _isInheritanceType($type) |
|
| 2333 | |||
| 2334 | /** |
||
| 2335 | * Adds a mapped field to the class. |
||
| 2336 | * |
||
| 2337 | * @param array $mapping The field mapping. |
||
| 2338 | * |
||
| 2339 | * @return void |
||
| 2340 | * |
||
| 2341 | * @throws MappingException |
||
| 2342 | */ |
||
| 2343 | 521 | public function mapField(array $mapping) |
|
| 2350 | |||
| 2351 | /** |
||
| 2352 | * INTERNAL: |
||
| 2353 | * Adds an association mapping without completing/validating it. |
||
| 2354 | * This is mainly used to add inherited association mappings to derived classes. |
||
| 2355 | * |
||
| 2356 | * @param array $mapping |
||
| 2357 | * |
||
| 2358 | * @return void |
||
| 2359 | * |
||
| 2360 | * @throws MappingException |
||
| 2361 | */ |
||
| 2362 | 46 | public function addInheritedAssociationMapping(array $mapping/*, $owningClassName = null*/) |
|
| 2369 | |||
| 2370 | /** |
||
| 2371 | * INTERNAL: |
||
| 2372 | * Adds a field mapping without completing/validating it. |
||
| 2373 | * This is mainly used to add inherited field mappings to derived classes. |
||
| 2374 | * |
||
| 2375 | * @param array $fieldMapping |
||
| 2376 | * |
||
| 2377 | * @return void |
||
| 2378 | */ |
||
| 2379 | 105 | public function addInheritedFieldMapping(array $fieldMapping) |
|
| 2385 | |||
| 2386 | /** |
||
| 2387 | * INTERNAL: |
||
| 2388 | * Adds a named query to this class. |
||
| 2389 | * |
||
| 2390 | * @param array $queryMapping |
||
| 2391 | * |
||
| 2392 | * @return void |
||
| 2393 | * |
||
| 2394 | * @throws MappingException |
||
| 2395 | */ |
||
| 2396 | 24 | public function addNamedQuery(array $queryMapping) |
|
| 2420 | |||
| 2421 | /** |
||
| 2422 | * INTERNAL: |
||
| 2423 | * Adds a named native query to this class. |
||
| 2424 | * |
||
| 2425 | * @param array $queryMapping |
||
| 2426 | * |
||
| 2427 | * @return void |
||
| 2428 | * |
||
| 2429 | * @throws MappingException |
||
| 2430 | */ |
||
| 2431 | 41 | public function addNamedNativeQuery(array $queryMapping) |
|
| 2464 | |||
| 2465 | /** |
||
| 2466 | * INTERNAL: |
||
| 2467 | * Adds a sql result set mapping to this class. |
||
| 2468 | * |
||
| 2469 | * @param array $resultMapping |
||
| 2470 | * |
||
| 2471 | * @return void |
||
| 2472 | * |
||
| 2473 | * @throws MappingException |
||
| 2474 | */ |
||
| 2475 | 41 | public function addSqlResultSetMapping(array $resultMapping) |
|
| 2525 | |||
| 2526 | /** |
||
| 2527 | * Adds a one-to-one mapping. |
||
| 2528 | * |
||
| 2529 | * @param array $mapping The mapping. |
||
| 2530 | * |
||
| 2531 | * @return void |
||
| 2532 | */ |
||
| 2533 | 163 | public function mapOneToOne(array $mapping) |
|
| 2541 | |||
| 2542 | /** |
||
| 2543 | * Adds a one-to-many mapping. |
||
| 2544 | * |
||
| 2545 | * @param array $mapping The mapping. |
||
| 2546 | * |
||
| 2547 | * @return void |
||
| 2548 | */ |
||
| 2549 | 121 | public function mapOneToMany(array $mapping) |
|
| 2557 | |||
| 2558 | /** |
||
| 2559 | * Adds a many-to-one mapping. |
||
| 2560 | * |
||
| 2561 | * @param array $mapping The mapping. |
||
| 2562 | * |
||
| 2563 | * @return void |
||
| 2564 | */ |
||
| 2565 | 155 | public function mapManyToOne(array $mapping) |
|
| 2574 | |||
| 2575 | /** |
||
| 2576 | * Adds a many-to-many mapping. |
||
| 2577 | * |
||
| 2578 | * @param array $mapping The mapping. |
||
| 2579 | * |
||
| 2580 | * @return void |
||
| 2581 | */ |
||
| 2582 | 143 | public function mapManyToMany(array $mapping) |
|
| 2590 | |||
| 2591 | /** |
||
| 2592 | * Stores the association mapping. |
||
| 2593 | * |
||
| 2594 | * @param array $assocMapping |
||
| 2595 | * |
||
| 2596 | * @return void |
||
| 2597 | * |
||
| 2598 | * @throws MappingException |
||
| 2599 | */ |
||
| 2600 | 325 | protected function _storeAssociationMapping(array $assocMapping) |
|
| 2608 | |||
| 2609 | /** |
||
| 2610 | * Registers a custom repository class for the entity class. |
||
| 2611 | * |
||
| 2612 | * @param string $repositoryClassName The class name of the custom mapper. |
||
| 2613 | * |
||
| 2614 | * @return void |
||
| 2615 | */ |
||
| 2616 | 62 | public function setCustomRepositoryClass($repositoryClassName) |
|
| 2620 | |||
| 2621 | /** |
||
| 2622 | * Dispatches the lifecycle event of the given entity to the registered |
||
| 2623 | * lifecycle callbacks and lifecycle listeners. |
||
| 2624 | * |
||
| 2625 | * @deprecated Deprecated since version 2.4 in favor of \Doctrine\ORM\Event\ListenersInvoker |
||
| 2626 | * |
||
| 2627 | * @param string $lifecycleEvent The lifecycle event. |
||
| 2628 | * @param object $entity The Entity on which the event occurred. |
||
| 2629 | * |
||
| 2630 | * @return void |
||
| 2631 | */ |
||
| 2632 | 1 | public function invokeLifecycleCallbacks($lifecycleEvent, $entity) |
|
| 2638 | |||
| 2639 | /** |
||
| 2640 | * Whether the class has any attached lifecycle listeners or callbacks for a lifecycle event. |
||
| 2641 | * |
||
| 2642 | * @param string $lifecycleEvent |
||
| 2643 | * |
||
| 2644 | * @return boolean |
||
| 2645 | */ |
||
| 2646 | public function hasLifecycleCallbacks($lifecycleEvent) |
||
| 2650 | |||
| 2651 | /** |
||
| 2652 | * Gets the registered lifecycle callbacks for an event. |
||
| 2653 | * |
||
| 2654 | * @param string $event |
||
| 2655 | * |
||
| 2656 | * @return array |
||
| 2657 | */ |
||
| 2658 | public function getLifecycleCallbacks($event) |
||
| 2662 | |||
| 2663 | /** |
||
| 2664 | * Adds a lifecycle callback for entities of this class. |
||
| 2665 | * |
||
| 2666 | * @param string $callback |
||
| 2667 | * @param string $event |
||
| 2668 | * |
||
| 2669 | * @return void |
||
| 2670 | */ |
||
| 2671 | 35 | public function addLifecycleCallback($callback, $event) |
|
| 2679 | |||
| 2680 | /** |
||
| 2681 | * Sets the lifecycle callbacks for entities of this class. |
||
| 2682 | * Any previously registered callbacks are overwritten. |
||
| 2683 | * |
||
| 2684 | * @param array $callbacks |
||
| 2685 | * |
||
| 2686 | * @return void |
||
| 2687 | */ |
||
| 2688 | 120 | public function setLifecycleCallbacks(array $callbacks) |
|
| 2692 | |||
| 2693 | /** |
||
| 2694 | * Adds a entity listener for entities of this class. |
||
| 2695 | * |
||
| 2696 | * @param string $eventName The entity lifecycle event. |
||
| 2697 | * @param string $class The listener class. |
||
| 2698 | * @param string $method The listener callback method. |
||
| 2699 | * |
||
| 2700 | * @throws \Doctrine\ORM\Mapping\MappingException |
||
| 2701 | */ |
||
| 2702 | 35 | public function addEntityListener($eventName, $class, $method) |
|
| 2725 | |||
| 2726 | /** |
||
| 2727 | * Sets the discriminator column definition. |
||
| 2728 | * |
||
| 2729 | * @param array $columnDef |
||
| 2730 | * |
||
| 2731 | * @return void |
||
| 2732 | * |
||
| 2733 | * @throws MappingException |
||
| 2734 | * |
||
| 2735 | * @see getDiscriminatorColumn() |
||
| 2736 | */ |
||
| 2737 | 161 | public function setDiscriminatorColumn($columnDef) |
|
| 2763 | |||
| 2764 | /** |
||
| 2765 | * Sets the discriminator values used by this class. |
||
| 2766 | * Used for JOINED and SINGLE_TABLE inheritance mapping strategies. |
||
| 2767 | * |
||
| 2768 | * @param array $map |
||
| 2769 | * |
||
| 2770 | * @return void |
||
| 2771 | */ |
||
| 2772 | 154 | public function setDiscriminatorMap(array $map) |
|
| 2778 | |||
| 2779 | /** |
||
| 2780 | * Adds one entry of the discriminator map with a new class and corresponding name. |
||
| 2781 | * |
||
| 2782 | * @param string $name |
||
| 2783 | * @param string $className |
||
| 2784 | * |
||
| 2785 | * @return void |
||
| 2786 | * |
||
| 2787 | * @throws MappingException |
||
| 2788 | */ |
||
| 2789 | 102 | public function addDiscriminatorMapClass($name, $className) |
|
| 2810 | |||
| 2811 | /** |
||
| 2812 | * Checks whether the class has a named query with the given query name. |
||
| 2813 | * |
||
| 2814 | * @param string $queryName |
||
| 2815 | * |
||
| 2816 | * @return boolean |
||
| 2817 | */ |
||
| 2818 | 1 | public function hasNamedQuery($queryName) |
|
| 2822 | |||
| 2823 | /** |
||
| 2824 | * Checks whether the class has a named native query with the given query name. |
||
| 2825 | * |
||
| 2826 | * @param string $queryName |
||
| 2827 | * |
||
| 2828 | * @return boolean |
||
| 2829 | */ |
||
| 2830 | 1 | public function hasNamedNativeQuery($queryName) |
|
| 2834 | |||
| 2835 | /** |
||
| 2836 | * Checks whether the class has a named native query with the given query name. |
||
| 2837 | * |
||
| 2838 | * @param string $name |
||
| 2839 | * |
||
| 2840 | * @return boolean |
||
| 2841 | */ |
||
| 2842 | 1 | public function hasSqlResultSetMapping($name) |
|
| 2846 | |||
| 2847 | /** |
||
| 2848 | * {@inheritDoc} |
||
| 2849 | */ |
||
| 2850 | 338 | public function hasAssociation($fieldName) |
|
| 2854 | |||
| 2855 | /** |
||
| 2856 | * {@inheritDoc} |
||
| 2857 | */ |
||
| 2858 | 1 | public function isSingleValuedAssociation($fieldName) |
|
| 2863 | |||
| 2864 | /** |
||
| 2865 | * {@inheritDoc} |
||
| 2866 | */ |
||
| 2867 | 997 | public function isCollectionValuedAssociation($fieldName) |
|
| 2872 | |||
| 2873 | /** |
||
| 2874 | * Is this an association that only has a single join column? |
||
| 2875 | * |
||
| 2876 | * @param string $fieldName |
||
| 2877 | * |
||
| 2878 | * @return bool |
||
| 2879 | */ |
||
| 2880 | 35 | public function isAssociationWithSingleJoinColumn($fieldName) |
|
| 2886 | |||
| 2887 | /** |
||
| 2888 | * Returns the single association join column (if any). |
||
| 2889 | * |
||
| 2890 | * @param string $fieldName |
||
| 2891 | * |
||
| 2892 | * @return string |
||
| 2893 | * |
||
| 2894 | * @throws MappingException |
||
| 2895 | */ |
||
| 2896 | 9 | public function getSingleAssociationJoinColumnName($fieldName) |
|
| 2904 | |||
| 2905 | /** |
||
| 2906 | * Returns the single association referenced join column name (if any). |
||
| 2907 | * |
||
| 2908 | * @param string $fieldName |
||
| 2909 | * |
||
| 2910 | * @return string |
||
| 2911 | * |
||
| 2912 | * @throws MappingException |
||
| 2913 | */ |
||
| 2914 | 9 | public function getSingleAssociationReferencedJoinColumnName($fieldName) |
|
| 2922 | |||
| 2923 | /** |
||
| 2924 | * Used to retrieve a fieldname for either field or association from a given column. |
||
| 2925 | * |
||
| 2926 | * This method is used in foreign-key as primary-key contexts. |
||
| 2927 | * |
||
| 2928 | * @param string $columnName |
||
| 2929 | * |
||
| 2930 | * @return string |
||
| 2931 | * |
||
| 2932 | * @throws MappingException |
||
| 2933 | */ |
||
| 2934 | 629 | public function getFieldForColumn($columnName) |
|
| 2950 | |||
| 2951 | /** |
||
| 2952 | * Sets the ID generator used to generate IDs for instances of this class. |
||
| 2953 | * |
||
| 2954 | * @param \Doctrine\ORM\Id\AbstractIdGenerator $generator |
||
| 2955 | * |
||
| 2956 | * @return void |
||
| 2957 | */ |
||
| 2958 | 412 | public function setIdGenerator($generator) |
|
| 2962 | |||
| 2963 | /** |
||
| 2964 | * Sets definition. |
||
| 2965 | * |
||
| 2966 | * @param array $definition |
||
| 2967 | * |
||
| 2968 | * @return void |
||
| 2969 | */ |
||
| 2970 | 12 | public function setCustomGeneratorDefinition(array $definition) |
|
| 2974 | |||
| 2975 | /** |
||
| 2976 | * Sets the definition of the sequence ID generator for this class. |
||
| 2977 | * |
||
| 2978 | * The definition must have the following structure: |
||
| 2979 | * <code> |
||
| 2980 | * array( |
||
| 2981 | * 'sequenceName' => 'name', |
||
| 2982 | * 'allocationSize' => 20, |
||
| 2983 | * 'initialValue' => 1 |
||
| 2984 | * 'quoted' => 1 |
||
| 2985 | * ) |
||
| 2986 | * </code> |
||
| 2987 | * |
||
| 2988 | * @param array $definition |
||
| 2989 | * |
||
| 2990 | * @return void |
||
| 2991 | * |
||
| 2992 | * @throws MappingException |
||
| 2993 | */ |
||
| 2994 | 17 | public function setSequenceGeneratorDefinition(array $definition) |
|
| 3007 | |||
| 3008 | /** |
||
| 3009 | * Sets the version field mapping used for versioning. Sets the default |
||
| 3010 | * value to use depending on the column type. |
||
| 3011 | * |
||
| 3012 | * @param array $mapping The version field mapping array. |
||
| 3013 | * |
||
| 3014 | * @return void |
||
| 3015 | * |
||
| 3016 | * @throws MappingException |
||
| 3017 | */ |
||
| 3018 | 19 | public function setVersionMapping(array &$mapping) |
|
| 3033 | |||
| 3034 | /** |
||
| 3035 | * Sets whether this class is to be versioned for optimistic locking. |
||
| 3036 | * |
||
| 3037 | * @param boolean $bool |
||
| 3038 | * |
||
| 3039 | * @return void |
||
| 3040 | */ |
||
| 3041 | 120 | public function setVersioned($bool) |
|
| 3045 | |||
| 3046 | /** |
||
| 3047 | * Sets the name of the field that is to be used for versioning if this class is |
||
| 3048 | * versioned for optimistic locking. |
||
| 3049 | * |
||
| 3050 | * @param string $versionField |
||
| 3051 | * |
||
| 3052 | * @return void |
||
| 3053 | */ |
||
| 3054 | 120 | public function setVersionField($versionField) |
|
| 3058 | |||
| 3059 | /** |
||
| 3060 | * Marks this class as read only, no change tracking is applied to it. |
||
| 3061 | * |
||
| 3062 | * @return void |
||
| 3063 | */ |
||
| 3064 | 3 | public function markReadOnly() |
|
| 3068 | |||
| 3069 | /** |
||
| 3070 | * {@inheritDoc} |
||
| 3071 | */ |
||
| 3072 | public function getFieldNames() |
||
| 3076 | |||
| 3077 | /** |
||
| 3078 | * {@inheritDoc} |
||
| 3079 | */ |
||
| 3080 | public function getAssociationNames() |
||
| 3084 | |||
| 3085 | /** |
||
| 3086 | * {@inheritDoc} |
||
| 3087 | * |
||
| 3088 | * @throws InvalidArgumentException |
||
| 3089 | */ |
||
| 3090 | 1 | public function getAssociationTargetClass($assocName) |
|
| 3098 | |||
| 3099 | /** |
||
| 3100 | * {@inheritDoc} |
||
| 3101 | */ |
||
| 3102 | 709 | public function getName() |
|
| 3106 | |||
| 3107 | /** |
||
| 3108 | * Gets the (possibly quoted) identifier column names for safe use in an SQL statement. |
||
| 3109 | * |
||
| 3110 | * @deprecated Deprecated since version 2.3 in favor of \Doctrine\ORM\Mapping\QuoteStrategy |
||
| 3111 | * |
||
| 3112 | * @param \Doctrine\DBAL\Platforms\AbstractPlatform $platform |
||
| 3113 | * |
||
| 3114 | * @return array |
||
| 3115 | */ |
||
| 3116 | public function getQuotedIdentifierColumnNames($platform) |
||
| 3145 | |||
| 3146 | /** |
||
| 3147 | * Gets the (possibly quoted) column name of a mapped field for safe use in an SQL statement. |
||
| 3148 | * |
||
| 3149 | * @deprecated Deprecated since version 2.3 in favor of \Doctrine\ORM\Mapping\QuoteStrategy |
||
| 3150 | * |
||
| 3151 | * @param string $field |
||
| 3152 | * @param \Doctrine\DBAL\Platforms\AbstractPlatform $platform |
||
| 3153 | * |
||
| 3154 | * @return string |
||
| 3155 | */ |
||
| 3156 | public function getQuotedColumnName($field, $platform) |
||
| 3162 | |||
| 3163 | /** |
||
| 3164 | * Gets the (possibly quoted) primary table name of this class for safe use in an SQL statement. |
||
| 3165 | * |
||
| 3166 | * @deprecated Deprecated since version 2.3 in favor of \Doctrine\ORM\Mapping\QuoteStrategy |
||
| 3167 | * |
||
| 3168 | * @param \Doctrine\DBAL\Platforms\AbstractPlatform $platform |
||
| 3169 | * |
||
| 3170 | * @return string |
||
| 3171 | */ |
||
| 3172 | public function getQuotedTableName($platform) |
||
| 3178 | |||
| 3179 | /** |
||
| 3180 | * Gets the (possibly quoted) name of the join table. |
||
| 3181 | * |
||
| 3182 | * @deprecated Deprecated since version 2.3 in favor of \Doctrine\ORM\Mapping\QuoteStrategy |
||
| 3183 | * |
||
| 3184 | * @param array $assoc |
||
| 3185 | * @param \Doctrine\DBAL\Platforms\AbstractPlatform $platform |
||
| 3186 | * |
||
| 3187 | * @return string |
||
| 3188 | */ |
||
| 3189 | public function getQuotedJoinTableName(array $assoc, $platform) |
||
| 3195 | |||
| 3196 | /** |
||
| 3197 | * {@inheritDoc} |
||
| 3198 | */ |
||
| 3199 | 6 | public function isAssociationInverseSide($fieldName) |
|
| 3204 | |||
| 3205 | /** |
||
| 3206 | * {@inheritDoc} |
||
| 3207 | */ |
||
| 3208 | public function getAssociationMappedByTargetField($fieldName) |
||
| 3212 | |||
| 3213 | /** |
||
| 3214 | * @param string $targetClass |
||
| 3215 | * |
||
| 3216 | * @return array |
||
| 3217 | */ |
||
| 3218 | 2 | public function getAssociationsByTargetClass($targetClass) |
|
| 3230 | |||
| 3231 | /** |
||
| 3232 | * @param string|null $className |
||
| 3233 | * |
||
| 3234 | * @return string|null null if the input value is null |
||
| 3235 | */ |
||
| 3236 | 461 | public function fullyQualifiedClassName($className) |
|
| 3248 | |||
| 3249 | /** |
||
| 3250 | * @param string $name |
||
| 3251 | * |
||
| 3252 | * @return mixed |
||
| 3253 | */ |
||
| 3254 | 2 | public function getMetadataValue($name) |
|
| 3263 | |||
| 3264 | /** |
||
| 3265 | * Map Embedded Class |
||
| 3266 | * |
||
| 3267 | * @param array $mapping |
||
| 3268 | * |
||
| 3269 | * @throws MappingException |
||
| 3270 | * @return void |
||
| 3271 | */ |
||
| 3272 | 27 | public function mapEmbedded(array $mapping) |
|
| 3283 | |||
| 3284 | /** |
||
| 3285 | * Inline the embeddable class |
||
| 3286 | * |
||
| 3287 | * @param string $property |
||
| 3288 | * @param ClassMetadataInfo $embeddable |
||
| 3289 | */ |
||
| 3290 | 11 | public function inlineEmbeddable($property, ClassMetadataInfo $embeddable) |
|
| 3319 | |||
| 3320 | /** |
||
| 3321 | * @param string $fieldName |
||
| 3322 | * @throws MappingException |
||
| 3323 | */ |
||
| 3324 | 556 | private function assertFieldNotMapped($fieldName) |
|
| 3333 | |||
| 3334 | /** |
||
| 3335 | * Gets the sequence name based on class metadata. |
||
| 3336 | * |
||
| 3337 | * @param AbstractPlatform $platform |
||
| 3338 | * @return string |
||
| 3339 | * |
||
| 3340 | * @todo Sequence names should be computed in DBAL depending on the platform |
||
| 3341 | */ |
||
| 3342 | 3 | public function getSequenceName(AbstractPlatform $platform) |
|
| 3350 | |||
| 3351 | /** |
||
| 3352 | * Gets the sequence name prefix based on class metadata. |
||
| 3353 | * |
||
| 3354 | * @param AbstractPlatform $platform |
||
| 3355 | * @return string |
||
| 3356 | * |
||
| 3357 | * @todo Sequence names should be computed in DBAL depending on the platform |
||
| 3358 | */ |
||
| 3359 | 3 | public function getSequencePrefix(AbstractPlatform $platform) |
|
| 3375 | |||
| 3376 | /** |
||
| 3377 | * @param array $mapping |
||
| 3378 | */ |
||
| 3379 | 198 | private function assertMappingOrderBy(array $mapping) |
|
| 3385 | } |
||
| 3386 |
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: