首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >第164行的engine/Library/Enlight/Hook/ProxyFactory.php中不存在类Shopware_Controllers_Backend_MytestPaymentServices

第164行的engine/Library/Enlight/Hook/ProxyFactory.php中不存在类Shopware_Controllers_Backend_MytestPaymentServices
EN

Stack Overflow用户
提问于 2020-05-10 18:46:55
回答 1查看 131关注 0票数 0

我正在尝试实现一个测试按钮作为参考here

这是我的服务文件

代码语言:javascript
复制
<?xml version="1.0" ?>

<container xmlns="http://symfony.com/schema/dic/services"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">

    <services>
        <service id="mytest_payment.mytest_payment_controllers_backend_mytest_payment_services" class="MytestPayment\Controllers\Backend\MytestPaymentServices">
            <argument type="service" id="http_client"/>
            <argument type="service" id="MytestPayment.logger" />
            <tag name="shopware.controller" module="backend" controller="MytestPayment\Controllers\Backend\MytestPaymentServices"/>
        </service>
    </services>

</container>

MytestPaymentServices.php

代码语言:javascript
复制
<?php


namespace MytestPayment\Controllers\Backend;

use Monolog\Logger;
use Shopware\Components\HttpClient\HttpClientInterface;
use Shopware\Components\HttpClient\RequestException;
use Symfony\Component\HttpFoundation\Response;

 class MytestPaymentServices extends \Shopware_Controllers_Backend_ExtJs
{
    private const EXTERNAL_API_BASE_URL = 'https://www.dom.com/api';
    /**
     * @var HttpClientInterface
     */
    private $client;

    /**
     * @var Logger
     */
    private $logger;

    public function __construct(HttpClientInterface $client, Logger $logger)
    {
        $this->client = $client;
        $this->logger = $logger;

        parent::__construct();
    }

    public function testAction()
    {
        try {
            $response = $this->client->get(self::EXTERNAL_API_BASE_URL);

            if ((int) $response->getStatusCode() === Response::HTTP_OK) {
                $this->View()->assign('response', 'Success!');
            } else {
                $this->View()->assign('response', 'Oh no! Something went wrong :(');
            }
        } catch (RequestException $exception) {
            $this->logger->addError($exception->getMessage());

            $this->response->setStatusCode(Response::HTTP_INTERNAL_SERVER_ERROR);
            $this->View()->assign('response', $exception->getMessage());
        }
    }
}

但是我得到了以下错误

Class Shopware_Controllers_Backend_MytestPaymentServices does not exist in engine/Library/Enlight/Hook/ProxyFactory.php on line 164

EN

回答 1

Stack Overflow用户

发布于 2020-05-22 15:32:36

“控制器”文件夹是为旧的控制器系统保留的。只需将你的文件夹命名为"Controller“,它就可以工作了

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/61710727

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档