You are here

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

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

Namesort descending Modifiers Type Description Overrides
RulesDataInputEvaluator::attachForm public static function Overrides RulesDataProcessor::attachForm(). Overrides RulesDataProcessor::attachForm
RulesDataInputEvaluator::evaluators public static function Returns all input evaluators that can be applied to the parameters type.
RulesDataInputEvaluator::getEvaluatorOptions protected function Generates the evaluator $options.
RulesDataInputEvaluator::getPreparedValue protected function Return $this or skip this processor by returning the next processor. Overrides RulesDataProcessor::getPreparedValue
RulesDataInputEvaluator::help public static function Provide some usage help for the evaluator. 3
RulesDataInputEvaluator::prepareSetting public static function Overridden to prepare input evaluator processors. Overrides RulesDataProcessor::prepareSetting
RulesDataInputEvaluator::process public function Overridden to generate evaluator $options and invoke evaluate(). Overrides RulesDataProcessor::process 1
RulesDataInputEvaluator::processors public static function Overrides RulesDataProcessor::processors(). Overrides RulesDataProcessor::processors
RulesDataInputEvaluator::__construct protected function Overridden to invoke prepare(). Overrides RulesDataProcessor::__construct
RulesDataProcessor::$processor protected property Allows chaining processors. If set, the next processor to invoke.
RulesDataProcessor::$setting protected property The processors' setting value.
RulesDataProcessor::access public static function Return whether the current user has permission to use the processor. 1
RulesDataProcessor::dependencies public function Returns an array of modules which we depend on.
RulesDataProcessor::editAccess public function Determines whether the current user has permission to edit this chain of data processors. 2
RulesDataProcessor::form protected static function Defines the processor form element. 3
RulesDataProcessor::getChainSettings public function Gets the settings array for this and all contained chained processors.
RulesDataProcessor::getSetting public function Gets the settings of this processor.
RulesDataProcessor::unchain protected function
RulesDataProcessor::_item_sort public static function
RulesURIInputEvaluator::evaluate public function Overrides RulesDataInputEvaluator::evaluate(). Overrides RulesDataInputEvaluator::evaluate
RulesURIInputEvaluator::prepare public function Overrides RulesDataInputEvaluator::prepare(). Overrides RulesDataInputEvaluator::prepare