class RulesPHPDataProcessor in Rules 7.2
A data processor using PHP.
Hierarchy
- class \RulesDataProcessor
- class \RulesPHPDataProcessor
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 - Contains rules integration for the php module needed during evaluation.
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
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
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 static | function | Attaches the form of applicable data processors. | 1 |
RulesDataProcessor:: |
public | function | Returns an array of modules which we depend on. | |
RulesDataProcessor:: |
public | function | Gets the settings array for this and all contained chained processors. | |
RulesDataProcessor:: |
protected | function | Return $this or skip this processor by returning the next processor. | 1 |
RulesDataProcessor:: |
public | function | Gets the settings of this processor. | |
RulesDataProcessor:: |
public static | function | Prepares the processor for parameters. | 1 |
RulesDataProcessor:: |
public static | function | Returns defined data processors applicable for the given parameter. | 1 |
RulesDataProcessor:: |
protected | function | ||
RulesDataProcessor:: |
public static | function | ||
RulesDataProcessor:: |
protected | function | Constructor. | 1 |
RulesPHPDataProcessor:: |
public | function |
Overrides RulesDataProcessor::editAccess(). Overrides RulesDataProcessor:: |
|
RulesPHPDataProcessor:: |
protected static | function |
Overrides RulesDataProcessor::form(). Overrides RulesDataProcessor:: |
|
RulesPHPDataProcessor:: |
public | function |
Overrides RulesDataProcessor::process(). Overrides RulesDataProcessor:: |