Skip to content

Commit

Permalink
Fix Attribute Collectors dispatch view dependency data
Browse files Browse the repository at this point in the history
  • Loading branch information
Ioannis committed Dec 15, 2024
1 parent 7be2adf commit ebb11a8
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 10 deletions.
8 changes: 7 additions & 1 deletion app/src/Controller/StandardEnrollerController.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,14 @@ class StandardEnrollerController extends StandardPluginController {
*/

public function beforeRender(\Cake\Event\EventInterface $event) {
$Petition = TableRegistry::getTableLocator()->get('Petitions');
// Make the Petition available to the view
$this->set('vv_petition', $this->petition);
$this->set(
'vv_petition',
$Petition->findById($this->petition->id)
->contain($Petition->getIndexContains())
->firstOrFail()
);

return parent::beforeRender($event);
}
Expand Down
29 changes: 20 additions & 9 deletions app/src/View/Helper/PetitionHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,29 +44,40 @@ class PetitionHelper extends Helper
// The current entity, if edit or view
protected ?object $entity = null;

protected ?object $petition = null;

public function initialize(array $config): void
{
parent::initialize($config);
$this->entity = $this->getView()->get('vv_obj');
$this->petition = $this->getView()->get('vv_petition');
$this->enrollmentAttributesTable = new EnrollmentAttributesTable();
}

/**
* Get the
*
* @param string $attribute
*
* @return array
* @since COmanage Registry v5.0.0
*/
/**
* Get the Enrollment Attribute hardcoded configuration
*
* @param string $attribute
*
* @return array
* @since COmanage Registry v5.0.0
*/
public function getSupportedEnrollmentAttribute(string $attribute): array
{
return $this->enrollmentAttributesTable->supportedAttributes()[$attribute];
}

/**
* Calculate and populate the Enrollment Attributes auto view vars
*
* @since COmanage Registry v5.0.0
*/
public function populateAutoViewVars(): void
{
foreach ($this->enrollmentAttributesTable->calculateAutoViewVars(2, $this->entity) as $vvar => $value) {
// XXX Find the co id
foreach (
$this->enrollmentAttributesTable->calculateAutoViewVars($this->petition?->enrollment_flow?->co_id,$this->entity) as $vvar => $value
) {
$this->getView()->set($vvar, $value);
}
}
Expand Down

0 comments on commit ebb11a8

Please sign in to comment.