function PaymentMethodEntityController::load in Payment 7
Overridden to support passing numeric ids as well as names as $ids.
Overrides EntityAPIControllerExportable::load
File
- ./
payment.classes.inc, line 635 - The API and related functions for executing and managing payments.
Class
- PaymentMethodEntityController
- Entity API controller for payment_method entities.
Code
function load($ids = array(), $conditions = array()) {
static $unavailable = NULL;
$entities = parent::load($ids, $conditions);
foreach ($entities as $payment_method) {
// Cast non-string scalars to their original types, because some backends
// store/return all variables as strings.
$payment_method->enabled = (bool) $payment_method->enabled;
$payment_method->pmid = (int) $payment_method->pmid;
$payment_method->status = (int) $payment_method->status;
$payment_method->uid = (int) $payment_method->uid;
}
// Load PaymentMethodUnavailable for all requested IDs that did not match
// any existing payment methods.
if (is_array($ids)) {
// If the entities were loaded by PID.
if (is_numeric(reset($ids))) {
$diff = array_diff($ids, array_keys($entities));
}
else {
$names = array();
foreach ($entities as $entity) {
$names[] = $entity->name;
}
$diff = array_diff($ids, $names);
}
if ($diff && is_null($unavailable)) {
$unavailable = new PaymentMethodUnavailable();
}
foreach ($diff as $pmid) {
$entities[$pmid] = $unavailable;
}
ksort($entities);
}
return $entities;
}