Skip to content

Commit

Permalink
Add Containable relation to PetitionsTable only if the plugin is loaded
Browse files Browse the repository at this point in the history
  • Loading branch information
Ioannis committed Feb 10, 2025
1 parent d9e98f1 commit 1137002
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions app/src/Model/Table/PetitionsTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,14 +114,20 @@ public function initialize(array $config): void {
'EnrollmentFlows',
'PetitionerPeople' => ['PrimaryName' => ['foreignKey' => 'person_id']]
]);
$this->setViewContains([

$viewContainsRelations = [
'EnrollmentFlows' => ['EnrollmentFlowSteps' => ['sort' => ['ordr' => 'ASC']]],
'EnrolleePeople' => ['PrimaryName' => ['foreignKey' => 'person_id']],
'PetitionerPeople' => ['PrimaryName' => ['foreignKey' => 'person_id']],
'PetitionHistoryRecords',
'PetitionStepResults',
'PetitionAttributes',
]);
];

// Fetch extra data if the CoreEnroller plugin is enabled.
if(\Cake\Core\Plugin::isLoaded('CoreEnroller')) {
$viewContainsRelations[] = 'PetitionAttributes';
}
$this->setViewContains($viewContainsRelations);

$this->setAutoViewVars([
'statuses' => [
Expand Down

0 comments on commit 1137002

Please sign in to comment.