From d01624b8aa825132927c01bc80a3dbc72cfec9ba Mon Sep 17 00:00:00 2001 From: Dave Mc Nicoll Date: Fri, 14 Jul 2023 19:57:29 -0400 Subject: [PATCH] - WIP on relations, constrains and foreign keys --- src/Attribute/ConstrainActionEnum.php | 14 +++++++++++++ src/Attribute/IndexTypeEnum.php | 16 ++++++++++++++ src/Attribute/Obj/Constrain.php | 23 +++++++++++++++++++++ src/Attribute/Obj/Index.php | 14 +++++++++++++ src/Attribute/Property/Field/ForeignKey.php | 21 +++++-------------- src/Attribute/Property/Index.php | 17 ++++----------- src/Attribute/Property/Unique.php | 13 ++++++++++++ src/EntityCollection.php | 2 +- 8 files changed, 90 insertions(+), 30 deletions(-) create mode 100644 src/Attribute/ConstrainActionEnum.php create mode 100644 src/Attribute/IndexTypeEnum.php create mode 100644 src/Attribute/Obj/Constrain.php create mode 100644 src/Attribute/Obj/Index.php create mode 100644 src/Attribute/Property/Unique.php diff --git a/src/Attribute/ConstrainActionEnum.php b/src/Attribute/ConstrainActionEnum.php new file mode 100644 index 0000000..e4c58f8 --- /dev/null +++ b/src/Attribute/ConstrainActionEnum.php @@ -0,0 +1,14 @@ +foreignKey = Attribute::handleArrayField($this->foreignKey, false); + $this->references = Attribute::handleArrayField($this->references, false); + } +} diff --git a/src/Attribute/Obj/Index.php b/src/Attribute/Obj/Index.php new file mode 100644 index 0000000..4cd773f --- /dev/null +++ b/src/Attribute/Obj/Index.php @@ -0,0 +1,14 @@ +references = Attribute::handleArrayField($this->references, false); + #$this->references = Attribute::handleArrayField($this->references, false); } } diff --git a/src/Attribute/Property/Index.php b/src/Attribute/Property/Index.php index 70e6311..0d0fae9 100644 --- a/src/Attribute/Property/Index.php +++ b/src/Attribute/Property/Index.php @@ -2,20 +2,11 @@ namespace Ulmus\Attribute\Property; +use Ulmus\Attribute\IndexTypeEnum; + #[\Attribute(\Attribute::TARGET_PROPERTY)] class Index { - - public const TYPE_PRIMARY = 'primary'; - - public const TYPE_INDEX = 'index'; - - public const TYPE_UNIQUE = 'unique'; - - public const TYPE_SPATIAL = 'spatial'; - - public const TYPE_FULLTEXT = 'fulltext'; - public function __construct( - public string $type = self::TYPE_INDEX, + public IndexTypeEnum $type = IndexTypeEnum::Index, ) {} -} +} \ No newline at end of file diff --git a/src/Attribute/Property/Unique.php b/src/Attribute/Property/Unique.php new file mode 100644 index 0000000..0889633 --- /dev/null +++ b/src/Attribute/Property/Unique.php @@ -0,0 +1,13 @@ +entityClass = $entityClass;