protected function _requestMatches($patterns)
    {
        if (empty($patterns)) {
            return false;
        }

        $request = $this->_View->request;
        $path = '/' . urldecode($request->url);
        $patterns = explode("\n", $patterns);

        foreach ($patterns as &$p) {
            $p = $this->_View->Url->build('/') . $p;
            $p = str_replace('//', '/', $p);
            $p = str_replace($request->base, '', $p);
            $p = $this->localePrefix($p);
        }

        $patterns = implode("\n", $patterns);

        // Convert path settings to a regular expression.
        // Therefore replace newlines with a logical or, /* with asterisks and "/" with the front page.
        $toReplace = [
            '/(\r\n?|\n)/', // newlines
            '/\\\\\*/', // asterisks
            '/(^|\|)\/($|\|)/' // front '/'
        ];

        $replacements = [
            '|',
            '.*',
            '\1' . preg_quote($this->_View->Url->build('/'), '/') . '\2'
        ];

        $patternsQuoted = preg_quote($patterns, '/');
        $patterns = '/^(' . preg_replace($toReplace, $replacements, $patternsQuoted) . ')$/';

        return (bool)preg_match($patterns, $path);
    }
protected function _requestMatches($patterns)
    {
        if (empty($patterns)) {
            return false;
        }

        $request = $this->_View->request;
        $path = '/' . urldecode($request->url);
        $patterns = explode("\n", $patterns);

        foreach ($patterns as &$p) {
            $p = $this->_View->Url->build('/') . $p;
            $p = str_replace('//', '/', $p);
            $p = str_replace($request->base, '', $p);
            $p = $this->localePrefix($p);
        }

        $patterns = implode("\n", $patterns);

        // Convert path settings to a regular expression.
        // Therefore replace newlines with a logical or, /* with asterisks and "/" with the front page.
        $toReplace = [
            '/(\r\n?|\n)/', // newlines
            '/\\\\\*/', // asterisks
            '/(^|\|)\/($|\|)/' // front '/'
        ];

        $replacements = [
            '|',
            '.*',
            '\1' . preg_quote($this->_View->Url->build('/'), '/') . '\2'
        ];

        $patternsQuoted = preg_quote($patterns, '/');
        $patterns = '/^(' . preg_replace($toReplace, $replacements, $patternsQuoted) . ')$/';

        return (bool)preg_match($patterns, $path);
    }
protected function _requestMatches ( $ patterns ) { if ( empty ( $ patterns ) ) { return false ; } $ request = $ this -> _View -> request ; $ path = '/' . urldecode ( $ request -> url ) ; $ patterns = explode ( "\n" , $ patterns ) ; foreach ( $ patterns as & $ p ) { $ p = $ this -> _View -> Url -> build ( '/' ) . $ p ; $ p = str_replace ( '//' , '/' , $ p ) ; $ p = str_replace ( $ request -> base , '' , $ p ) ; $ p = $ this -> localePrefix ( $ p ) ; } $ patterns = implode ( "\n" , $ patterns ) ; // Convert path settings to a regular expression. // Therefore replace newlines with a logical or, /* with asterisks and "/" with the front page. $ toReplace = [ '/(\r\n?|\n)/' , // newlines '/\\\\\*/' , // asterisks '/(^|\|)\/($|\|)/' // front '/' ] ; $ replacements = [ '|' , '.*' , '\1' . preg_quote ( $ this -> _View -> Url -> build ( '/' ) , '/' ) . '\2' ] ; $ patternsQuoted = preg_quote ( $ patterns , '/' ) ; $ patterns = '/^(' . preg_replace ( $ toReplace , $ replacements , $ patternsQuoted ) . ')$/' ; return ( bool ) preg_match ( $ patterns , $ path ) ; }
Check if current request path matches any pattern in a set of patterns.

@param string $patterns String containing a set of patterns separated by \n,
\r or \r\n
@return bool TRUE if the path matches a pattern, FALSE otherwise
Check if current request path matches any pattern in a set of patterns .