You are here

class CommerceFileLicenseEntityRulesController in Commerce File 7

Default controller for generating Rules integration.

Hierarchy

Expanded class hierarchy of CommerceFileLicenseEntityRulesController

1 string reference to 'CommerceFileLicenseEntityRulesController'
commerce_file_entity_info in ./commerce_file.module
Implements hook_entity_info().

File

./commerce_file.rules.inc, line 15
Provides Rules integration for entities provided via the CRUD API.

View source
class CommerceFileLicenseEntityRulesController extends EntityDefaultRulesController {
  protected $type, $info;
  public function __construct($type = NULL) {
    parent::__construct(COMMERCE_FILE_LICENSE_ENTITY_NAME);
  }
  public function eventInfo() {
    $info = $this->info;
    $type = $this->type;
    $label = $info['label'];
    $tokens = array(
      '@entity' => drupal_strtolower($label),
    );
    $defaults = array(
      'module' => isset($info['module']) ? $info['module'] : 'entity',
      'group' => $label,
      'access callback' => 'entity_rules_integration_event_access',
    );

    // intialize with standard events
    $items = parent::eventInfo();

    // Update event - add an unchanged variable
    $items[$type . '_update']['variables']["{$type}_unchanged"] = array(
      'type' => $type,
      'label' => t('Unchanged @entity', $tokens),
      'skip save' => TRUE,
      'handler' => 'rules_events_entity_unchanged',
    );

    // File download event
    $items[$type . '_download'] = $defaults + array(
      'label' => t('Requesting a download for a licensed file', $tokens),
      'variables' => array(
        $type => array(
          'type' => $type,
          'label' => t('active @entity', $tokens),
        ),
      ),
    );

    // Access denied event
    $items[$type . '_access_denied'] = $defaults + array(
      'label' => t('Before denying access to a licensed file', $tokens),
      'variables' => array(
        $type => array(
          'type' => $type,
          'label' => t('active @entity', $tokens),
        ),
      ),
    );

    // Log file download event
    $items[$type . '_log_download'] = $defaults + array(
      'label' => t('Logging access to a licensed file', $tokens),
      'variables' => array(
        $type => array(
          'type' => $type,
          'label' => t('active @entity', $tokens),
        ),
      ),
    );
    return $items;
  }

}

Members