class RulesURIInputEvaluator in Rules 7.2
A class implementing a rules input evaluator processing URI inputs.
Makes sure URIs are absolute and path aliases get applied.
Hierarchy
- class \RulesDataProcessor
- class \RulesDataInputEvaluator
- class \RulesURIInputEvaluator
- class \RulesDataInputEvaluator
Expanded class hierarchy of RulesURIInputEvaluator
Related topics
1 string reference to 'RulesURIInputEvaluator'
- rules_rules_core_evaluator_info in modules/
rules_core.rules.inc - Implements hook_rules_evaluator_info() on behalf of the pseudo rules_core module.
File
- modules/
rules_core.eval.inc, line 109 - Contains rules core integration needed during evaluation.
View source
class RulesURIInputEvaluator extends RulesDataInputEvaluator {
/**
* Overrides RulesDataInputEvaluator::prepare().
*/
public function prepare($uri, $var_info) {
if (!isset($this->processor) && valid_url($uri, TRUE)) {
// Only process if another evaluator is used or the url is not absolute.
$this->setting = NULL;
}
}
/**
* Overrides RulesDataInputEvaluator::evaluate().
*/
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);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
RulesDataInputEvaluator:: |
public static | function |
Overrides RulesDataProcessor::attachForm(). Overrides RulesDataProcessor:: |
|
RulesDataInputEvaluator:: |
public static | function | Returns all input evaluators that can be applied to the parameters type. | |
RulesDataInputEvaluator:: |
protected | function | Generates the evaluator $options. | |
RulesDataInputEvaluator:: |
protected | function |
Return $this or skip this processor by returning the next processor. Overrides RulesDataProcessor:: |
|
RulesDataInputEvaluator:: |
public static | function | Provide some usage help for the evaluator. | 3 |
RulesDataInputEvaluator:: |
public static | function |
Overridden to prepare input evaluator processors. Overrides RulesDataProcessor:: |
|
RulesDataInputEvaluator:: |
public | function |
Overridden to generate evaluator $options and invoke evaluate(). Overrides RulesDataProcessor:: |
1 |
RulesDataInputEvaluator:: |
public static | function |
Overrides RulesDataProcessor::processors(). Overrides RulesDataProcessor:: |
|
RulesDataInputEvaluator:: |
protected | function |
Overridden to invoke prepare(). Overrides RulesDataProcessor:: |
|
RulesDataProcessor:: |
protected | property | Allows chaining processors. If set, the next processor to invoke. | |
RulesDataProcessor:: |
protected | property | The processors' setting value. | |
RulesDataProcessor:: |
public static | function | Return whether the current user has permission to use the processor. | 1 |
RulesDataProcessor:: |
public | function | Returns an array of modules which we depend on. | |
RulesDataProcessor:: |
public | function | Determines whether the current user has permission to edit this chain of data processors. | 2 |
RulesDataProcessor:: |
protected static | function | Defines the processor form element. | 3 |
RulesDataProcessor:: |
public | function | Gets the settings array for this and all contained chained processors. | |
RulesDataProcessor:: |
public | function | Gets the settings of this processor. | |
RulesDataProcessor:: |
protected | function | ||
RulesDataProcessor:: |
public static | function | ||
RulesURIInputEvaluator:: |
public | function |
Overrides RulesDataInputEvaluator::evaluate(). Overrides RulesDataInputEvaluator:: |
|
RulesURIInputEvaluator:: |
public | function |
Overrides RulesDataInputEvaluator::prepare(). Overrides RulesDataInputEvaluator:: |