diff --git a/civiremote_funding.module b/civiremote_funding.module index 509c629..d96eb05 100644 --- a/civiremote_funding.module +++ b/civiremote_funding.module @@ -42,6 +42,9 @@ function civiremote_funding_views_plugins_field_alter(array &$plugins): void { $plugins['numeric']['class'] = LanguageAwareNumericField::class; } +/** + * Implements hook_views_pre_build(). + */ function civiremote_funding_views_pre_build(ViewExecutable $view): void { if (!in_array($view->id(), ['civiremote_funding_application_list', 'civiremote_funding_combined_application_process_list'], TRUE)) { return; diff --git a/src/Views/ApplicationProcessDropButton.php b/src/Views/ApplicationProcessDropButton.php index 7a6e5b7..6b9d23b 100644 --- a/src/Views/ApplicationProcessDropButton.php +++ b/src/Views/ApplicationProcessDropButton.php @@ -32,12 +32,15 @@ */ final class ApplicationProcessDropButton extends Dropbutton { + private Dropbutton $dropbutton; + private FundingApi $fundingApi; private ?int $applicationProcessId = NULL; public function __construct(FundingApi $fundingApi, Dropbutton $dropbutton) { $this->fundingApi = $fundingApi; + $this->dropbutton = $dropbutton; parent::__construct($dropbutton->configuration, $dropbutton->getPluginId(), $dropbutton->getPluginDefinition()); // @phpstan-ignore-next-line if (NULL !== $dropbutton->view) { @@ -49,6 +52,8 @@ public function __construct(FundingApi $fundingApi, Dropbutton $dropbutton) { * {@inheritDoc} */ public function render(ResultRow $values) { + $this->applicationProcessId = NULL; + // @phpstan-ignore-next-line foreach ($values as $key => $value) { if (str_ends_with($key, '_application_process_id')) { @@ -58,12 +63,11 @@ public function render(ResultRow $values) { } } - try { - return parent::render($values); - } - finally { - $this->applicationProcessId = NULL; + if (get_class($this->dropbutton) !== Dropbutton::class) { + $this->dropbutton->render($values); } + + return parent::render($values); } /** @@ -74,7 +78,7 @@ public function render(ResultRow $values) { * @throws \Drupal\civiremote_funding\Api\Exception\ApiCallFailedException */ protected function getLinks(): array { - $links = parent::getLinks(); + $links = $this->dropbutton->getLinks(); if (NULL === $this->applicationProcessId) { // Should not happen. return $links;