获得致命错误:在Open Cart Payment Module中调用未定义的方法Loader :: controller()?

时间:2014-10-09 05:33:14

标签: php opencart payment-gateway

我只是想将moneybookers支付模块克隆到Open Cart中的支付模块并猜测我现在被困在这里的错误如下:

Fatal error: Call to undefined method Loader::controller() in /home/hunter/public_html/opencart_new/admin/controller/payment/mpower.php on line 213

以下是完整的/home/hunter/public_html/opencart_new/admin/controller/payment/mpower.php文件:

<?php
class ControllerPaymentMPower extends Controller {
private $error = array();

public function index() {
    $this->load->language('payment/mpower');

    $this->document->setTitle($this->language->get('heading_title'));

    $this->load->model('setting/setting');

    if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validate()) {
        $this->model_setting_setting->editSetting('mpower', $this->request->post);

        $this->session->data['success'] = $this->language->get('text_success');

        $this->response->redirect($this->url->link('extension/payment', 'token=' . $this->session->data['token'], 'SSL'));
    }

    $data['heading_title'] = $this->language->get('heading_title');

    $data['text_edit'] = $this->language->get('text_edit');
    $data['text_enabled'] = $this->language->get('text_enabled');
    $data['text_disabled'] = $this->language->get('text_disabled');
    $data['text_all_zones'] = $this->language->get('text_all_zones');

    $data['entry_MasterKey'] = $this->language->get('entry_MasterKey');
    $data['entry_PublicKey'] = $this->language->get('entry_PublicKey');
    $data['entry_PrivateKey'] = $this->language->get('entry_PrivateKey');
    $data['entry_Mode'] = $this->language->get('entry_Mode');
    $data['entry_Token'] = $this->language->get('entry_Token');
    $data['entry_StoreName'] = $this->language->get('entry_StoreName');
    $data['entry_StoreTagline'] = $this->language->get('entry_StoreTagline');
    $data['entry_PhoneNumber'] = $this->language->get('entry_PhoneNumber');
    $data['entry_PostalAddress'] = $this->language->get('entry_PostalAddress');
    $data['entry_total'] = $this->language->get('entry_total');
    $data['entry_order_status'] = $this->language->get('entry_order_status');
    $data['entry_pending_status'] = $this->language->get('entry_pending_status');
    $data['entry_canceled_status'] = $this->language->get('entry_canceled_status');
    $data['entry_failed_status'] = $this->language->get('entry_failed_status');
    $data['entry_chargeback_status'] = $this->language->get('entry_chargeback_status');
    $data['entry_geo_zone'] = $this->language->get('entry_geo_zone');
    $data['entry_status'] = $this->language->get('entry_status');
    $data['entry_sort_order'] = $this->language->get('entry_sort_order');
    $data['entry_custnote'] = $this->language->get('entry_custnote');

    $data['help_total'] = $this->language->get('help_total');

    $data['button_save'] = $this->language->get('button_save');
    $data['button_cancel'] = $this->language->get('button_cancel');

    if (isset($this->error['warning'])) {
        $data['error_warning'] = $this->error['warning'];
    } else {
        $data['error_warning'] = '';
    }

    if (isset($this->error['email'])) {
        $data['error_email'] = $this->error['email'];
    } else {
        $data['error_email'] = '';
    }

    $data['breadcrumbs'] = array();

    $data['breadcrumbs'][] = array(
        'text' => $this->language->get('text_home'),
        'href' => $this->url->link('common/dashboard', 'token=' . $this->session->data['token'], 'SSL')
    );

    $data['breadcrumbs'][] = array(
        'text' => $this->language->get('text_payment'),
        'href' => $this->url->link('extension/payment', 'token=' . $this->session->data['token'], 'SSL')
    );

    $data['breadcrumbs'][] = array(
        'text' => $this->language->get('heading_title'),
        'href' => $this->url->link('payment/mpower', 'token=' . $this->session->data['token'], 'SSL')
    );

    $data['action'] = $this->url->link('payment/mpower', 'token=' . $this->session->data['token'], 'SSL');

    $data['cancel'] = $this->url->link('extension/payment', 'token=' . $this->session->data['token'], 'SSL');

    if (isset($this->request->post['mpower_MasterKey'])) {
        $data['mpower_MasterKey'] = $this->request->post['mpower_MasterKey'];
    } else {
        $data['mpower_MasterKey'] = $this->config->get('mpower_MasterKey');
    }

    if (isset($this->request->post['mpower_PublicKey'])) {
        $data['mpower_PublicKey'] = $this->request->post['mpower_PublicKey'];
    } else {
        $data['mpower_PublicKey'] = $this->config->get('mpower_PublicKey');
    }

    if (isset($this->request->post['mpower_PrivateKey'])) {
        $data['mpower_PrivateKey'] = $this->request->post['mpower_PrivateKey'];
    } else {
        $data['mpower_PrivateKey'] = $this->config->get('mpower_PrivateKey');
    }

    if (isset($this->request->post['mpower_Token'])) {
        $data['mpower_Token'] = $this->request->post['mpower_Token'];
    } else {
        $data['mpower_Token'] = $this->config->get('mpower_Token');
    }

    if (isset($this->request->post['mpower_mode'])) {
        $data['mpower_mode'] = $this->request->post['mpower_mode'];
    } else {
        $data['mpower_mode'] = $this->config->get('mpower_mode');
    }

    if (isset($this->request->post['mpower_StoreName'])) {
        $data['mpower_StoreName'] = $this->request->post['mpower_StoreName'];
    } else {
        $data['mpower_StoreName'] = $this->config->get('mpower_StoreName');
    }

    if (isset($this->request->post['mpower_StoreTagline'])) {
        $data['mpower_StoreTagline'] = $this->request->post['mpower_StoreTagline'];
    } else {
        $data['mpower_StoreTagline'] = $this->config->get('mpower_StoreTagline');
    }

    if (isset($this->request->post['mpower_PhoneNumber'])) {
        $data['mpower_PhoneNumber'] = $this->request->post['mpower_PhoneNumber'];
    } else {
        $data['mpower_PhoneNumber'] = $this->config->get('mpower_PhoneNumber');
    }

    if (isset($this->request->post['mpower_PostalAddress'])) {
        $data['mpower_PostalAddress'] = $this->request->post['mpower_PostalAddress'];
    } else {
        $data['mpower_PostalAddress'] = $this->config->get('mpower_PostalAddress');
    }

    if (isset($this->request->post['mpower_total'])) {
        $data['mpower_total'] = $this->request->post['mpower_total'];
    } else {
        $data['mpower_total'] = $this->config->get('mpower_total');
    }

    if (isset($this->request->post['mpower_order_status_id'])) {
        $data['mpower_order_status_id'] = $this->request->post['mpower_order_status_id'];
    } else {
        $data['mpower_order_status_id'] = $this->config->get('mpower_order_status_id');
    }

    if (isset($this->request->post['mpower_pending_status_id'])) {
        $data['mpower_pending_status_id'] = $this->request->post['mpower_pending_status_id'];
    } else {
        $data['mpower_pending_status_id'] = $this->config->get('mpower_pending_status_id');
    }

    if (isset($this->request->post['mpower_canceled_status_id'])) {
        $data['mpower_canceled_status_id'] = $this->request->post['mpower_canceled_status_id'];
    } else {
        $data['mpower_canceled_status_id'] = $this->config->get('mpower_canceled_status_id');
    }

    if (isset($this->request->post['mpower_failed_status_id'])) {
        $data['mpower_failed_status_id'] = $this->request->post['mpower_failed_status_id'];
    } else {
        $data['mpower_failed_status_id'] = $this->config->get('mpower_failed_status_id');
    }

    if (isset($this->request->post['mpower_chargeback_status_id'])) {
        $data['mpower_chargeback_status_id'] = $this->request->post['mpower_chargeback_status_id'];
    } else {
        $data['mpower_chargeback_status_id'] = $this->config->get('mpower_chargeback_status_id');
    }

    $this->load->model('localisation/order_status');

    $data['order_statuses'] = $this->model_localisation_order_status->getOrderStatuses();

    if (isset($this->request->post['mpower_geo_zone_id'])) {
        $data['mpower_geo_zone_id'] = $this->request->post['mpower_geo_zone_id'];
    } else {
        $data['mpower_geo_zone_id'] = $this->config->get('mpower_geo_zone_id');
    }

    $this->load->model('localisation/geo_zone');

    $data['geo_zones'] = $this->model_localisation_geo_zone->getGeoZones();

    if (isset($this->request->post['mpower_status'])) {
        $data['mpower_status'] = $this->request->post['mpower_status'];
    } else {
        $data['mpower_status'] = $this->config->get('mpower_status');
    }

    if (isset($this->request->post['mpower_sort_order'])) {
        $data['mpower_sort_order'] = $this->request->post['mpower_sort_order'];
    } else {
        $data['mpower_sort_order'] = $this->config->get('mpower_sort_order');
    }

    if (isset($this->request->post['mpower_rid'])) {
        $data['mpower_rid'] = $this->request->post['mpower_rid'];
    } else {
        $data['mpower_rid'] = $this->config->get('mpower_rid');
    }

    if (isset($this->request->post['mpower_custnote'])) {
        $data['mpower_custnote'] = $this->request->post['mpower_custnote'];
    } else {
        $data['mpower_custnote'] = $this->config->get('mpower_custnote');
    }

    $data['header'] = $this->load->controller('common/header');
    $data['column_left'] = $this->load->controller('common/column_left');
    $data['footer'] = $this->load->controller('common/footer');

    $this->response->setOutput($this->load->view('payment/mpower.tpl', $data));
  }

  protected function validate() {
    if (!$this->user->hasPermission('modify', 'payment/mpower')) {
        $this->error['warning'] = $this->language->get('error_permission');
    }

    if (!$this->request->post['mpower_MasterKey']) {
        $this->error['MasterKey'] = $this->language->get('error_MasterKey');
    }

    if (!$this->request->post['mpower_PublicKey']) {
        $this->error['PublicKey'] = $this->language->get('error_PublicKey');
    }

    if (!$this->request->post['mpower_PrivateKey']) {
        $this->error['PrivateKey'] = $this->language->get('error_PrivateKey');
    }

    if (!$this->request->post['mpower_Token']) {
        $this->error['Token'] = $this->language->get('error_Token');
    }

    return !$this->error;
    }
}

第213行是:

$data['header'] = $this->load->controller('common/header');

我还没有完全开发模块,但差不多完成了付款模块的管理员方面,但是它给出了错误,所以如果有人可以请一看,让我知道我做错了什么?

2 个答案:

答案 0 :(得分:1)

以下是第213行之后的代码:

替换此代码:

$data['header'] = $this->load->controller('common/header');
$data['column_left'] = $this->load->controller('common/column_left');
$data['footer'] = $this->load->controller('common/footer');

$this->response->setOutput($this->load->view('payment/mpower.tpl', $data));

使用

$this->template = 'payment/mpower.tpl';
    $this->children = array(
        'common/header',
        'common/column_left',
        'common/footer'
    );

    $this->response->setOutput($this->render());

无需为页眉,页脚等调用控制器。

并且无需在$data中传递setOutput,当您在浏览器中加载支付网关链接时,它会自动传入您的视图文件,因为默认情况下它会调用您的索引方法。

答案 1 :(得分:1)

我遇到了同样的问题,发现我在opencart版本2.0.X.X中使用了1.5.X.X模块。您可能只是使用了错误的模块版本。