@@ 388-409 (lines=22) @@ | ||
385 | * |
|
386 | * @SuppressWarnings(PHPMD.BooleanArgumentFlag) |
|
387 | */ |
|
388 | protected function foreignRelationship( |
|
389 | string $column, |
|
390 | string $referredClass, |
|
391 | bool $cascadeDelete = false |
|
392 | ): Closure { |
|
393 | return function ( |
|
394 | Table $table, |
|
395 | MigrationContextInterface $context |
|
396 | ) use ( |
|
397 | $column, |
|
398 | $referredClass, |
|
399 | $cascadeDelete |
|
400 | ) { |
|
401 | $tableName = $this->getTableNameForClass($referredClass); |
|
402 | $pkName = $this->getModelSchemas()->getPrimaryKey($referredClass); |
|
403 | $columnType = $this->getModelSchemas()->getAttributeType($context->getModelClass(), $column); |
|
404 | ||
405 | $closure = $this->foreignColumn($column, $tableName, $pkName, $columnType, $cascadeDelete); |
|
406 | ||
407 | return $closure($table, $context); |
|
408 | }; |
|
409 | } |
|
410 | ||
411 | /** |
|
412 | * @param string $column |
|
@@ 420-441 (lines=22) @@ | ||
417 | * |
|
418 | * @SuppressWarnings(PHPMD.BooleanArgumentFlag) |
|
419 | */ |
|
420 | protected function nullableForeignRelationship( |
|
421 | string $column, |
|
422 | string $referredClass, |
|
423 | bool $cascadeDelete = false |
|
424 | ): Closure { |
|
425 | return function ( |
|
426 | Table $table, |
|
427 | MigrationContextInterface $context |
|
428 | ) use ( |
|
429 | $column, |
|
430 | $referredClass, |
|
431 | $cascadeDelete |
|
432 | ) { |
|
433 | $tableName = $this->getTableNameForClass($referredClass); |
|
434 | $pkName = $this->getModelSchemas()->getPrimaryKey($referredClass); |
|
435 | $columnType = $this->getModelSchemas()->getAttributeType($context->getModelClass(), $column); |
|
436 | ||
437 | $closure = $this->nullableForeignColumn($column, $tableName, $pkName, $columnType, $cascadeDelete); |
|
438 | ||
439 | return $closure($table, $context); |
|
440 | }; |
|
441 | } |
|
442 | ||
443 | /** |
|
444 | * @param string $localKey |