class RulesAction in Rules 7.2
Implements a rules action.
Hierarchy
- class \RulesExtendable extends \FacesExtendable
- class \RulesPlugin
- class \RulesAbstractPlugin
- class \RulesAction implements RulesActionInterface
- class \RulesAbstractPlugin
- class \RulesPlugin
Expanded class hierarchy of RulesAction
1 string reference to 'RulesAction'
- rules_rules_plugin_info in ./
rules.module - Implements hook_rules_plugin_info().
File
- includes/
rules.plugins.inc, line 11 - Contains plugin info and implementations not needed for rule evaluation.
View source
class RulesAction extends RulesAbstractPlugin implements RulesActionInterface {
/**
* @var string
*/
protected $itemName = 'action';
/**
* Execute the callback and update/save data as specified by the action.
*/
protected function executeCallback(array $args, RulesState $state = NULL) {
rules_log('Evaluating the action %name.', array(
'%name' => $this
->label($this->elementName),
), RulesLog::INFO, $this);
$return = $this
->__call('execute', empty($this->info['named parameter']) ? $args : array(
$args,
));
// Get the (partially) wrapped arguments.
$args = $state->currentArguments;
if (is_array($return)) {
foreach ($return as $name => $data) {
// Add provided variables.
if (isset($this->info['provides'][$name])) {
$var_name = isset($this->settings[$name . ':var']) ? $this->settings[$name . ':var'] : $name;
if (!$state
->varInfo($var_name)) {
$state
->addVariable($var_name, $data, $this->info['provides'][$name]);
rules_log('Added the provided variable %name of type %type', array(
'%name' => $var_name,
'%type' => $this->info['provides'][$name]['type'],
), RulesLog::INFO, $this);
if (!empty($this->info['provides'][$name]['save']) && $state->variables[$var_name] instanceof EntityMetadataWrapper) {
$state
->saveChanges($var_name, $state->variables[$var_name]);
}
}
}
elseif (!isset($this->info['provides'][$name])) {
// Update the data value using the wrapper.
if (isset($args[$name]) && $args[$name] instanceof EntityMetadataWrapper) {
try {
$args[$name]
->set($data);
} catch (EntityMetadataWrapperException $e) {
throw new RulesEvaluationException('Unable to update the argument for parameter %name: %error', array(
'%name' => $name,
'%error' => $e
->getMessage(),
), $this);
}
}
elseif (array_key_exists($name, $args)) {
// Map back to the source variable name and update it.
$var_name = !empty($this->settings[$name . ':select']) ? str_replace('-', '_', $this->settings[$name . ':select']) : $name;
$state->variables[$var_name] = $data;
}
}
}
}
// Save parameters as defined in the parameter info.
if ($return !== FALSE) {
foreach ($this->info['parameter'] as $name => $info) {
if (!empty($info['save']) && $args[$name] instanceof EntityMetadataWrapper) {
if (isset($this->settings[$name . ':select'])) {
$state
->saveChanges($this->settings[$name . ':select'], $args[$name]);
}
else {
// Wrapper has been configured via direct input, so just save.
rules_log('Saved argument of type %type for parameter %name.', array(
'%name' => $name,
'%type' => $args[$name]
->type(),
));
$args[$name]
->save();
}
}
}
}
}
}
Members
Name![]() |
Modifiers | Type | Description | Overrides |
---|---|---|---|---|
RulesAbstractPlugin:: |
protected | property | ||
RulesAbstractPlugin:: |
protected | property |
Info about this element. Usage depends on the plugin. Overrides RulesPlugin:: |
|
RulesAbstractPlugin:: |
protected | property | ||
RulesAbstractPlugin:: |
public | function |
Whether the currently logged in user has access to all configured elements. Overrides RulesPlugin:: |
|
RulesAbstractPlugin:: |
public | function |
Calculates an array of required modules. Overrides RulesPlugin:: |
|
RulesAbstractPlugin:: |
public | function |
Evaluate the element on a given rules evaluation state. Overrides RulesPlugin:: |
|
RulesAbstractPlugin:: |
public | function |
Execute the configuration by passing arguments in a single array. Overrides RulesPlugin:: |
|
RulesAbstractPlugin:: |
protected | function |
Overrides RulesPlugin:: |
1 |
RulesAbstractPlugin:: |
public | function |
Forces the object to be setUp, this executes setUp() if not done yet. Overrides RulesExtendable:: |
|
RulesAbstractPlugin:: |
public | function | Gets the name of the configured action or condition. | |
RulesAbstractPlugin:: |
protected | function | ||
RulesAbstractPlugin:: |
protected static | function | Returns all include files for a module. | |
RulesAbstractPlugin:: |
public | function |
Gets the name of this plugin instance. Overrides RulesPlugin:: |
|
RulesAbstractPlugin:: |
public | function |
Applies the given export. Overrides RulesPlugin:: |
1 |
RulesAbstractPlugin:: |
public static | function | Makes sure all supported destinations are included. | |
RulesAbstractPlugin:: |
public | function |
Returns the info of the plugin. Overrides RulesPlugin:: |
|
RulesAbstractPlugin:: |
public | function |
Makes sure the plugin is configured right. Overrides RulesPlugin:: |
|
RulesAbstractPlugin:: |
public | function |
Returns the label of the element. Overrides RulesPlugin:: |
1 |
RulesAbstractPlugin:: |
protected | function | Loads this module's .rules.inc file. | |
RulesAbstractPlugin:: |
public | function |
Returns info about parameters needed by the plugin. Overrides RulesPlugin:: |
|
RulesAbstractPlugin:: |
public | function |
Returns info about variables 'provided' by the plugin. Overrides RulesPlugin:: |
|
RulesAbstractPlugin:: |
public | function |
Processes the settings e.g. to prepare input evaluators. Overrides RulesPlugin:: |
|
RulesAbstractPlugin:: |
public | function |
Add in the data provided by the info hooks to the cache. Overrides RulesExtendable:: |
|
RulesAbstractPlugin:: |
protected | function |
Overrides RulesExtendable:: |
|
RulesAbstractPlugin:: |
protected | function |
Returns asserted additions to the available variable info. Overrides RulesPlugin:: |
|
RulesAbstractPlugin:: |
public | function |
Overrides RulesExtendable:: |
|
RulesAbstractPlugin:: |
public | function |
Overrides RulesPlugin:: |
1 |
RulesAction:: |
protected | property |
Overrides RulesExtendable:: |
|
RulesAction:: |
protected | function |
Execute the callback and update/save data as specified by the action. Overrides RulesAbstractPlugin:: |
|
RulesExtendable:: |
protected | property | ||
RulesExtendable:: |
public | function | ||
RulesExtendable:: |
public static | function | Returns whether the a RuleExtendable supports the given interface. | |
RulesExtendable:: |
public | function | Magic method: Invoke the dynamically implemented methods. | |
RulesPlugin:: |
protected | property | Static cache for availableVariables(). | 1 |
RulesPlugin:: |
protected | property |
Overrides RulesExtendable:: |
|
RulesPlugin:: |
protected | property | Identifies an element inside a configuration. | |
RulesPlugin:: |
protected | property |
Overrides RulesExtendable:: |
|
RulesPlugin:: |
public | property | If this is a configuration saved to the db, the id of it. | |
RulesPlugin:: |
public | property | ||
RulesPlugin:: |
protected | property | The parent element, if any. | |
RulesPlugin:: |
public | property | An array of settings for this element. | |
RulesPlugin:: |
public | property | ||
RulesPlugin:: |
public | function | Applies the given data selector. | |
RulesPlugin:: |
public | function | Returns info about variables available to be used as arguments for this element. | 1 |
RulesPlugin:: |
protected | function | Checks whether parameters are correctly configured. | |
RulesPlugin:: |
protected | function | ||
RulesPlugin:: |
protected static | function | ||
RulesPlugin:: |
public | function | Deletes configuration from database. | 1 |
RulesPlugin:: |
public | function | Returns the depth of this element in the configuration. | |
RulesPlugin:: |
public | function | Removes circular object references so PHP garbage collector can work. | 1 |
RulesPlugin:: |
public | function | Returns the element id, which identifies the element inside the config. | |
RulesPlugin:: |
public | function | Gets the element map helper object, which helps mapping elements to ids. | |
RulesPlugin:: |
public | function | Iterate over all elements nested below the current element. | |
RulesPlugin:: |
protected | function | Ensure the configuration has a name. If not, generate one. | |
RulesPlugin:: |
public | function | ||
RulesPlugin:: |
public | function | ||
RulesPlugin:: |
public | function | Execute the configuration. | |
RulesPlugin:: |
public | function | Exports a rule configuration. | |
RulesPlugin:: |
protected | function | ||
RulesPlugin:: |
protected | function | 1 | |
RulesPlugin:: |
public | function | Seamlessly invokes the method implemented via faces. | |
RulesPlugin:: |
public | function | ||
RulesPlugin:: |
public | function | ||
RulesPlugin:: |
protected | function | Returns the argument for the parameter $name described with $info. | |
RulesPlugin:: |
public | function | Returns info about the configured argument. | |
RulesPlugin:: |
protected | function | Gets the right arguments for executing the element. | |
RulesPlugin:: |
public | function | Checks if the configuration has a certain exportable status. | |
RulesPlugin:: |
public | function | Returns the config name. | |
RulesPlugin:: |
protected | function | ||
RulesPlugin:: |
protected | function | 1 | |
RulesPlugin:: |
public | function | ||
RulesPlugin:: |
public | function | Returns whether the element is the root of the configuration. | |
RulesPlugin:: |
public | function | Optimizes a rule configuration in order to speed up evaluation. | 1 |
RulesPlugin:: |
public | function | Returns info about parameters needed for executing the configured plugin. | 1 |
RulesPlugin:: |
public | function | Returns the element's parent. | |
RulesPlugin:: |
public | function | Returns the name of the element's plugin. | |
RulesPlugin:: |
public | function | Returns info about the element's plugin. | |
RulesPlugin:: |
public | function | Returns info about all variables provided for later evaluated elements. | 2 |
RulesPlugin:: |
public | function | Resets any internal static caches. | 1 |
RulesPlugin:: |
protected | function | Finalizes the configuration export. | |
RulesPlugin:: |
protected | function | Gets variables to return once the configuration has been executed. | 2 |
RulesPlugin:: |
public | function | Gets the root element of the configuration. | |
RulesPlugin:: |
public | function | Saves the configuration to the database. | 1 |
RulesPlugin:: |
public | function | Sets a new parent element. | |
RulesPlugin:: |
public | function | Sets up the execution state for the given arguments. | |
RulesPlugin:: |
protected | function | Returns info about all variables that have to be setup in the state. | 1 |
RulesPlugin:: |
public | function | Do a deep clone. | 1 |
RulesPlugin:: |
public | function | When converted to a string, just use the export format. |