You are here

class UcCouponMetadataController in Ubercart Discount Coupons 7.3

Metadata Controller for uc_coupon entity

Hierarchy

Expanded class hierarchy of UcCouponMetadataController

1 string reference to 'UcCouponMetadataController'
uc_coupon_entity_info in ./uc_coupon.module
Implements hook_entity_info();

File

./uc_coupon.entity.inc, line 215
Entity Controller and Metadata Controller classes for uc_coupon.

View source
class UcCouponMetadataController extends EntityDefaultMetadataController {
  public function entityPropertyInfo() {
    $prop_info = parent::entityPropertyInfo();
    $props =& $prop_info['uc_coupon']['properties'];

    //dpm($prop_info);

    // Copy the descriptions from the schema. Drupal discards this information, so we have to
    // call uc_order_schema() directly.
    module_load_include('install', 'uc_coupon', 'uc_coupon');
    $schema = uc_coupon_schema();
    foreach ($schema['uc_coupons']['fields'] as $name => $info) {
      if (is_array($props[$name]) && !empty($info['description'])) {
        $props[$name]['description'] = $info['description'];
      }
    }
    $props['type']['options list'] = '_uc_coupon_type_options';
    $props['status']['options list']['type'] = 'boolean';
    $props['bulk']['type'] = 'boolean';

    // Set the correct type for the date properties.
    foreach (array(
      'created',
      'valid_from',
      'valid_until',
    ) as $key) {
      $props[$key]['type'] = 'date';
      $props[$key]['getter callback'] = 'entity_property_verbatim_date_get';
    }

    // Unpack some of the 'data' properties.
    unset($props['data']);
    $props['products'] = array(
      'type' => 'list<node>',
      'label' => t('Products'),
      'description' => t('The applicable products for this coupon.'),
      'getter callback' => 'uc_coupon_data_property_get',
      'setter callback' => 'uc_coupon_data_property_set',
    );
    $props['negate_products'] = array(
      'type' => 'boolean',
      'label' => t('Negate applicable products'),
      'description' => t('Whether or not the products list represents allowed or disallowed products'),
      'getter callback' => 'uc_coupon_data_property_get',
      'setter callback' => 'uc_coupon_data_property_set',
    );
    $props['base_coupon'] = array(
      'type' => 'uc_coupon',
      'description' => t('The coupon on which a purchased or assigned coupon is based'),
      'label' => t('Base coupon'),
      'getter callback' => 'uc_coupon_data_property_get',
      'setter callback' => 'uc_coupon_data_property_set',
    );
    return $prop_info;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
EntityDefaultMetadataController::$type protected property
EntityDefaultMetadataController::bundleOptionsList public static function A options list callback returning all bundles for an entity type.
EntityDefaultMetadataController::convertSchema protected function Return a set of properties for an entity based on the schema definition
EntityDefaultMetadataController::__construct public function
UcCouponMetadataController::entityPropertyInfo public function Overrides EntityDefaultMetadataController::entityPropertyInfo