Guest User

Untitled

a guest
Jun 18th, 2018
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. <?php
  2. class halo_ParameterMethodNameResolver implements halo_IMethodNameResolver {
  3.  
  4. private $paramName = 'action';
  5. private $methodParamNames;
  6.  
  7. public function setParamName($paramName) {
  8. $this->paramName = $paramName;
  9. }
  10.  
  11. public function setMethodParamNames(Array $methodParamNames) {
  12. $this->methodParamNames = $methodParamNames;
  13. }
  14.  
  15. public function getHandlerMethodName(halo_HttpRequest $request){
  16. $methodName = '';
  17. if ($this->methodParamNames !== null) {
  18. foreach ($this->methodParamNames as $variable) {
  19. if($request->getParameter($variable) !== null){
  20. $methodName = $request->getParameter($variable);
  21. break;
  22. }
  23. }
  24. }
  25.  
  26. if ($methodName === null && $this->paramName !== null) {
  27. $methodName = $request->getParameter($this->paramName);
  28. }
  29.  
  30. if ($methodName !== null && $methodName === "") {
  31. $methodName = null;
  32. }
  33.  
  34. if ($methodName === null) {
  35. if ($this->defaultMethodName !== null) {
  36. $methodName = $this->defaultMethodName;
  37. }
  38. else {
  39. throw new Exception('Handler method, not found');
  40. }
  41. }
  42. return $methodName;
  43. }
  44. }
  45. ?>
Add Comment
Please, Sign In to add comment