cycle /
annotated
| 1 | <?php |
||
| 2 | |||
| 3 | declare(strict_types=1); |
||
| 4 | |||
| 5 | namespace Cycle\Annotated\Annotation\Relation; |
||
| 6 | |||
| 7 | use Cycle\Annotated\Annotation\Relation\Traits\InverseTrait; |
||
| 8 | use JetBrains\PhpStorm\ExpectedValues; |
||
| 9 | use Spiral\Attributes\NamedArgumentConstructor; |
||
| 10 | |||
| 11 | /** |
||
| 12 | * @Annotation |
||
| 13 | * @NamedArgumentConstructor |
||
| 14 | * @Target("PROPERTY") |
||
| 15 | */ |
||
| 16 | #[\Attribute(\Attribute::TARGET_PROPERTY), NamedArgumentConstructor] |
||
| 17 | final class HasMany extends Relation |
||
| 18 | { |
||
| 19 | use InverseTrait; |
||
| 20 | |||
| 21 | protected const TYPE = 'hasMany'; |
||
| 22 | |||
| 23 | /** |
||
| 24 | * @param non-empty-string $target |
||
|
0 ignored issues
–
show
Documentation
Bug
introduced
by
Loading history...
|
|||
| 25 | * @param array|non-empty-string|null $innerKey Inner key in parent entity. Defaults to the primary key. |
||
| 26 | * @param array|non-empty-string|null $outerKey Outer key name. Defaults to {parentRole}_{innerKey}. |
||
| 27 | * @param bool $cascade Automatically save related data with parent entity. |
||
| 28 | * @param bool $nullable Defines if the relation can be nullable (child can have no parent). |
||
| 29 | * @param array $where Additional where condition to be applied for the relation. |
||
| 30 | * @param array $orderBy Additional sorting rules. |
||
| 31 | * @param bool $fkCreate Set to true to automatically create FK on outerKey. |
||
| 32 | * @param non-empty-string|null $fkAction FK onDelete and onUpdate action. |
||
| 33 | * @param non-empty-string|null $fkOnDelete FK onDelete action. It has higher priority than {@see $fkAction}. |
||
| 34 | * Defaults to {@see $fkAction}. |
||
| 35 | * @param bool $indexCreate Create an index on outerKey. |
||
| 36 | * @param non-empty-string|null $collection Collection that will contain loaded entities. |
||
| 37 | * @param non-empty-string $load Relation load approach. |
||
| 38 | */ |
||
| 39 | 544 | public function __construct( |
|
| 40 | string $target, |
||
| 41 | protected array|string|null $innerKey = null, |
||
| 42 | protected array|string|null $outerKey = null, |
||
| 43 | protected bool $cascade = true, |
||
| 44 | protected bool $nullable = false, |
||
| 45 | protected array $where = [], |
||
| 46 | protected array $orderBy = [], |
||
| 47 | protected bool $fkCreate = true, |
||
| 48 | /** |
||
| 49 | * @Enum({"NO ACTION", "CASCADE", "SET NULL"}) |
||
| 50 | */ |
||
| 51 | #[ExpectedValues(values: ['NO ACTION', 'CASCADE', 'SET NULL'])] |
||
| 52 | protected ?string $fkAction = 'CASCADE', |
||
| 53 | /** |
||
| 54 | * @Enum({"NO ACTION", "CASCADE", "SET NULL"}) |
||
| 55 | */ |
||
| 56 | #[ExpectedValues(values: ['NO ACTION', 'CASCADE', 'SET NULL'])] |
||
| 57 | protected ?string $fkOnDelete = null, |
||
| 58 | protected bool $indexCreate = true, |
||
| 59 | protected ?string $collection = null, |
||
| 60 | #[ExpectedValues(values: ['lazy', 'eager'])] |
||
| 61 | string $load = 'lazy', |
||
| 62 | ?Inverse $inverse = null, |
||
| 63 | ) { |
||
| 64 | 544 | $this->inverse = $inverse; |
|
| 65 | |||
| 66 | 544 | parent::__construct($target, $load); |
|
| 67 | 544 | } |
|
| 68 | } |
||
| 69 |