public function match($stub)
{
if (preg_match($this->parse_regex, $stub, $pattern_matches) > 0) {
$this->entire_match = array_shift($pattern_matches);
// The entire matched string is returned at index 0
$named_args = $this->named_args;
// Direct call shows a PHP notice
$result = true;
if (is_string($this->parameters) && ($parameters = unserialize($this->parameters)) || is_array($this->parameters) && ($parameters = $this->parameters)) {
$this->named_arg_values = array_merge($this->named_arg_values, $parameters);
}
foreach ($named_args as $keys) {
foreach ($keys as $key) {
if (!empty($pattern_matches[$key])) {
$this->named_arg_values[$key] = urldecode(str_replace('%252F', '%2F', $pattern_matches[$key]));
}
}
}
if (preg_match('/^\\{\\$(\\w+)\\}$/u', $this->action, $matches) > 0) {
$this->action = $this->named_arg_values[$matches[1]];
}
if (isset($parameters['require_match'])) {
$result = call_user_func($parameters['require_match'], $this, $stub, $parameters);
}
if ($result && isset($parameters['require_permission'])) {
foreach ($parameters['require_permission'] as $token => $access) {
$access = Utils::single_array($access);
foreach ($access as $mask) {
if (is_bool($mask) && User::identify()->can($token)) {
$result = true;
break;
} elseif (User::identify()->can($token, $mask)) {
$result = true;
break 2;
}
}
}
}
return $result;
}
return false;
}