【发布时间】:2021-10-27 07:43:17
【问题描述】:
我正在使用 Magento 2.4 自定义错误 404 提供的错误,如果有人对此有任何想法:
Error: Call to a member function get() on null in C:\xampp-clean\htdocs\magento242\vendor\magento\framework\App\Action\Action.php:109 Stack trace: #0 C:\xampp-clean\htdocs\magento242\vendor\magento\framework\App\FrontController.php(186): Magento\Framework\App\Action\Action->dispatch(Object(Magento\Framework\App\Request\Http)) #1 C:\xampp-clean\htdocs\magento242\vendor\magento\framework\App\FrontController.php(118): Magento\Framework\App\FrontController->processRequest(Object(Magento\Framework\App\Request\Http), Object(SimplifiedMagento\RequestFlow\Controller\Page\CustomNoRoute\Interceptor))
这是函数(控制器)
<?php
namespace SimplifiedMagento\RequestFlow\Controller\Page;
use Magento\Framework\App\Action\Action;
use Magento\Framework\App\ResponseInterface;
class CustomNoRoute extends Action
{
public function execute()
{
echo "this is our custom 404";
}
}
把代码改成这个后
<?php
namespace SimplifiedMagento\RequestFlow\Controller\Page;
use Magento\Framework\App\ActionInterface;
use Magento\Framework\App\ResponseInterface;
class CustomNoRoute implements ActionInterface
{
public function execute()
{
echo "this is our custom 404";
}
}
我得到了这个结果:
this is our custom 4041 exception(s):
Exception #0 (InvalidArgumentException): Invalid return type
Exception #0 (InvalidArgumentException): Invalid return type
<pre>#1 Magento\Framework\App\Http\Interceptor->launch() called at [vendor\magento\framework\App\Bootstrap.php:263]
#2 Magento\Framework\App\Bootstrap->run() called at [pub\index.php:29]
</pre>
所以至少它是在呼应结果;但仍然显示异常错误。
如果有人有想法? 提前致谢
【问题讨论】:
标签: php zend-framework magento2 magento2.4