Fixed regression due to forcing camel case names in operation methods, now allow both camel case and snake case

This commit is contained in:
Eric Espie
2023-05-05 14:55:45 +02:00
parent b9cfb62d1a
commit f1d1aa8833

View File

@@ -204,15 +204,16 @@ abstract class Controller extends AbstractController
$this->CheckAccess();
$this->m_sOperation = utils::ReadParam('operation', $this->m_sDefaultOperation);
$sMethodName = 'Operation'.utils::ToCamelCase($this->m_sOperation);
if (method_exists($this, $sMethodName))
{
$this->$sMethodName();
if ($this->CallOperation(utils::ToCamelCase($this->m_sOperation))) {
return;
}
else
{
$this->DisplayPageNotFound();
// Fallback to unchanged names for compatibility
if ($this->CallOperation($this->m_sOperation)) {
return;
}
$this->DisplayPageNotFound();
}
catch (Exception $e)
{
@@ -222,6 +223,17 @@ abstract class Controller extends AbstractController
}
}
private function CallOperation($sOperation): bool
{
$sMethodName = 'Operation'.$sOperation;
if (!method_exists($this, $sMethodName)) {
return false;
}
$this->$sMethodName();
return true;
}
/**
* Overridable "page not found" which is more an "operation not found"
*/