Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class halo_PropertiesMethodNameResolver implements halo_IMethodNameResolver {
- private $mappings;
- private $pathMatcher;
- public function __construct() {
- $this->pathMatcher = new halo_AntPathMatcher();
- }
- public function setMappings(Array $mappings) {
- $this->mappings = $mappings;
- }
- /**
- * Set the PathMatcher implementation to use for matching URL paths
- * against registered URL patterns. Default is halo_AntPathMatcher.
- * @see halo_AntPathMatcher
- */
- public function setPathMatcher(halo_IPathMatcher $pathMatcher) {
- $this->pathMatcher = $pathMatcher;
- }
- public function getHandlerMethodName(halo_HttpRequest $request){
- $urlPath = $request->getRequestedUrl();
- if(array_key_exists($urlPath, $this->mappings)){
- return $this->mappings[$urlPath];
- }
- foreach ($this->mappings as $key => $value) {
- if ($this->pathMatcher->match($key, $urlPath)) {
- return $value;
- }
- }
- return null;
- }
- }
- ?>
Add Comment
Please, Sign In to add comment