diff --git a/app/availableplugins/ApiConnector/config/plugin.json b/app/availableplugins/ApiConnector/config/plugin.json index 9f5b08eb5..c378e0d34 100644 --- a/app/availableplugins/ApiConnector/config/plugin.json +++ b/app/availableplugins/ApiConnector/config/plugin.json @@ -22,11 +22,11 @@ "columns": { "id": {}, "api_id": {}, - "api_source_id": { "type": "integer", "foreignkey": { "table": "api_sources", "column": "id" } } + "external_identity_source_id": {} }, "indexes": { "api_source_endpoints_i1": { "columns": [ "api_id" ] }, - "api_source_endpoints_i2": { "columns": [ "api_source_id" ] } + "api_source_endpoints_i2": { "columns": [ "external_identity_source_id" ] } } }, "api_source_records": { diff --git a/app/availableplugins/ApiConnector/src/Controller/ApiSourceEndpointsController.php b/app/availableplugins/ApiConnector/src/Controller/ApiSourceEndpointsController.php index 6d4a8fe21..f9fe4da31 100644 --- a/app/availableplugins/ApiConnector/src/Controller/ApiSourceEndpointsController.php +++ b/app/availableplugins/ApiConnector/src/Controller/ApiSourceEndpointsController.php @@ -50,16 +50,17 @@ class ApiSourceEndpointsController extends StandardPluginController { public function beforeRender(\Cake\Event\EventInterface $event) { $vv_obj = $this->viewBuilder()->getVar('vv_obj'); - if(!empty($vv_obj->api_source_id)) { - $apiSource = $this->ApiSourceEndpoints->ApiSources->get( - $vv_obj->api_source_id, - contain: 'ExternalIdentitySources' - ); + if(!empty($vv_obj->external_identity_source->api_source->id)) { + // For consistency with other plugins, the data model points to the External Identity Source + // but the API points to Api Source. $this->set( 'vv_push_endpoint', Router::url( - url: '/api/apisource/' . $apiSource->id . '/v2/sorPeople/' . $apiSource->external_identity_source->sor_label, + url: '/api/apisource/' + . $vv_obj->external_identity_source->api_source->id + . '/v2/sorPeople/' + . $vv_obj->external_identity_source->sor_label, full: true ) ); diff --git a/app/availableplugins/ApiConnector/src/Model/Table/ApiSourceEndpointsTable.php b/app/availableplugins/ApiConnector/src/Model/Table/ApiSourceEndpointsTable.php index 25507f50d..bba81edc0 100644 --- a/app/availableplugins/ApiConnector/src/Model/Table/ApiSourceEndpointsTable.php +++ b/app/availableplugins/ApiConnector/src/Model/Table/ApiSourceEndpointsTable.php @@ -39,6 +39,7 @@ class ApiSourceEndpointsTable extends Table { use \App\Lib\Traits\CoLinkTrait; use \App\Lib\Traits\PermissionsTrait; use \App\Lib\Traits\PrimaryLinkTrait; + use \App\Lib\Traits\QueryModificationTrait; use \App\Lib\Traits\TableMetaTrait; use \App\Lib\Traits\ValidationTrait; @@ -58,8 +59,7 @@ public function initialize(array $config): void { $this->setTableType(\App\Lib\Enum\TableTypeEnum::Configuration); // Define associations - $this->belongsTo('ApiConnector.ApiSources'); - // $this->belongsTo('ApiUsers'); + $this->belongsTo('ExternalIdentitySources'); $this->belongsTo('Apis'); $this->setDisplayField('api_id'); @@ -68,8 +68,13 @@ public function initialize(array $config): void { $this->setRequiresCO(true); $this->setRedirectGoal('self'); + $this->setEditContains([ + 'ExternalIdentitySources' => ['ApiSources'] + ]); + + $this->setAutoViewVars([ - 'apiSources' => [ + 'externalIdentitySources' => [ 'type' => 'plugin', 'model' => 'ApiConnector.ApiSources' ] @@ -108,10 +113,10 @@ public function validationDefault(Validator $validator): Validator { ]); $validator->notEmptyString('api_id'); - $validator->add('api_source_id', [ + $validator->add('external_identity_source_id', [ 'content' => ['rule' => 'isInteger'] ]); - $validator->notEmptyString('api_source_id'); + $validator->notEmptyString('external_identity_source_id'); return $validator; } diff --git a/app/availableplugins/ApiConnector/templates/ApiSourceEndpoints/fields.inc b/app/availableplugins/ApiConnector/templates/ApiSourceEndpoints/fields.inc index 22e5178c8..8bc3c67c9 100644 --- a/app/availableplugins/ApiConnector/templates/ApiSourceEndpoints/fields.inc +++ b/app/availableplugins/ApiConnector/templates/ApiSourceEndpoints/fields.inc @@ -35,7 +35,7 @@ if($vv_action == 'edit') { print $this->element('form/listItem', [ 'arguments' => [ - 'fieldName' => 'api_source_id', + 'fieldName' => 'external_identity_source_id', ] ]); }