You are here

function rules_condition_data_is_empty in Rules 7.2

Condition: Data value is empty.

Related topics

1 string reference to 'rules_condition_data_is_empty'
rules_data_condition_info in modules/data.rules.inc
Implements hook_rules_condition_info() on behalf of the pseudo data module.

File

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

Code

function rules_condition_data_is_empty($data) {

  // Note that some primitive variables might not be wrapped at all.
  if ($data instanceof EntityMetadataWrapper) {
    try {

      // We cannot use the dataAvailable() method from the wrapper because it
      // is protected, so we catch possible exceptions with the value() method.
      $value = $data
        ->value();
      return empty($value);
    } catch (EntityMetadataWrapperException $e) {

      // An exception means that the wrapper is somehow broken and we treat
      // that as empty.
      return TRUE;
    }
  }
  return empty($data);
}