diff --git a/app/config/schema/schema.json b/app/config/schema/schema.json index 52e689317..2a4f45b43 100644 --- a/app/config/schema/schema.json +++ b/app/config/schema/schema.json @@ -663,6 +663,19 @@ "ext_identity_sources_records_i2": { "columns": [ "external_identity_id" ] }, "ext_identity_sources_records_i3": { "columns": [ "external_identity_source_id", "source_key" ] } } + }, + + "application_states": { + "columns": { + "id": {}, + "person_id": {}, + "tag": { "type": "string", "size": 128 }, + "value": { "type": "string", "size": 256 } + }, + "indexes": { + "application_states_i1": { "columns": [ "person_id" ] } + }, + "changelog": false } }, diff --git a/app/src/Model/Entity/ApplicationState.php b/app/src/Model/Entity/ApplicationState.php new file mode 100644 index 000000000..db92f2ad9 --- /dev/null +++ b/app/src/Model/Entity/ApplicationState.php @@ -0,0 +1,40 @@ + true, + 'id' => false, + 'slug' => false, + ]; +} \ No newline at end of file diff --git a/app/src/Model/Table/ApplicationStatesTable.php b/app/src/Model/Table/ApplicationStatesTable.php new file mode 100644 index 000000000..24d260fa0 --- /dev/null +++ b/app/src/Model/Table/ApplicationStatesTable.php @@ -0,0 +1,80 @@ +addBehavior('Log'); + $this->addBehavior('Timestamp'); + + $this->setTableType(\App\Lib\Enum\TableTypeEnum::Metadata); + + // Define associations + $this->belongsTo('People'); + + $this->setDisplayField('tag'); + } + + /** + * Set validation rules. + * + * @since COmanage Registry v5.0.0 + * @param Validator $validator Validator + * @return Validator Validator + * @throws InvalidArgumentException + * @throws RecordNotFoundException + */ + + public function validationDefault(Validator $validator): Validator { + $schema = $this->getSchema(); + + $this->registerPrimaryKeyValidation($validator, $this->getPrimaryLinks()); + + $this->registerStringValidation($validator, $schema, 'tag', true); + + $this->registerStringValidation($validator, $schema, 'value', false); + + return $validator; + } +} \ No newline at end of file diff --git a/app/src/Model/Table/PeopleTable.php b/app/src/Model/Table/PeopleTable.php index 74f95c0f1..64d337900 100644 --- a/app/src/Model/Table/PeopleTable.php +++ b/app/src/Model/Table/PeopleTable.php @@ -89,6 +89,9 @@ public function initialize(array $config): void { $this->hasMany('AdHocAttributes') ->setDependent(true) ->setCascadeCallbacks(true); + $this->hasMany('ApplicationStates') + ->setDependent(true) + ->setCascadeCallbacks(true); $this->hasMany('EmailAddresses') ->setDependent(true) ->setCascadeCallbacks(true);