mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-23 02:28:44 +02:00
Fixed regression due to forcing camel case names in operation methods, now allow both camel case and snake case
This commit is contained in:
@@ -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"
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user