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 Doctrine\Common\Annotations\Annotation\Enum; |
||
9 | use JetBrains\PhpStorm\ExpectedValues; |
||
10 | use Spiral\Attributes\NamedArgumentConstructor; |
||
11 | |||
12 | /** |
||
13 | * @Annotation |
||
14 | * @NamedArgumentConstructor |
||
15 | * @Target("PROPERTY") |
||
16 | */ |
||
17 | #[\Attribute(\Attribute::TARGET_PROPERTY), NamedArgumentConstructor] |
||
18 | final class RefersTo extends Relation |
||
19 | { |
||
20 | use InverseTrait; |
||
21 | |||
22 | protected const TYPE = 'refersTo'; |
||
23 | |||
24 | /** |
||
25 | * @param non-empty-string $target |
||
0 ignored issues
–
show
Documentation
Bug
introduced
by
![]() |
|||
26 | * @param bool $cascade Automatically save related data with parent entity. |
||
27 | * @param bool $nullable Defines if the relation can be nullable (child can have no parent). |
||
28 | * @param array|non-empty-string|null $innerKey Inner key in parent entity. |
||
29 | * @param array|non-empty-string|null $outerKey Outer key name. Defaults to {parentRole}_{innerKey}. |
||
30 | * @param bool $fkCreate Set to true to automatically create FK on outerKey. |
||
31 | * @param non-empty-string|null $fkAction FK onDelete and onUpdate action. |
||
32 | * @param non-empty-string|null $fkOnDelete FK onDelete action. It has higher priority than {@see $fkAction}. |
||
33 | * Defaults to {@see $fkAction}. |
||
34 | * @param bool $indexCreate Create an index on outerKey. |
||
35 | * @param non-empty-string $load Relation load approach. |
||
36 | */ |
||
37 | 520 | public function __construct( |
|
38 | string $target, |
||
39 | protected bool $cascade = true, |
||
40 | protected bool $nullable = false, |
||
41 | protected array|string|null $innerKey = null, |
||
42 | protected array|string|null $outerKey = null, |
||
43 | protected bool $fkCreate = true, |
||
44 | /** |
||
45 | * @Enum({"NO ACTION", "CASCADE", "SET NULL"}) |
||
46 | */ |
||
47 | #[ExpectedValues(values: ['NO ACTION', 'CASCADE', 'SET NULL'])] |
||
48 | protected ?string $fkAction = 'CASCADE', |
||
49 | /** |
||
50 | * @Enum({"NO ACTION", "CASCADE", "SET NULL"}) |
||
51 | */ |
||
52 | #[ExpectedValues(values: ['NO ACTION', 'CASCADE', 'SET NULL'])] |
||
53 | protected ?string $fkOnDelete = null, |
||
54 | protected bool $indexCreate = true, |
||
55 | #[ExpectedValues(values: ['lazy', 'eager'])] |
||
56 | string $load = 'lazy', |
||
57 | ?Inverse $inverse = null |
||
58 | ) { |
||
59 | 520 | $this->inverse = $inverse; |
|
60 | 520 | parent::__construct($target, $load); |
|
61 | 520 | } |
|
62 | } |
||
63 |