rules_test.module

Rules test module.

File

tests/rules_test.module

View source
<?php


/**
 * @file
 * Rules test module.
 */

/**
 * Implements hook_entity_property_info_alter() to add a property without
 * access.
 */
function rules_test_entity_property_info_alter(&$info) {
    $properties =& $info['site']['properties'];
    $properties['no_access_user'] = array(
        'label' => t("Logged in user"),
        'description' => t("The currently logged in user."),
        'getter callback' => 'entity_metadata_system_get_properties',
        'access callback' => 'rules_test_no_access',
        'type' => 'user',
    );
    $properties =& $info['node']['properties'];
    $properties['reference'] = array(
        'label' => t("Referenced entity"),
        'getter callback' => 'rules_test_get_referenced_entity',
        'type' => 'entity',
    );
    $properties['ref_nodes'] = array(
        'label' => t("Referenced nodes"),
        'getter callback' => 'rules_test_get_referenced_node',
        'type' => 'list<node>',
    );
}

/**
 * Getter callback to get the referenced-entity property.
 */
function rules_test_get_referenced_entity($node) {
    // For testing purposes we just return the node itself as property value.
    return entity_metadata_wrapper('node', $node);
}

/**
 * Getter callback to get the referenced-node list-property.
 */
function rules_test_get_referenced_node($node) {
    // For testing purposes we just return the node itself as property value.
    return array(
        $node->nid,
    );
}

/**
 * Access callback. Returns TRUE except when $op == 'edit'.
 */
function rules_test_no_access($op) {
    return $op == 'edit' ? FALSE : TRUE;
}

Functions

Title Deprecated Summary
rules_test_entity_property_info_alter Implements hook_entity_property_info_alter() to add a property without access.
rules_test_get_referenced_entity Getter callback to get the referenced-entity property.
rules_test_get_referenced_node Getter callback to get the referenced-node list-property.
rules_test_no_access Access callback. Returns TRUE except when $op == 'edit'.