From babc1a033913f9aee1d483590eca5c0b977f5313 Mon Sep 17 00:00:00 2001 From: Ioannis Igoumenos Date: Thu, 18 Sep 2025 20:21:27 +0300 Subject: [PATCH] Move vv_bc_parent_* calculation in StandardEnrollerController --- .../AttributeCollectorsController.php | 21 ------------------- .../BasicAttributeCollectorsController.php | 21 ------------------- .../Controller/EmailVerifiersController.php | 8 ------- .../EnrollmentAttributesController.php | 8 ------- .../IdentifierCollectorsController.php | 21 ------------------- .../InvitationAcceptersController.php | 21 ------------------- .../Controller/StandardEnrollerController.php | 11 ++++++++++ 7 files changed, 11 insertions(+), 100 deletions(-) diff --git a/app/plugins/CoreEnroller/src/Controller/AttributeCollectorsController.php b/app/plugins/CoreEnroller/src/Controller/AttributeCollectorsController.php index aeb0fb6a9..e9640bd71 100644 --- a/app/plugins/CoreEnroller/src/Controller/AttributeCollectorsController.php +++ b/app/plugins/CoreEnroller/src/Controller/AttributeCollectorsController.php @@ -41,27 +41,6 @@ class AttributeCollectorsController extends StandardEnrollerController { ] ]; - /** - * Callback run prior to the request render. - * - * @param EventInterface $event Cake Event - * - * @return Response|void - * @since COmanage Registry v5.0.0 - */ - - public function beforeRender(EventInterface $event) { - $link = $this->getPrimaryLink(true); - - if(!empty($link->value)) { - $this->set('vv_bc_parent_obj', $this->AttributeCollectors->EnrollmentFlowSteps->get($link->value)); - $this->set('vv_bc_parent_displayfield', $this->AttributeCollectors->EnrollmentFlowSteps->getDisplayField()); - $this->set('vv_bc_parent_primarykey', $this->AttributeCollectors->EnrollmentFlowSteps->getPrimaryKey()); - } - - return parent::beforeRender($event); - } - /** * Dispatch an Enrollment Flow Step. * diff --git a/app/plugins/CoreEnroller/src/Controller/BasicAttributeCollectorsController.php b/app/plugins/CoreEnroller/src/Controller/BasicAttributeCollectorsController.php index be85918ad..4e3496057 100644 --- a/app/plugins/CoreEnroller/src/Controller/BasicAttributeCollectorsController.php +++ b/app/plugins/CoreEnroller/src/Controller/BasicAttributeCollectorsController.php @@ -39,27 +39,6 @@ class BasicAttributeCollectorsController extends StandardEnrollerController { ] ]; - /** - * Callback run prior to the request render. - * - * @param EventInterface $event Cake Event - * - * @return Response|void - * @since COmanage Registry v5.1.0 - */ - - public function beforeRender(\Cake\Event\EventInterface $event) { - $link = $this->getPrimaryLink(true); - - if(!empty($link->value)) { - $this->set('vv_bc_parent_obj', $this->BasicAttributeCollectors->EnrollmentFlowSteps->get($link->value)); - $this->set('vv_bc_parent_displayfield', $this->BasicAttributeCollectors->EnrollmentFlowSteps->getDisplayField()); - $this->set('vv_bc_parent_primarykey', $this->BasicAttributeCollectors->EnrollmentFlowSteps->getPrimaryKey()); - } - - return parent::beforeRender($event); - } - /** * Dispatch an Enrollment Flow Step. * diff --git a/app/plugins/CoreEnroller/src/Controller/EmailVerifiersController.php b/app/plugins/CoreEnroller/src/Controller/EmailVerifiersController.php index 2922f0c67..6e683e9f9 100644 --- a/app/plugins/CoreEnroller/src/Controller/EmailVerifiersController.php +++ b/app/plugins/CoreEnroller/src/Controller/EmailVerifiersController.php @@ -58,14 +58,6 @@ class EmailVerifiersController extends StandardEnrollerController { */ public function beforeRender(\Cake\Event\EventInterface $event) { - $link = $this->getPrimaryLink(true); - - if(!empty($link->value)) { - $this->set('vv_bc_parent_obj', $this->EmailVerifiers->EnrollmentFlowSteps->get($link->value)); - $this->set('vv_bc_parent_displayfield', $this->EmailVerifiers->EnrollmentFlowSteps->getDisplayField()); - $this->set('vv_bc_parent_primarykey', $this->EmailVerifiers->EnrollmentFlowSteps->getPrimaryKey()); - } - // We use the viewvar to determine the op since 'index' isn't always present $op = $this->viewBuilder()->getVar('vv_op'); diff --git a/app/plugins/CoreEnroller/src/Controller/EnrollmentAttributesController.php b/app/plugins/CoreEnroller/src/Controller/EnrollmentAttributesController.php index fc7198367..b86691aeb 100644 --- a/app/plugins/CoreEnroller/src/Controller/EnrollmentAttributesController.php +++ b/app/plugins/CoreEnroller/src/Controller/EnrollmentAttributesController.php @@ -51,14 +51,6 @@ class EnrollmentAttributesController extends StandardEnrollerController { public function beforeRender(\Cake\Event\EventInterface $event) { $this->set('vv_supported_attributes', $this->EnrollmentAttributes->supportedAttributes()); - $link = $this->getPrimaryLink(true); - - if(!empty($link->value)) { - $this->set('vv_bc_parent_obj', $this->EnrollmentAttributes->AttributeCollectors->get($link->value)); - $this->set('vv_bc_parent_displayfield', $this->EnrollmentAttributes->AttributeCollectors->getDisplayField()); - $this->set('vv_bc_parent_primarykey', $this->EnrollmentAttributes->AttributeCollectors->getPrimaryKey()); - } - $ret = parent::beforeRender($event); $attributes = $this->viewBuilder()->getVar('attributes'); diff --git a/app/plugins/CoreEnroller/src/Controller/IdentifierCollectorsController.php b/app/plugins/CoreEnroller/src/Controller/IdentifierCollectorsController.php index 74347f02e..0a532ecb3 100644 --- a/app/plugins/CoreEnroller/src/Controller/IdentifierCollectorsController.php +++ b/app/plugins/CoreEnroller/src/Controller/IdentifierCollectorsController.php @@ -38,27 +38,6 @@ class IdentifierCollectorsController extends StandardEnrollerController { 'IdentifierCollectors.id' => 'asc' ] ]; - - /** - * Callback run prior to the request render. - * - * @param EventInterface $event Cake Event - * - * @return Response|void - * @since COmanage Registry v5.0.0 - */ - - public function beforeRender(\Cake\Event\EventInterface $event) { - $link = $this->getPrimaryLink(true); - - if(!empty($link->value)) { - $this->set('vv_bc_parent_obj', $this->IdentifierCollectors->EnrollmentFlowSteps->get($link->value)); - $this->set('vv_bc_parent_displayfield', $this->IdentifierCollectors->EnrollmentFlowSteps->getDisplayField()); - $this->set('vv_bc_parent_primarykey', $this->IdentifierCollectors->EnrollmentFlowSteps->getPrimaryKey()); - } - - return parent::beforeRender($event); - } /** * Dispatch an Enrollment Flow Step. diff --git a/app/plugins/CoreEnroller/src/Controller/InvitationAcceptersController.php b/app/plugins/CoreEnroller/src/Controller/InvitationAcceptersController.php index 172594124..17535e9c0 100644 --- a/app/plugins/CoreEnroller/src/Controller/InvitationAcceptersController.php +++ b/app/plugins/CoreEnroller/src/Controller/InvitationAcceptersController.php @@ -39,27 +39,6 @@ class InvitationAcceptersController extends StandardEnrollerController { 'InvitationAccepters.id' => 'asc' ] ]; - - /** - * Callback run prior to the request render. - * - * @param EventInterface $event Cake Event - * - * @return Response|void - * @since COmanage Registry v5.0.0 - */ - - public function beforeRender(\Cake\Event\EventInterface $event) { - $link = $this->getPrimaryLink(true); - - if(!empty($link->value)) { - $this->set('vv_bc_parent_obj', $this->InvitationAccepters->EnrollmentFlowSteps->get($link->value)); - $this->set('vv_bc_parent_displayfield', $this->InvitationAccepters->EnrollmentFlowSteps->getDisplayField()); - $this->set('vv_bc_parent_primarykey', $this->InvitationAccepters->EnrollmentFlowSteps->getPrimaryKey()); - } - - return parent::beforeRender($event); - } /** * Dispatch an Enrollment Flow Step. diff --git a/app/src/Controller/StandardEnrollerController.php b/app/src/Controller/StandardEnrollerController.php index ea70e6982..c7f6e2124 100644 --- a/app/src/Controller/StandardEnrollerController.php +++ b/app/src/Controller/StandardEnrollerController.php @@ -70,6 +70,17 @@ public function beforeRender(\Cake\Event\EventInterface $event) { $this->set('vv_petition', null); } + $link = $this->getPrimaryLink(true); + + if(!empty($link->value)) { + $currentTable = $this->getCurrentTable(); + $efsTable = $currentTable->getAssociation('EnrollmentFlowSteps')->getTarget(); + + $this->set('vv_bc_parent_obj', $efsTable->get($link->value)); + $this->set('vv_bc_parent_displayfield', $efsTable->getDisplayField()); + $this->set('vv_bc_parent_primarykey', $efsTable->getPrimaryKey()); + } + return parent::beforeRender($event); }