You are here

function payment_method_controller_load_multiple in Payment 7

Load multiple payment method controllers.

Parameters

array $controller_class_names: An array with names of controller classes. Leave empty to load all controllers.

Return value

array Keys are the values of $controller_class_names passed on to this function. Every value is either a PaymentMethodController object or FALSE if the controller could not be loaded.

5 calls to payment_method_controller_load_multiple()
payment_method_controller_load in ./payment.module
Load a payment method controller().
payment_method_controller_options in ./payment.ui.inc
Return payment method controllers for use in form elements.
payment_page_payment_method_add_select_controller in ./payment.ui.inc
Shows a page with controllers payment methods can be added for.
payment_page_payment_method_add_select_controller_access in ./payment.ui.inc
Menu access callback for payment_page_payment_method_add_select_controller().
payment_permission in ./payment.module
Implements hook_permission().

File

./payment.module, line 860
Hook implementations and shared functions.

Code

function payment_method_controller_load_multiple(array $controller_class_names = array()) {
  $controllers = NULL;

  // Load all existing controllers.
  if (is_null($controllers)) {
    foreach (payment_method_controllers_info() as $controller_class_name_alias => $controller_class_name) {
      $controller = new $controller_class_name();
      $controller->name = $controller_class_name_alias;
      $controllers[$controller_class_name_alias] = $controller;
    }
  }

  // Set FALSE for requested controllers that do not exist.
  $controllers += array_fill_keys(array_diff($controller_class_names, array_keys($controllers)), FALSE);
  return $controller_class_names ? array_intersect_key($controllers, array_flip($controller_class_names)) : array_filter($controllers);
}