public function convertByMethod() { if (!$this->method_id) { return false; } $methodArray = PaymentMethod::getMethodArray($this->method_id); if (!isset($methodArray['fields']) || !$methodArray['fields']) { return true; } foreach ($methodArray['fields'] as $fieldName => $array) { if (!isset($array['connectWithDB']['set']) || !$array['connectWithDB']['set']) { continue; } //Here can be inserted validation $set = $array['connectWithDB']['set']; if ($set['type'] == 'field' && isset($set['field'])) { $this->{$set}['field'] = $this->_data[$fieldName]; } elseif ($set['type'] == 'method' && isset($set['method']) && isset($set['method']['name'])) { if (method_exists($this, $set['method']['name'])) { $params = isset($set['method']['params']) && $set['method']['params'] ? $set['method']['params'] : array(); if ($params) { call_user_func_array(array($this, $set['method']['name']), $params); } else { $this->{$set}['method']['name'](); } } } } }