class RulesPHPDataProcessor
A data processor using PHP.
Hierarchy
- class \RulesDataProcessor
- class \RulesPHPDataProcessor extends \RulesDataProcessor
 
 
Expanded class hierarchy of RulesPHPDataProcessor
Related topics
1 string reference to 'RulesPHPDataProcessor'
- rules_php_data_processor_info in modules/
php.rules.inc  - Implements hook_rules_data_processor_info() on behalf of the php module.
 
File
- 
              modules/
php.eval.inc, line 87  
View source
class RulesPHPDataProcessor extends RulesDataProcessor {
  
  /**
   * Overrides RulesDataProcessor::form().
   */
  protected static function form($settings, $var_info) {
    $settings += array(
      'code' => '',
    );
    $form = array(
      '#type' => 'fieldset',
      '#title' => t('PHP evaluation'),
      '#collapsible' => TRUE,
      '#collapsed' => empty($settings['code']),
      '#description' => t('Enter PHP code to process the selected argument value.'),
    );
    $form['code'] = array(
      '#type' => 'textarea',
      '#title' => t('Code'),
      '#description' => t('Enter PHP code without <?php ?> delimiters that returns the processed value. The selected value is available in the variable $value. Example: %code', array(
        '%code' => 'return $value + 1;',
      )),
      '#default_value' => $settings['code'],
      '#weight' => 5,
    );
    return $form;
  }
  
  /**
   * Overrides RulesDataProcessor::editAccess().
   */
  public function editAccess() {
    return parent::editAccess() && (user_access('use PHP for settings') || drupal_is_cli());
  }
  
  /**
   * Overrides RulesDataProcessor::process().
   */
  public function process($value, $info, RulesState $state, RulesPlugin $element) {
    $value = isset($this->processor) ? $this->processor
      ->process($value, $info, $state, $element) : $value;
    return rules_php_eval_return($this->setting['code'], array(
      'value' => $value,
    ));
  }
}
Members
| Title Sort descending | Modifiers | Object type | Summary | Overriden Title | Overrides | 
|---|---|---|---|---|---|
| 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::attachForm | public static | function | Attaches the form of applicable data processors. | 1 | |
| RulesDataProcessor::dependencies | public | function | Returns an array of modules which we depend on. | ||
| RulesDataProcessor::getChainSettings | public | function | Gets the settings array for this and all contained chained processors. | ||
| RulesDataProcessor::getPreparedValue | protected | function | Return $this or skip this processor by returning the next processor. | 1 | |
| RulesDataProcessor::getSetting | public | function | Gets the settings of this processor. | ||
| RulesDataProcessor::prepareSetting | public static | function | Prepares the processor for parameters. | 1 | |
| RulesDataProcessor::processors | public static | function | Returns defined data processors applicable for the given parameter. | 1 | |
| RulesDataProcessor::unchain | protected | function | |||
| RulesDataProcessor::_item_sort | public static | function | |||
| RulesDataProcessor::__construct | protected | function | Constructor. | 1 | |
| RulesPHPDataProcessor::editAccess | public | function | Overrides RulesDataProcessor::editAccess(). | Overrides RulesDataProcessor::editAccess | |
| RulesPHPDataProcessor::form | protected static | function | Overrides RulesDataProcessor::form(). | Overrides RulesDataProcessor::form | |
| RulesPHPDataProcessor::process | public | function | Overrides RulesDataProcessor::process(). | Overrides RulesDataProcessor::process |