You are here

public function UcCouponMetadataController::entityPropertyInfo in Ubercart Discount Coupons 7.3

Overrides EntityDefaultMetadataController::entityPropertyInfo

File

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

Class

UcCouponMetadataController
Metadata Controller for uc_coupon entity

Code

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;
}