You are here

function pay::__construct in Pay 7

Same name and namespace in other branches
  1. 6 includes/handlers/pay.inc \pay::__construct()
3 calls to pay::__construct()
pay::save in includes/handlers/pay.inc
pay_method_direct::form_submit in includes/handlers/pay_method_direct.inc
pay_method_direct::response_action in includes/handlers/pay_method_direct.inc
Implement a 'response' action, which interprets the response from a direct payment gateway.

File

includes/handlers/pay.inc, line 18
The base class for the Payment API.

Class

pay
@file The base class for the Payment API.

Code

function __construct($values = NULL) {
  $current = (array) $this;
  if ($values) {
    foreach ((array) $values as $name => $val) {
      if ($name == 'settings' && !empty($val) && is_scalar($val)) {
        $this
          ->__construct(unserialize($val));
      }
      elseif (array_key_exists($name, $current) && !is_null($val)) {
        $func = 'set_' . $name;
        if (method_exists($this, $func)) {
          $this
            ->{$func}($val);
        }
        else {
          $this->{$name} = $val;
        }
        unset($current[$name]);
      }
    }
  }

  // Set defaults if possible.
  foreach ($current as $name => $val) {
    $func = 'set_' . $name;
    if (method_exists($this, $func)) {
      $this
        ->{$func}($this->{$name});
    }
  }
}