diff options
Diffstat (limited to 'vendor/doctrine/orm/src/Mapping/AssociationOverrides.php')
| -rw-r--r-- | vendor/doctrine/orm/src/Mapping/AssociationOverrides.php | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/vendor/doctrine/orm/src/Mapping/AssociationOverrides.php b/vendor/doctrine/orm/src/Mapping/AssociationOverrides.php new file mode 100644 index 0000000..9fc6807 --- /dev/null +++ b/vendor/doctrine/orm/src/Mapping/AssociationOverrides.php | |||
| @@ -0,0 +1,38 @@ | |||
| 1 | <?php | ||
| 2 | |||
| 3 | declare(strict_types=1); | ||
| 4 | |||
| 5 | namespace Doctrine\ORM\Mapping; | ||
| 6 | |||
| 7 | use Attribute; | ||
| 8 | |||
| 9 | use function array_values; | ||
| 10 | use function is_array; | ||
| 11 | |||
| 12 | /** This attribute is used to override association mappings of relationship properties. */ | ||
| 13 | #[Attribute(Attribute::TARGET_CLASS)] | ||
| 14 | final class AssociationOverrides implements MappingAttribute | ||
| 15 | { | ||
| 16 | /** | ||
| 17 | * Mapping overrides of relationship properties. | ||
| 18 | * | ||
| 19 | * @var list<AssociationOverride> | ||
| 20 | */ | ||
| 21 | public readonly array $overrides; | ||
| 22 | |||
| 23 | /** @param array<AssociationOverride>|AssociationOverride $overrides */ | ||
| 24 | public function __construct(array|AssociationOverride $overrides) | ||
| 25 | { | ||
| 26 | if (! is_array($overrides)) { | ||
| 27 | $overrides = [$overrides]; | ||
| 28 | } | ||
| 29 | |||
| 30 | foreach ($overrides as $override) { | ||
| 31 | if (! ($override instanceof AssociationOverride)) { | ||
| 32 | throw MappingException::invalidOverrideType('AssociationOverride', $override); | ||
| 33 | } | ||
| 34 | } | ||
| 35 | |||
| 36 | $this->overrides = array_values($overrides); | ||
| 37 | } | ||
| 38 | } | ||
