From 11370029d233c5649572c5a39794d6a9285aae3c Mon Sep 17 00:00:00 2001 From: Ioannis Igoumenos Date: Mon, 10 Feb 2025 13:17:45 +0200 Subject: [PATCH] Add Containable relation to PetitionsTable only if the plugin is loaded --- app/src/Model/Table/PetitionsTable.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/app/src/Model/Table/PetitionsTable.php b/app/src/Model/Table/PetitionsTable.php index 065ab20ef..9540f2df7 100644 --- a/app/src/Model/Table/PetitionsTable.php +++ b/app/src/Model/Table/PetitionsTable.php @@ -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' => [