Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 14 additions & 7 deletions app/src/Lib/Traits/TableMetaTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,12 @@ public function bindPluginRelations() {
$activeModels = $Plugins->getActivePluginModels('all');

foreach(array_keys($activeModels) as $entryPointModelName) {
$PluginTable = TableRegistry::getTableLocator()->get($entryPointModelName);
// Not all Entry Point Models are Tables (eg: Jobs), so make sure we don't get an Auto-Table.
if(!\Cake\Core\App::className($entryPointModelName, 'Model/Table', 'Table')) {
continue;
}

// Not all Entry Point Models are Tables (eg: Jobs).
$PluginTable = TableRegistry::getTableLocator()->get($entryPointModelName);

if(method_exists($PluginTable, 'getHasManyPluginRelations')) {
$pluginRelations = $PluginTable->getHasManyPluginRelations($tableName);
Expand Down Expand Up @@ -487,22 +490,26 @@ public function getHasManyPluginRelations(string $modelName): array {
/**
* Obtain the set of related models to relink to the archive copy of the
* parent record when saving (via ChangelogBehavior).
*
*
* @since COmanage Registry v5.3.0
* @return array Array of relations, in standard Cake notation
*/

public function getRelinkToArchive(): array {
return $this->relinkToArchive;
}

/**
* Declaration by Plugin Models of hasMany relations from the perspective of the Core model.
* This is intended to allow Core models to figure out which plugins have created relations
* for them. Tho configuration array is keyed on the Core model and contains a list of
* arrays of dependency informatian. See
* arrays of dependency information. See
* https://spaces.at.internet2.edu/spaces/COmanage/pages/250251876/Writing+Registry+PE+Plugins#WritingRegistryPEPlugins-PluginModelstoCoreModels
*
* Note: Core models that use PluggableModelTrait automatically create hasOne relationships
* to matching plugin entry point models. Do not include them in this configuration to
* avoid duplicate association alias exceptions.
*
* @since COmanage Registry v5.3.0
* @param array $config Array of relation configurations
*/
Expand Down Expand Up @@ -587,15 +594,15 @@ public function mapForeignKey(
/**
* Set the related models that will be relinked to the archived parent record
* when saving (via ChangelogBehavior).
*
*
* @since COmanage Registry v5.3.0
* @param array $relations Array of relations, in standard Cake notation
*/

public function relinkToArchive(array $relations) {
$this->relinkToArchive = $relations;
}

/**
* Set the type of this Table.
*
Expand Down