OpenCart 3. Fix Fatal error: Uncaught Error: Class 'Controllerextensionpaymentgcash' not found in storage\modification\system\engine\action.php:71

OpenCart 3. Fix Fatal error: Uncaught Error: Class 'Controllerextensionpaymentgcash' not found in storage\modification\system\engine\action.php:71

我正在我的 OpenCart 3.0.3.3 上创建新的扩展支付网关 GCash。我复制现有的银行转帐概念。但是一旦我安装了新的扩展,我就遇到了错误。

Fatal error: Uncaught Error: Class 'Controllerextensionpaymentgcash' not found in C:\xampp\storage\chaguan\storage\modification\system\engine\action.php:71 Stack trace: #0 C:\xampp\storage\chaguan\storage\modification\system\engine\loader.php(48): Action->execute(Object(Registry), Array) #1 C:\xampp\htdocs\chaguan2\admin\controller\extension\extension\payment.php(27): Loader->controller('extension/payme...') #2 C:\xampp\storage\chaguan\storage\modification\system\engine\action.php(79): ControllerExtensionExtensionPayment->install() #3 C:\xampp\htdocs\chaguan2\admin\controller\startup\router.php(26): Action->execute(Object(Registry), Array) #4 C:\xampp\storage\chaguan\storage\modification\system\engine\action.php(79): ControllerStartupRouter->index() #5 C:\xampp\htdocs\chaguan2\system\engine\router.php(67): Action->execute(Object(Registry)) #6 C:\xampp\htdocs\chaguan2\system\engine\router.php(56): Router->execute(Object(Action)) #7 C:\xampp\htdocs\chaguan2\system\framework.php(165): Router->dispatch(Object(Action), Object( in C:\xampp\storage\chaguan\storage\modification\system\engine\action.php on line 71

如何解决以下错误?

作为参考,这是我的代码:

控制器 路径:

admin\controller\extension\payment\gcash.php

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

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

        $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('payment_gcash', $this->request->post);

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

            $this->response->redirect($this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=payment', true));
        }

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

        if (isset($this->error['bank'])) {
            $data['error_bank'] = $this->error['bank'];
        } else {
            $data['error_bank'] = array();
        }

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

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

        $data['breadcrumbs'][] = array(
            'text' => $this->language->get('text_extension'),
            'href' => $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=payment', true)
        );

        $data['breadcrumbs'][] = array(
            'text' => $this->language->get('heading_title'),
            'href' => $this->url->link('extension/payment/gcash', 'user_token=' . $this->session->data['user_token'], true)
        );

        $data['action'] = $this->url->link('extension/payment/gcash', 'user_token=' . $this->session->data['user_token'], true);

        $data['cancel'] = $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=payment', true);

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

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

        $languages = $this->model_localisation_language->getLanguages();
        
        foreach ($languages as $language) {
            if (isset($this->request->post['payment_gcash_info' . $language['language_id']])) {
                $data['payment_gcash_info'][$language['language_id']] = $this->request->post['payment_gcash_info' . $language['language_id']];
            } else {
                $data['payment_gcash_info'][$language['language_id']] = $this->config->get('payment_gcash_info' . $language['language_id']);
            }
        }

        $data['languages'] = $languages;

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

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

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

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

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

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

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

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

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

        $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('extension/payment/gcash', $data));
    }

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

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

        $languages = $this->model_localisation_language->getLanguages();

        foreach ($languages as $language) {
            if (empty($this->request->post['payment_gcash_info' . $language['language_id']])) {
                $this->error['bank'][$language['language_id']] = $this->language->get('error_bank');
            }
        }

        return !$this->error;
    }
}

查看

路径: admin\view\template\extension\payment\gcash.twig

<div id="content">
  <div class="page-header">
    <div class="container-fluid">
      <div class="pull-right">
        <button type="submit" form="form-payment" data-toggle="tooltip" title="{{ button_save }}" class="btn btn-primary"><i class="fa fa-save"></i></button>
        <a href="{{ cancel }}" data-toggle="tooltip" title="{{ button_cancel }}" class="btn btn-default"><i class="fa fa-reply"></i></a></div>
      <h1>{{ heading_title }}</h1>
      <ul class="breadcrumb">
        {% for breadcrumb in breadcrumbs %}
        <li><a href="{{ breadcrumb.href }}">{{ breadcrumb.text }}</a></li>
        {% endfor %}
      </ul>
    </div>
  </div>
  <div class="container-fluid">
    {% if error_warning %}
    <div class="alert alert-danger alert-dismissible"><i class="fa fa-exclamation-circle"></i> {{ error_warning }}
      <button type="button" class="close" data-dismiss="alert">&times;</button>
    </div>
    {% endif %}
    <div class="panel panel-default">
      <div class="panel-heading">
        <h3 class="panel-title"><i class="fa fa-pencil"></i> {{ text_edit }}</h3>
      </div>
      <div class="panel-body">
        <form action="{{ action }}" method="post" enctype="multipart/form-data" id="form-payment" class="form-horizontal">
          {% for language in languages %}
          <div class="form-group required">
            <label class="col-sm-2 control-label" for="input-gcash{{ language.language_id }}">{{ entry_gcash }}</label>
            <div class="col-sm-10">
              <div class="input-group"><span class="input-group-addon"><img src="language/{{ language.code }}/{{ language.code }}.png" title="{{ language.name }}" /></span>
                <textarea name="payment_entry_gcash_info{{ language.language_id }}" cols="80" rows="10" placeholder="{{ entry_gcash }}" id="input-gcash{{ language.language_id }}" class="form-control">{% if payment_entry_gcash_info[language.language_id] %}{{ payment_entry_gcash_info[language.language_id] }}{% endif %}</textarea>
              </div>
              {% if error_gcash[language.language_id] %}
              <div class="text-danger">{{ error_gcash[language.language_id] }}</div>
              {% endif %}
            </div>
          </div>
          {% endfor %}
          <div class="form-group">
            <label class="col-sm-2 control-label" for="input-total"><span data-toggle="tooltip" title="{{ help_total }}">{{ entry_total }}</span></label>
            <div class="col-sm-10">
              <input type="text" name="payment_gcash_total" value="{{ payment_gcash_total }}" placeholder="{{ entry_total }}" id="input-total" class="form-control" />
            </div>
          </div>
          <div class="form-group">
            <label class="col-sm-2 control-label" for="input-order-status">{{ entry_order_status }}</label>
            <div class="col-sm-10">
              <select name="payment_gcash_order_status_id" id="input-order-status" class="form-control">
                {% for order_status in order_statuses %}
                {% if order_status.order_status_id == payment_gcash_order_status_id %}
                <option value="{{ order_status.order_status_id }}" selected="selected">{{ order_status.name }}</option>
                {% else %}
                <option value="{{ order_status.order_status_id }}">{{ order_status.name }}</option>
                {% endif %}
                {% endfor %}
              </select>
            </div>
          </div>
          <div class="form-group">
            <label class="col-sm-2 control-label" for="input-geo-zone">{{ entry_geo_zone }}</label>
            <div class="col-sm-10">
              <select name="payment_gcash_geo_zone_id" id="input-geo-zone" class="form-control">
                <option value="0">{{ text_all_zones }}</option>
                {% for geo_zone in geo_zones %}
                {% if geo_zone.geo_zone_id == payment_gcash_geo_zone_id %}
                <option value="{{ geo_zone.geo_zone_id }}" selected="selected">{{ geo_zone.name }}</option>
                {% else %}
                <option value="{{ geo_zone.geo_zone_id }}">{{ geo_zone.name }}</option>
                {% endif %}
                {% endfor %}
              </select>
            </div>
          </div>
          <div class="form-group">
            <label class="col-sm-2 control-label" for="input-status">{{ entry_status }}</label>
            <div class="col-sm-10">
              <select name="payment_gcash_status" id="input-status" class="form-control">
                {% if payment_gcash_status %}
                <option value="1" selected="selected">{{ text_enabled }}</option>
                <option value="0">{{ text_disabled }}</option>
                {% else %}
                <option value="1">{{ text_enabled }}</option>
                <option value="0" selected="selected">{{ text_disabled }}</option>
                {% endif %}
              </select>
            </div>
          </div>
          <div class="form-group">
            <label class="col-sm-2 control-label" for="input-sort-order">{{ entry_sort_order }}</label>
            <div class="col-sm-10">
              <input type="text" name="payment_gcash_sort_order" value="{{ payment_gcash_sort_order }}" placeholder="{{ entry_sort_order }}" id="input-sort-order" class="form-control" />
            </div>
          </div>
        </form>
      </div>
    </div>
  </div>
</div>

语言

路径:admin\language\en-gb\extension\payment\gcash.php

<?php
// Heading
$_['heading_title']      = 'GCash';

// Text
$_['text_extension']     = 'Extensions';
$_['text_success']       = 'Success: You have modified GCash details!';
$_['text_edit']          = 'Edit GCash';

// Entry
$_['entry_gcash']        = 'GCash Instructions';
$_['entry_total']        = 'Total';
$_['entry_order_status'] = 'Order Status';
$_['entry_geo_zone']     = 'Geo Zone';
$_['entry_status']       = 'Status';
$_['entry_sort_order']   = 'Sort Order';

// Help
$_['help_total']         = 'The checkout total the order must reach before this payment method becomes active.'; 

// Error 
$_['error_permission']   = 'Warning: You do not have permission to modify payment GCash!';
$_['error_gcash']        = 'GCash Instructions Required!';

admin\controller\extension\payment\gcash.php

替换

class ControllerExtensionGCash extends Controller {

class ControllerExtensionPaymentGCash extends Controller {

OpenCart 在安装时寻找的控制器类型 class 名称。