Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class halo_ParameterMethodNameResolver implements halo_IMethodNameResolver {
- private $paramName = 'action';
- private $methodParamNames;
- public function setParamName($paramName) {
- $this->paramName = $paramName;
- }
- public function setMethodParamNames(Array $methodParamNames) {
- $this->methodParamNames = $methodParamNames;
- }
- public function getHandlerMethodName(halo_HttpRequest $request){
- $methodName = '';
- if ($this->methodParamNames !== null) {
- foreach ($this->methodParamNames as $variable) {
- if($request->getParameter($variable) !== null){
- $methodName = $request->getParameter($variable);
- break;
- }
- }
- }
- if ($methodName === null && $this->paramName !== null) {
- $methodName = $request->getParameter($this->paramName);
- }
- if ($methodName !== null && $methodName === "") {
- $methodName = null;
- }
- if ($methodName === null) {
- if ($this->defaultMethodName !== null) {
- $methodName = $this->defaultMethodName;
- }
- else {
- throw new Exception('Handler method, not found');
- }
- }
- return $methodName;
- }
- }
- ?>
Add Comment
Please, Sign In to add comment