Skip to content

Commit

Permalink
Move vv_bc_parent_* calculation in StandardEnrollerController
Browse files Browse the repository at this point in the history
  • Loading branch information
Ioannis committed Sep 18, 2025
1 parent 3a7a27e commit babc1a0
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 100 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
11 changes: 11 additions & 0 deletions app/src/Controller/StandardEnrollerController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down

0 comments on commit babc1a0

Please sign in to comment.