Skip to content

Commit

Permalink
Various fixes to Pluggable Model handling (CFM-445)
Browse files Browse the repository at this point in the history
  • Loading branch information
Benn Oshrin committed Aug 28, 2025
1 parent 06673d3 commit d739d25
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 22 deletions.
40 changes: 20 additions & 20 deletions app/src/Lib/Traits/AutoViewVarsTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
*
* @link https://www.internet2.edu/comanage COmanage Project
* @package registry
* @since COmanage Registry v5.0.0
* @since COmanage Registry v5.1.0
* @license Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
*/

Expand Down Expand Up @@ -64,14 +64,13 @@ public function setAutoViewVars($vars): void {
/**
* Calculate the AutoView Vars
*
* @param int|null $coId
* @param Object|null $obj Current object (eg: from edit), if set
*
* @since COmanage Registry v5.1.0
* @param int|null $coId
* @param Object|null $obj Current object (eg: from edit), if set
* @return \Generator
* @since COmanage Registry v5.0.0
*/
public function calculateAutoViewVars(int|null $coId, Object $obj = null): \Generator
{

public function calculateAutoViewVars(int|null $coId, Object $obj = null): \Generator {
// $table = the actual table object
$table = $this;

Expand Down Expand Up @@ -225,30 +224,31 @@ public function calculateAutoViewVars(int|null $coId, Object $obj = null): \Gene
$PluggableTable = TableRegistry::getTableLocator()->get(StringUtilities::foreignKeyToClassName($l));

if(method_exists($PluggableTable, "getPluggableModelType")) {
// This is the correct primary link. Note we don't necessarily know how to
// filter inactive records since the only column PluggableTrait requires is
// "plugin".
// This is the correct primary link.

// The entity field holding the related model
$modelKey = StringUtilities::pluginToEntityField($avv['model']);

// For now we don't filter on status because not all Pluggable models
// use it consistency. (Specifically, EISs use SyncModeEnum instead.)
// This isn't really an Application Rule, but per the documentation at
// https://spaces.at.internet2.edu/display/COmanage/Adding+a+Pluggable+Model
// we require all Pluggable Models to have a status field, and define "S" as the
// value that will remove values from this list. (The recommendation is to use "X"
// to disable but allow the value to still appear.)
$generatedValue = $PluggableTable->find('list', [
'keyField' => $modelKey.'.id',
'keyField' => 'id',
'valueField' => 'description'
])
->where(['plugin' => $avv['model']])
->contain(StringUtilities::pluginModel($avv['model']))
// We assume Pluggable tables always FK to co_id which
// is currently true but might not always be true
->where([
'plugin' => $avv['model'],
'co_id' => $coId,
'status IS NOT' => "S"
])
->all();

break;
}
}
}
break;
default:
// XXX I18n? and in match?
throw new \LogicException(__d('error', 'auto.viewvar.type.unknown', [$avv['type']]));
}

Expand Down
2 changes: 1 addition & 1 deletion app/src/Model/Table/EnrollmentFlowStepsTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public function initialize(array $config): void {
],
'plugins' => [
'type' => 'plugin',
'pluginType' => 'enroller'
'pluginType' => 'enrollment_flow_step'
],
'statuses' => [
'type' => 'enum',
Expand Down
2 changes: 1 addition & 1 deletion app/src/Model/Table/TrafficDetoursTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public function initialize(array $config): void {
$this->setAutoViewVars([
'plugins' => [
'type' => 'plugin',
'pluginType' => 'traffic'
'pluginType' => 'traffic_detour'
],
'statuses' => [
'type' => 'enum',
Expand Down

0 comments on commit d739d25

Please sign in to comment.