class RulesEventSet
This class is used for caching the rules to be evaluated per event.
Hierarchy
- class \RulesExtendable extends \FacesExtendable
- class \RulesPlugin extends \RulesExtendable
- class \RulesContainerPlugin implements \IteratorAggregate extends \RulesPlugin
- class \RulesActionContainer implements \RulesActionInterface extends \RulesContainerPlugin
- class \RulesRuleSet extends \RulesActionContainer
- class \RulesEventSet extends \RulesRuleSet
- class \RulesRuleSet extends \RulesActionContainer
- class \RulesActionContainer implements \RulesActionInterface extends \RulesContainerPlugin
- class \RulesContainerPlugin implements \IteratorAggregate extends \RulesPlugin
- class \RulesPlugin extends \RulesExtendable
Expanded class hierarchy of RulesEventSet
1 string reference to 'RulesEventSet'
- rules_rules_plugin_info in ./
rules.module - Implements hook_rules_plugin_info().
File
-
includes/
rules.plugins.inc, line 814
View source
class RulesEventSet extends RulesRuleSet {
/**
* @var string
*/
protected $itemName = 'event set';
/**
* Event sets may recurse as we block recursions on rule-level.
*
* @var bool
*/
public $recursion = TRUE;
public function __construct($info = array()) {
$this->setup();
$this->info = $info;
}
public function executeByArgs($args = array()) {
rules_log('Reacting on event %label.', array(
'%label' => $this->info['label'],
), RulesLog::INFO, NULL, TRUE);
$state = $this->setUpState($args);
module_invoke_all('rules_config_execute', $this);
$this->evaluate($state);
$state->cleanUp($this);
rules_log('Finished reacting on event %label.', array(
'%label' => $this->info['label'],
), RulesLog::INFO, NULL, FALSE);
}
/**
* Rebuilds the event cache.
*
* We cache event-sets per event in order to allow efficient usage via
* rules_invoke_event().
*
* @see rules_get_cache()
* @see rules_invoke_event()
*/
public static function rebuildEventCache() {
// Set up the per-event cache.
$events = rules_fetch_data('event_info');
$sets = array();
// Add all rules associated with this event to an EventSet for caching.
$rules = rules_config_load_multiple(FALSE, array(
'plugin' => 'reaction rule',
'active' => TRUE,
));
foreach ($rules as $name => $rule) {
foreach ($rule->events() as $event_name) {
$event_base_name = rules_get_event_base_name($event_name);
// Skip not defined events.
if (empty($events[$event_base_name])) {
continue;
}
// Create an event set if not yet done.
if (!isset($sets[$event_name])) {
$handler = rules_get_event_handler($event_name, $rule->getEventSettings($event_name));
// Start the event dispatcher for this event, if any.
if ($handler instanceof RulesEventDispatcherInterface && !$handler->isWatching()) {
$handler->startWatching();
}
// Update the event info with the variables available based on the
// event settings.
$event_info = $events[$event_base_name];
$event_info['variables'] = $handler->availableVariables();
$sets[$event_name] = new RulesEventSet($event_info);
$sets[$event_name]->name = $event_name;
}
// If a rule is marked as dirty, check if this still applies.
if ($rule->dirty) {
rules_config_update_dirty_flag($rule);
}
if (!$rule->dirty) {
// Clone the rule to avoid modules getting the changed version from
// the static cache.
$sets[$event_name]->rule(clone $rule);
}
}
}
// Create cache items for all created sets.
foreach ($sets as $event_name => $set) {
$set->sortChildren();
$set->optimize();
// Allow modules to alter the cached event set.
drupal_alter('rules_event_set', $event_name, $set);
rules_set_cache('event_' . $event_name, $set);
}
// Cache a whitelist of configured events so we can use it to speed up later
// calls. See rules_invoke_event().
rules_set_cache('rules_event_whitelist', array_flip(array_keys($sets)));
}
protected function stateVariables($element = NULL) {
return $this->availableVariables();
}
/**
* Do not save since this class is for caching purposes only.
*
* @see RulesPlugin::save()
*/
public function save($name = NULL, $module = 'rules') {
return FALSE;
}
}
Members
| Title Sort descending | Modifiers | Object type | Summary | Overriden Title | Overrides |
|---|---|---|---|---|---|
| RulesActionContainer::action | public | function | Adds an action to the container. | ||
| RulesActionContainer::componentProvidesVariables | public | function | Returns an array of provided variable names. | ||
| RulesActionContainer::evaluate | public | function | Evaluate, whereas by default new vars are visible in the parent's scope. | Overrides RulesPlugin::evaluate | 2 |
| RulesActionContainer::exportToArray | protected | function | Overrides RulesContainerPlugin::exportToArray | 1 | |
| RulesActionContainer::import | public | function | Applies the given export. | Overrides RulesContainerPlugin::import | 1 |
| RulesActionContainer::pluginProvidesVariables | public | function | Returns info about variables 'provided' by the plugin. | Overrides RulesPlugin::pluginProvidesVariables | |
| RulesActionContainer::providesVariables | public | function | Returns info about all variables provided for later evaluated elements. | Overrides RulesPlugin::providesVariables | 1 |
| RulesContainerPlugin::$children | protected | property | |||
| RulesContainerPlugin::access | public | function | Whether the currently logged in user has access to all configured elements. | Overrides RulesPlugin::access | 1 |
| RulesContainerPlugin::availableVariables | public | function | Returns info about variables available to be used as arguments for this element. | Overrides RulesPlugin::availableVariables | |
| RulesContainerPlugin::componentVariables | public | function | Returns the specified variables, in case the plugin is used as component. | ||
| RulesContainerPlugin::delete | public | function | Overrides delete to keep the children alive, if possible. | Overrides RulesPlugin::delete | 1 |
| RulesContainerPlugin::dependencies | public | function | Calculates an array of required modules. | Overrides RulesPlugin::dependencies | 1 |
| RulesContainerPlugin::destroy | public | function | Removes circular object references so PHP garbage collector can work. | Overrides RulesPlugin::destroy | 1 |
| RulesContainerPlugin::exportFlat | protected | function | Determines whether the element should be exported in flat style. | 1 | |
| RulesContainerPlugin::getIterator | public | function | Allows access to the children through the iterator. | 1 | |
| RulesContainerPlugin::integrityCheck | public | function | Overrides RulesPlugin::integrityCheck | 2 | |
| RulesContainerPlugin::optimize | public | function | Overrides optimize(). | Overrides RulesPlugin::optimize | |
| RulesContainerPlugin::parameterInfo | public | function | Returns info about parameters needed for executing the configured plugin. | Overrides RulesPlugin::parameterInfo | |
| RulesContainerPlugin::resetInternalCache | public | function | Resets any internal static caches. | Overrides RulesPlugin::resetInternalCache | 1 |
| RulesContainerPlugin::setUpVariables | protected | function | Returns info about all variables that have to be setup in the state. | Overrides RulesPlugin::setUpVariables | |
| RulesContainerPlugin::sortChildren | public | function | Sorts all child elements by their weight. | 1 | |
| RulesContainerPlugin::variableInfoAssertions | protected | function | Returns asserted additions to the available variable info. | Overrides RulesPlugin::variableInfoAssertions | 1 |
| RulesContainerPlugin::__clone | public | function | By default we do a deep clone. | Overrides RulesPlugin::__clone | 1 |
| RulesContainerPlugin::__sleep | public | function | Overrides RulesPlugin::__sleep | 2 | |
| RulesEventSet::$itemName | protected | property | Overrides RulesRuleSet::$itemName | ||
| RulesEventSet::$recursion | public | property | Event sets may recurse as we block recursions on rule-level. | ||
| RulesEventSet::executeByArgs | public | function | Executes container with the given arguments. | Overrides RulesContainerPlugin::executeByArgs | |
| RulesEventSet::rebuildEventCache | public static | function | Rebuilds the event cache. | ||
| RulesEventSet::save | public | function | Do not save since this class is for caching purposes only. | Overrides RulesPlugin::save | |
| RulesEventSet::stateVariables | protected | function | Returns available state variables for an element. | Overrides RulesContainerPlugin::stateVariables | |
| RulesEventSet::__construct | public | function | Overrides RulesActionContainer::__construct | ||
| RulesExtendable::$itemInfo | protected | property | |||
| RulesExtendable::facesAs | public | function | |||
| RulesExtendable::forceSetUp | public | function | Forces the object to be setUp, this executes setUp() if not done yet. | 1 | |
| RulesExtendable::itemFacesAs | public static | function | Returns whether the a RuleExtendable supports the given interface. | ||
| RulesExtendable::rebuildCache | public | function | Allows items to add something to the rules cache. | 1 | |
| RulesExtendable::setUp | protected | function | 1 | ||
| RulesExtendable::__call | public | function | Magic method: Invoke the dynamically implemented methods. | ||
| RulesPlugin::$availableVariables | protected | property | Static cache for availableVariables(). | 1 | |
| RulesPlugin::$cache | protected | property | Overrides RulesExtendable::$cache | ||
| RulesPlugin::$elementId | protected | property | Identifies an element inside a configuration. | ||
| RulesPlugin::$hook | protected | property | Overrides RulesExtendable::$hook | ||
| RulesPlugin::$id | public | property | If this is a configuration saved to the db, the id of it. | ||
| RulesPlugin::$info | protected | property | Info about this element. Usage depends on the plugin. | 2 | |
| RulesPlugin::$name | public | property | |||
| RulesPlugin::$parent | protected | property | The parent element, if any. | ||
| RulesPlugin::$settings | public | property | An array of settings for this element. | ||
| RulesPlugin::$weight | public | property | |||
| RulesPlugin::applyDataSelector | public | function | Applies the given data selector. | ||
| RulesPlugin::checkParameterSettings | protected | function | Checks whether parameters are correctly configured. | ||
| RulesPlugin::checkVarName | protected | function | |||
| RulesPlugin::compare | protected static | function | |||
| RulesPlugin::depth | public | function | Returns the depth of this element in the configuration. | ||
| RulesPlugin::elementId | public | function | Returns the element id, which identifies the element inside the config. | ||
| RulesPlugin::elementMap | public | function | Gets the element map helper object, which helps mapping elements to ids. | ||
| RulesPlugin::elements | public | function | Iterate over all elements nested below the current element. | ||
| RulesPlugin::ensureNameExists | protected | function | Ensure the configuration has a name. If not, generate one. | ||
| RulesPlugin::entityInfo | public | function | |||
| RulesPlugin::entityType | public | function | |||
| RulesPlugin::execute | public | function | Execute the configuration. | ||
| RulesPlugin::export | public | function | Exports a rule configuration. | ||
| RulesPlugin::exportParameterSetting | protected | function | |||
| RulesPlugin::exportSettings | protected | function | 1 | ||
| RulesPlugin::form | public | function | Seamlessly invokes the method implemented via faces. | ||
| RulesPlugin::form_submit | public | function | |||
| RulesPlugin::form_validate | public | function | |||
| RulesPlugin::getArgument | protected | function | Returns the argument for the parameter $name described with $info. | ||
| RulesPlugin::getArgumentInfo | public | function | Returns info about the configured argument. | ||
| RulesPlugin::getExecutionArguments | protected | function | Gets the right arguments for executing the element. | ||
| RulesPlugin::getPluginName | public | function | Gets the name of this plugin instance. | 1 | |
| RulesPlugin::hasStatus | public | function | Checks if the configuration has a certain exportable status. | ||
| RulesPlugin::identifier | public | function | Returns the config name. | ||
| RulesPlugin::importParameterSetting | protected | function | |||
| RulesPlugin::importSettings | protected | function | 1 | ||
| RulesPlugin::info | public | function | Returns the info of the plugin. | 2 | |
| RulesPlugin::internalIdentifier | public | function | |||
| RulesPlugin::isRoot | public | function | Returns whether the element is the root of the configuration. | ||
| RulesPlugin::label | public | function | Returns the label of the element. | 4 | |
| RulesPlugin::parentElement | public | function | Returns the element's parent. | ||
| RulesPlugin::plugin | public | function | Returns the name of the element's plugin. | ||
| RulesPlugin::pluginInfo | public | function | Returns info about the element's plugin. | ||
| RulesPlugin::pluginParameterInfo | public | function | Returns info about parameters needed by the plugin. | 2 | |
| RulesPlugin::processSettings | public | function | Processes the settings e.g. to prepare input evaluators. | 1 | |
| RulesPlugin::returnExport | protected | function | Finalizes the configuration export. | ||
| RulesPlugin::returnVariables | protected | function | Gets variables to return once the configuration has been executed. | 2 | |
| RulesPlugin::root | public | function | Gets the root element of the configuration. | ||
| RulesPlugin::setParent | public | function | Sets a new parent element. | ||
| RulesPlugin::setUpState | public | function | Sets up the execution state for the given arguments. | ||
| RulesPlugin::__toString | public | function | When converted to a string, just use the export format. | ||
| RulesRuleSet::exportChildren | protected | function | Overrides RulesContainerPlugin::exportChildren | ||
| RulesRuleSet::importChildren | protected | function | Overrides RulesContainerPlugin::importChildren | ||
| RulesRuleSet::rule | public | function |