Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Spend More Time Surfing: Custom Entities & Enti...

Spend More Time Surfing: Custom Entities & Entity Tools

Mark Dorison

March 28, 2015
Tweet

More Decks by Mark Dorison

Other Decks in Technology

Transcript

  1. OOP

  2. /** * Implements hook_entity_info(). */ function gc_reservation_entity_info() { return array(

    'gc_reservation' => array( 'label' => t('Reservation'), 'plural label' => t('Reservations'), 'entity class' => 'GCReservation', 'controller class' => 'GCReservationController', 'base table' => 'gc_reservation', 'entity cache' => TRUE, 'entity keys' => array( 'id' => 'id', 'label' => 'id', ), 'label callback' => 'entity_class_label', 'uri callback' => 'gc_reservation_reservation_uri', 'fieldable' => TRUE, 'bundles' => array( 'gc_reservation' => array( 'label' => t('Reservation'), 'admin' => array( 'path' => 'admin/structure/reservations', 'access arguments' => array('administer reservation settings'), ), ), ), 'access callback' => 'gc_reservation_reservation_access', 'module' => 'gc_reservation', 'admin ui' => array( 'path' => 'admin/content/reservations', 'file' => 'gc_reservation.admin.inc', 'controller class' => 'GCReservationUIController', ), ), ); }
  3. $query = db_select('gc_reservation', 'gcr') ->fields('gcr', array('id')) ->condition('gcr.created', $created_limit, '>') ->condition('gcr.status',

    1, '='); $query->innerJoin('field_reservation_type', 'rt', 'gcr.id = frt.entity_id'); $query->condition('frt.field_reservation_type_value', 'booking', '='); $result = $query->execute();
  4. $query = new EntityFieldQuery(); $results = $query->entityCondition('entity_type', 'gc_reservation') ->fieldCondition('field_reservation_type', 'value',

    'booking') ->propertyCondition('created', $created_limit, '<') ->propertyCondition('status', 1) ->addMetaData('account', user_load(1)); ->execute();
  5. $query = new EntityFieldQuery(); $results = $query->entityCondition('entity_type', 'gc_reservation') ->fieldCondition('field_reservation_type', 'value',

    'booking') ->propertyCondition('created', $created_limit, '<') ->propertyCondition('status', 1) ->addMetaData('account', user_load(1)); ->execute();
  6. $query = new EntityFieldQuery(); $results = $query->entityCondition('entity_type', 'gc_reservation') ->fieldCondition('field_reservation_type', 'value',

    'booking') ->propertyCondition('created', $created_limit, '<') ->propertyCondition('status', 1) ->addMetaData('account', user_load(1)); ->execute();
  7. $query = new EntityFieldQuery(); $results = $query->entityCondition('entity_type', 'gc_reservation') ->fieldCondition('field_reservation_type', 'value',

    'booking') ->propertyCondition('created', $created_limit, '<') ->propertyCondition('status', 1) ->execute();
  8. EMW