class RulesCondition
Implements a rules condition.
Hierarchy
- class \RulesExtendable extends \FacesExtendable
- class \RulesPlugin extends \RulesExtendable
- class \RulesAbstractPlugin extends \RulesPlugin
- class \RulesCondition extends \RulesAbstractPlugin implements \RulesConditionInterface
- class \RulesAbstractPlugin extends \RulesPlugin
- class \RulesPlugin extends \RulesExtendable
Expanded class hierarchy of RulesCondition
1 string reference to 'RulesCondition'
- rules_rules_plugin_info in ./
rules.module - Implements hook_rules_plugin_info().
File
-
includes/
rules.plugins.inc, line 83
View source
class RulesCondition extends RulesAbstractPlugin implements RulesConditionInterface {
/**
* @var string
*/
protected $itemName = 'condition';
/**
* @var bool
*/
protected $negate = FALSE;
public function providesVariables() {
return array();
}
public function negate($negate = TRUE) {
$this->negate = (bool) $negate;
return $this;
}
public function isNegated() {
return $this->negate;
}
protected function executeCallback(array $args, RulesState $state = NULL) {
$return = (bool) $this->__call('execute', empty($this->info['named parameter']) ? $args : array(
$args,
));
$return = $this->negate ? !$return : $return;
rules_log('The condition %name evaluated to %bool', array(
'%name' => $this->label($this->elementName),
'%bool' => $return ? 'TRUE' : 'FALSE',
), RulesLog::INFO, $this);
return $return;
}
public function __sleep() {
return parent::__sleep() + array(
'negate' => 'negate',
);
}
/**
* Just return the boolean result.
*/
protected function returnVariables(RulesState $state, $result = NULL) {
return $result;
}
protected function exportToArray() {
$not = $this->negate ? 'NOT ' : '';
$export = $this->exportSettings();
// Abbreviate the export making "USING" implicit.
return array(
$not . $this->elementName => isset($export['USING']) ? $export['USING'] : array(),
);
}
public function import(array $export) {
$this->elementName = rules_array_key($export);
if (strpos($this->elementName, 'NOT ') === 0) {
$this->elementName = substr($this->elementName, 4);
$this->negate = TRUE;
}
// After setting the element name, setup the element again so the right
// element info is loaded.
$this->setUp();
// Re-add 'USING' which has been removed for abbreviation.
$this->importSettings(array(
'USING' => reset($export),
));
}
public function label() {
$label = parent::label();
return $this->negate ? t('NOT !condition', array(
'!condition' => $label,
)) : $label;
}
}
Members
Title Sort descending | Modifiers | Object type | Summary | Overriden Title | Overrides |
---|---|---|---|---|---|
RulesAbstractPlugin::$elementName | protected | property | |||
RulesAbstractPlugin::$info | protected | property | Info about this element. Usage depends on the plugin. | Overrides RulesPlugin::$info | |
RulesAbstractPlugin::$infoLoaded | protected | property | |||
RulesAbstractPlugin::access | public | function | Whether the currently logged in user has access to all configured elements. | Overrides RulesPlugin::access | |
RulesAbstractPlugin::dependencies | public | function | Calculates an array of required modules. | Overrides RulesPlugin::dependencies | |
RulesAbstractPlugin::evaluate | public | function | Evaluate the element on a given rules evaluation state. | Overrides RulesPlugin::evaluate | |
RulesAbstractPlugin::executeByArgs | public | function | Execute the configuration by passing arguments in a single array. | Overrides RulesPlugin::executeByArgs | |
RulesAbstractPlugin::forceSetUp | public | function | Forces the object to be setUp, this executes setUp() if not done yet. | Overrides RulesExtendable::forceSetUp | |
RulesAbstractPlugin::getElementName | public | function | Gets the name of the configured action or condition. | ||
RulesAbstractPlugin::getFileName | protected | function | |||
RulesAbstractPlugin::getIncludeFiles | protected static | function | Returns all include files for a module. | ||
RulesAbstractPlugin::getPluginName | public | function | Gets the name of this plugin instance. | Overrides RulesPlugin::getPluginName | |
RulesAbstractPlugin::includeFiles | public static | function | Makes sure all supported destinations are included. | ||
RulesAbstractPlugin::info | public | function | Returns the info of the plugin. | Overrides RulesPlugin::info | |
RulesAbstractPlugin::integrityCheck | public | function | Makes sure the plugin is configured right. | Overrides RulesPlugin::integrityCheck | |
RulesAbstractPlugin::loadBasicInclude | protected | function | Loads this module's .rules.inc file. | ||
RulesAbstractPlugin::pluginParameterInfo | public | function | Returns info about parameters needed by the plugin. | Overrides RulesPlugin::pluginParameterInfo | |
RulesAbstractPlugin::pluginProvidesVariables | public | function | Returns info about variables 'provided' by the plugin. | Overrides RulesPlugin::pluginProvidesVariables | |
RulesAbstractPlugin::processSettings | public | function | Processes the settings e.g. to prepare input evaluators. | Overrides RulesPlugin::processSettings | |
RulesAbstractPlugin::rebuildCache | public | function | Add in the data provided by the info hooks to the cache. | Overrides RulesExtendable::rebuildCache | |
RulesAbstractPlugin::setUp | protected | function | Overrides RulesExtendable::setUp | ||
RulesAbstractPlugin::variableInfoAssertions | protected | function | Returns asserted additions to the available variable info. | Overrides RulesPlugin::variableInfoAssertions | |
RulesAbstractPlugin::__construct | public | function | Overrides RulesExtendable::__construct | ||
RulesCondition::$itemName | protected | property | Overrides RulesExtendable::$itemName | ||
RulesCondition::$negate | protected | property | |||
RulesCondition::executeCallback | protected | function | Execute the configured execution callback and log that. | Overrides RulesAbstractPlugin::executeCallback | |
RulesCondition::exportToArray | protected | function | Overrides RulesAbstractPlugin::exportToArray | ||
RulesCondition::import | public | function | Applies the given export. | Overrides RulesAbstractPlugin::import | |
RulesCondition::isNegated | public | function | Returns whether the element is configured to negate the result. | Overrides RulesConditionInterface::isNegated | |
RulesCondition::label | public | function | Returns the label of the element. | Overrides RulesAbstractPlugin::label | |
RulesCondition::negate | public | function | Negate the result. | Overrides RulesConditionInterface::negate | |
RulesCondition::providesVariables | public | function | Returns info about all variables provided for later evaluated elements. | Overrides RulesPlugin::providesVariables | |
RulesCondition::returnVariables | protected | function | Just return the boolean result. | Overrides RulesPlugin::returnVariables | |
RulesCondition::__sleep | public | function | Overrides RulesAbstractPlugin::__sleep | ||
RulesExtendable::$itemInfo | protected | property | |||
RulesExtendable::facesAs | public | function | |||
RulesExtendable::itemFacesAs | public static | function | Returns whether the a RuleExtendable supports the given interface. | ||
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::$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::availableVariables | public | function | Returns info about variables available to be used as arguments for this element. | 1 | |
RulesPlugin::checkParameterSettings | protected | function | Checks whether parameters are correctly configured. | ||
RulesPlugin::checkVarName | protected | function | |||
RulesPlugin::compare | protected static | function | |||
RulesPlugin::delete | public | function | Deletes configuration from database. | 1 | |
RulesPlugin::depth | public | function | Returns the depth of this element in the configuration. | ||
RulesPlugin::destroy | public | function | Removes circular object references so PHP garbage collector can work. | 1 | |
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::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::internalIdentifier | public | function | |||
RulesPlugin::isRoot | public | function | Returns whether the element is the root of the configuration. | ||
RulesPlugin::optimize | public | function | Optimizes a rule configuration in order to speed up evaluation. | 1 | |
RulesPlugin::parameterInfo | public | function | Returns info about parameters needed for executing the configured plugin. | 1 | |
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::resetInternalCache | public | function | Resets any internal static caches. | 1 | |
RulesPlugin::returnExport | protected | function | Finalizes the configuration export. | ||
RulesPlugin::root | public | function | Gets the root element of the configuration. | ||
RulesPlugin::save | public | function | Saves the configuration to the database. | 1 | |
RulesPlugin::setParent | public | function | Sets a new parent element. | ||
RulesPlugin::setUpState | public | function | Sets up the execution state for the given arguments. | ||
RulesPlugin::setUpVariables | protected | function | Returns info about all variables that have to be setup in the state. | 1 | |
RulesPlugin::__clone | public | function | Do a deep clone. | 1 | |
RulesPlugin::__toString | public | function | When converted to a string, just use the export format. |