Controller/Component/PermitComponent.php
protected function _parse($route) {
		if (is_string($route)) {
			$this->_ensureHere();

			$url = parse_url($route);
			$_path = rtrim($url['path'], '/');
			if ($_path . '?' . Hash::get($url, 'query') === $this->_hereQuery) {
				return true;
			}

			if ($_path === $this->_here) {
				return true;
			}

			return false;
		}

		$count = count($route);
		if ($count == 0) {
			return false;
		}

		foreach ($route as $key => $value) {
			if (array_key_exists($key, $this->request->params)) {
				$values = (array)$value;
				$check = (array)$this->request->params[$key];

				$hasNullValues = (count($values) != count(array_filter($values)) || count($values) == 0);
				$currentValueIsNullish = (in_array(null, $check) || in_array('', $check) || count($check) == 0);
				if ($hasNullValues && $currentValueIsNullish) {
					$count--;
					continue;
				}

				if (in_array($key, array('controller', 'plugin'))) {
					foreach ($check as $k => $_check) {
						$check[$k] = Inflector::underscore(strtolower($_check));
					}
				} else {
					foreach ($check as $k => $_check) {
						$check[$k] = strtolower($_check);
					}
				}

				if (count($values) > 0) {
					foreach ($values as $k => $v) {
						if (in_array(strtolower($v), $check)) {
							$count--;
							break;
						}
					}
				} elseif (count($check) === 0) {
					$count--;
				}
			} elseif (is_numeric($key) && isset($this->request->params['pass'])) {
				if (is_array($this->request->params['pass'])) {
					if (Hash::contains($this->request->params['pass'], $value)) {
						$count--;
					}
				}
			}
		}

		return ($count == 0);
	}
protected function _parse($route) {
		if (is_string($route)) {
			$this->_ensureHere();

			$url = parse_url($route);
			$_path = rtrim($url['path'], '/');
			if ($_path . '?' . Hash::get($url, 'query') === $this->_hereQuery) {
				return true;
			}

			if ($_path === $this->_here) {
				return true;
			}

			return false;
		}

		$count = count($route);
		if ($count == 0) {
			return false;
		}

		foreach ($route as $key => $value) {
			if (array_key_exists($key, $this->request->params)) {
				$values = (array)$value;
				$check = (array)$this->request->params[$key];

				$hasNullValues = (count($values) != count(array_filter($values)) || count($values) == 0);
				$currentValueIsNullish = (in_array(null, $check) || in_array('', $check) || count($check) == 0);
				if ($hasNullValues && $currentValueIsNullish) {
					$count--;
					continue;
				}

				if (in_array($key, array('controller', 'plugin'))) {
					foreach ($check as $k => $_check) {
						$check[$k] = Inflector::underscore(strtolower($_check));
					}
				} else {
					foreach ($check as $k => $_check) {
						$check[$k] = strtolower($_check);
					}
				}

				if (count($values) > 0) {
					foreach ($values as $k => $v) {
						if (in_array(strtolower($v), $check)) {
							$count--;
							break;
						}
					}
				} elseif (count($check) === 0) {
					$count--;
				}
			} elseif (is_numeric($key) && isset($this->request->params['pass'])) {
				if (is_array($this->request->params['pass'])) {
					if (Hash::contains($this->request->params['pass'], $value)) {
						$count--;
					}
				}
			}
		}

		return ($count == 0);
	}
protected function _parse ( $ route ) { if ( is_string ( $ route ) ) { $ this -> _ensureHere ( ) ; $ url = parse_url ( $ route ) ; $ _path = rtrim ( $ url [ 'path' ] , '/' ) ; if ( $ _path . '?' . Hash :: get ( $ url , 'query' ) === $ this -> _hereQuery ) { return true ; } if ( $ _path === $ this -> _here ) { return true ; } return false ; } $ count = count ( $ route ) ; if ( $ count == 0 ) { return false ; } foreach ( $ route as $ key => $ value ) { if ( array_key_exists ( $ key , $ this -> request -> params ) ) { $ values = ( array ) $ value ; $ check = ( array ) $ this -> request -> params [ $ key ] ; $ hasNullValues = ( count ( $ values ) != count ( array_filter ( $ values ) ) || count ( $ values ) == 0 ) ; $ currentValueIsNullish = ( in_array ( null , $ check ) || in_array ( '' , $ check ) || count ( $ check ) == 0 ) ; if ( $ hasNullValues && $ currentValueIsNullish ) { $ count -- ; continue ; } if ( in_array ( $ key , array ( 'controller' , 'plugin' ) ) ) { foreach ( $ check as $ k => $ _check ) { $ check [ $ k ] = Inflector :: underscore ( strtolower ( $ _check ) ) ; } } else { foreach ( $ check as $ k => $ _check ) { $ check [ $ k ] = strtolower ( $ _check ) ; } } if ( count ( $ values ) > 0 ) { foreach ( $ values as $ k => $ v ) { if ( in_array ( strtolower ( $ v ) , $ check ) ) { $ count -- ; break ; } } } elseif ( count ( $ check ) === 0 ) { $ count -- ; } } elseif ( is_numeric ( $ key ) && isset ( $ this -> request -> params [ 'pass' ] ) ) { if ( is_array ( $ this -> request -> params [ 'pass' ] ) ) { if ( Hash :: contains ( $ this -> request -> params [ 'pass' ] , $ value ) ) { $ count -- ; } } } } return ( $ count == 0 ) ; }
Parses a given Permit route to see if it matches the current request

@param array $route A Permit Route
@return bool true if current request matches Permit route, false otherwise
Parses a given Permit route to see if it matches the current request