Example #1
0
 public function __get($name)
 {
     if (isset($this->_data['method_id']) && $this->_data['method_id'] && !(isset($this->_data[$name]) || !empty($this->_data[$name]))) {
         $connectWithDB = PaymentMethod::fieldConnectWithDB($this->_data['method_id'], $name);
         if (isset($connectWithDB['get']['type']) && $connectWithDB['get']['type']) {
             $get = $connectWithDB['get'];
             if ($get['type'] == 'field' && isset($get['field']) && $get['field']) {
                 $this->_data[$name] = $this->{$get}['field'];
             } elseif ($get['type'] == 'method' && isset($get['method']['name']) && $get['method']['name']) {
                 if (method_exists($this, $get['method']['name'])) {
                     $params = isset($get['method']['params']) && $get['method']['params'] ? $get['method']['params'] : array();
                     if ($params) {
                         $response = call_user_func_array(array($this, $get['method']['name']), $params);
                     } else {
                         $response = $this->{$get}['method']['name']();
                     }
                     $this->_data[$name] = $response;
                 }
             }
         }
     }
     return parent::__get($name);
 }