You are here

function paymentmethodbasic_entity_load in Payment 7

Implements hook_entity_load().

File

modules/paymentmethodbasic/paymentmethodbasic.module, line 18
Hook implementations and shared functions.

Code

function paymentmethodbasic_entity_load(array $entities, $entity_type) {
  if ($entity_type == 'payment_method') {
    $pmids = array();
    foreach ($entities as $payment_method) {
      if ($payment_method->controller->name == 'PaymentMethodBasicController') {
        $pmids[] = $payment_method->pmid;
      }
    }
    if ($pmids) {
      $query = db_select('paymentmethodbasic')
        ->fields('paymentmethodbasic')
        ->condition('pmid', $pmids);
      $result = $query
        ->execute();
      while ($data = $result
        ->fetchAssoc()) {
        $payment_method = $entities[$data['pmid']];
        $payment_method->controller_data = (array) $data;
        unset($payment_method->controller_data['pmid']);
      }
    }
  }
}