Skip to content

Commit

Permalink
Fix detail redirect for event argument
Browse files Browse the repository at this point in the history
  • Loading branch information
okmiim committed Dec 16, 2023
1 parent 898b4e5 commit 9ca29f7
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 25 deletions.
48 changes: 24 additions & 24 deletions Classes/Controller/CalendarController.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ public function initializeAction(): void
}

$this->modifyIndexRepository();
$this->redirectDetailWithEvent();
}

protected function modifyIndexRepository(): void
Expand All @@ -89,31 +88,28 @@ protected function modifyIndexRepository(): void
}
}

protected function redirectDetailWithEvent(): void
protected function redirectDetailWithEvent(): ?ResponseInterface
{
if ($this->request->hasArgument('event') && 'detailAction' === $this->actionMethodName) {
// default configuration
$configurationName = $this->settings['configuration'] ?? '';
// configuration overwritten by argument?
if ($this->request->hasArgument('extensionConfiguration')) {
$configurationName = $this->request->getArgument('extensionConfiguration');
}
// get the configuration
$configuration = ExtensionConfigurationUtility::get($configurationName);

$index = $this->indexRepository->findByTableAndUid(
$configuration['tableName'],
(int)$this->request->getArgument('event'),
true,
false,
1
)->getFirst();

// if there is a valid index in the event
if ($index) {
$this->redirect('detail', null, null, ['index' => $index]);
}
if (!$this->request->hasArgument('extensionConfiguration') || !$this->request->hasArgument('event')) {
return null;
}
$configuration = ExtensionConfigurationUtility::get($this->request->getArgument('extensionConfiguration'));
if (null === $configuration) {
return null;
}

$table = $configuration['tableName'];
$uid = (int)$this->request->getArgument('event');

$index = $this->indexRepository->findByTableAndUid($table, $uid, true, false, 1)->getFirst();
if (null === $index) {
$index = $this->indexRepository->findByTableAndUid($table, $uid, false, true, 1)->getFirst();
}
if ($index) {
return $this->redirect('detail', null, null, ['index' => $index]);
}

return null;
}

/**
Expand Down Expand Up @@ -520,6 +516,10 @@ public function dayAction(int $year = 0, int $month = 0, int $day = 0): Response
*/
public function detailAction(Index $index = null): ResponseInterface
{
$redirectResponse = $this->redirectDetailWithEvent();
if ($redirectResponse) {
return $redirectResponse;
}
if (null === $index) {
// handle fallback for "strange language settings"
if ($this->request->hasArgument('index')) {
Expand Down
2 changes: 1 addition & 1 deletion Classes/Utility/ExtensionConfigurationUtility.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class ExtensionConfigurationUtility
/**
* Get the given configuration value.
*/
public static function get(string $name): mixed
public static function get(string $name): ?array
{
return Register::getRegister()[$name] ?? null;
}
Expand Down

0 comments on commit 9ca29f7

Please sign in to comment.