function RulesURIInputEvaluator::evaluate
Overrides RulesDataInputEvaluator::evaluate().
Overrides RulesDataInputEvaluator::evaluate
File
-
modules/
rules_core.eval.inc, line 126
Class
- RulesURIInputEvaluator
- A class implementing a rules input evaluator processing URI inputs.
Code
public function evaluate($uri, $options, RulesState $state) {
if (!url_is_external($uri)) {
// Extract the path and build the URL using the url() function, so URL
// aliases are applied and query parameters and fragments get handled.
$url = drupal_parse_url($uri);
$url_options = array(
'absolute' => TRUE,
);
$url_options['query'] = $url['query'];
$url_options['fragment'] = $url['fragment'];
return url($url['path'], $url_options);
}
elseif (valid_url($uri)) {
return $uri;
}
throw new RulesEvaluationException('Input evaluation generated an invalid URI.', array(), NULL, RulesLog::WARN);
}