/** * @param string $actionCommand Action to invoke (lower-hyphenated format, ie. action-command) * @return View */ public final function invokeAction($actionCommand) { // Convert the action name to the format used for class method names // (ie. ActionName) $actionMethodName = Inflector::actionCommand_actionMethod($actionCommand); // Disregard this invocation if the $actionMethodName is listed in the // $allPrivateMethods array if (in_array($actionMethodName, $this->allPrivateMethods)) { return $this->unknown($this->params, $actionMethodName); } // Invoke the method (ensuring it's "public"), or the 'unknown' method // if it doesn't exist if (method_exists($this, $actionMethodName)) { $r = new ReflectionClass($this); $m = $r->getMethod($actionMethodName); if (!$m->isPublic() || $m->getName() !== $actionMethodName) { SystemLog::add(['Attempting to call a non-public action method: %s', $actionMethodName], SystemLog::FATAL); return new View(); } else { return $this->{$actionMethodName}($this->params); } } else { return $this->unknown($this->params, $actionCommand); } }