You are here

class RulesNodeConditionType in Rules 7.2

Condition: Check for selected content types.

Hierarchy

Expanded class hierarchy of RulesNodeConditionType

Related topics

File

modules/node.eval.inc, line 32
Contains rules integration for the node module needed during evaluation.

View source
class RulesNodeConditionType extends RulesNodeConditionBase {

  /**
   * Defines the condition.
   */
  public static function getInfo() {
    $info = self::defaults() + array(
      'name' => 'node_is_of_type',
      'label' => t('Content is of type'),
      'help' => t('Evaluates to TRUE if the given content is of one of the selected content types.'),
    );
    $info['parameter']['type'] = array(
      'type' => 'list<text>',
      'label' => t('Content types'),
      'options list' => 'node_type_get_names',
      'description' => t('The content type(s) to check for.'),
      'restriction' => 'input',
    );
    return $info;
  }

  /**
   * Executes the condition.
   */
  public function execute($node, $types) {
    return in_array($node->type, $types);
  }

  /**
   * Provides the content type of a node as asserted metadata.
   */
  public function assertions() {
    return array(
      'node' => array(
        'bundle' => $this->element->settings['type'],
      ),
    );
  }

}

Members

Namesort descending Modifiers Type Description Overrides
RulesNodeConditionBase::defaults public static function
RulesNodeConditionType::assertions public function Provides the content type of a node as asserted metadata. Overrides RulesPluginHandlerBase::assertions
RulesNodeConditionType::execute public function Executes the condition.
RulesNodeConditionType::getInfo public static function Defines the condition.
RulesPluginHandlerBase::$element protected property
RulesPluginHandlerBase::access public function Implements RulesPluginImplInterface::access(). Overrides RulesPluginHandlerInterface::access
RulesPluginHandlerBase::dependencies public function Returns an array of required modules. Overrides RulesPluginHandlerInterface::dependencies
RulesPluginHandlerBase::form_alter public function Alters the generated configuration form of the element. Overrides RulesPluginHandlerInterface::form_alter
RulesPluginHandlerBase::info_alter public function Allows altering of the element's action/condition info. Overrides RulesPluginHandlerInterface::info_alter
RulesPluginHandlerBase::process public function Processes settings independent from a form submission. Overrides RulesPluginHandlerInterface::process
RulesPluginHandlerBase::validate public function Validates $settings independent from a form submission. Overrides RulesPluginHandlerInterface::validate
RulesPluginHandlerBase::__construct public function Overridden to provide $this->element to make the code more meaningful.