我正在开发magento2中的模块 . 问题在于路由 - 路由器返回$ this-> actionFactory-> create('Magento \ Framework \ App \ Action \ Forward');不会重定向到我的模块,控制器和代码中指定的操作;它会导致异常前控制器达到100路由器匹配迭代 . 任何帮助都将受到高度赞赏 . 谢谢提前!
public function match(\Magento\Framework\App\RequestInterface $request)
{
$identifier = trim($request->getPathInfo(), '/');
$condition = new \Magento\Framework\DataObject(['identifier' => $identifier, 'continue' => true]);
$this->eventManager->dispatch(
'news_controller_router_match_before',
['router' => $this, 'condition' => $condition]
);
$identifier = $condition->getIdentifier();
if ($condition->getRedirectUrl()) {
$this->response->setRedirect($condition->getRedirectUrl());
$request->setDispatched(true);
return $this->actionFactory->create('Magento\Framework\App\Action\Redirect');
}
if (!$condition->getContinue()) {
return null;
}
/*for main page */
/*check identifier against news-configuration main page idendifier */
//$mainIdentifier = $topic->getMainPageIdentifer();
$mainIdentifier = 'news';
if ($mainIdentifier == $identifier) {
$request->setModuleName('news')->setControllerName('index')->setActionName('view');
$request->setAlias(\Magento\Framework\Url::REWRITE_REQUEST_PATH_ALIAS, $identifier);
return $this->actionFactory->create('Magento\Framework\App\Action\Forward');
}
}
1 exception(s):
Exception #0 (LogicException): Front controller reached 100 router match iterations
Exception #0 (LogicException): Front controller reached 100 router match iterations
#0 /opt/lampp/htdocs/Magento-CE-2.1.2_sample/vendor/magento/framework/Interception/Interceptor.php(74): Magento\Framework\App\FrontController->dispatch(Object(Magento\Framework\App\Request\Http))
#1 /opt/lampp/htdocs/Magento-CE-2.1.2_sample/vendor/magento/framework/Interception/Chain/Chain.php(70): Magento\Framework\App\FrontController\Interceptor->___callParent('dispatch', Array)
#2 /opt/lampp/htdocs/Magento-CE-2.1.2_sample/vendor/magento/framework/Interception/Chain/Chain.php(63): Magento\Framework\Interception\Chain\Chain->invokeNext('Magento\\Framewo...', 'dispatch', Object(Magento\Framework\App\FrontController\Interceptor), Array, 'requestPreproce...')
#3 /opt/lampp/htdocs/Magento-CE-2.1.2_sample/vendor/magento/module-store/App/FrontController/Plugin/RequestPreprocessor.php(94): Magento\Framework\Interception\Chain\Chain->Magento\Framework\Interception\Chain\{closure}(Object(Magento\Framework\App\Request\Http))
#4 /opt/lampp/htdocs/Magento-CE-2.1.2_sample/vendor/magento/framework/Interception/Chain/Chain.php(67): Magento\Store\App\FrontController\Plugin\RequestPreprocessor->aroundDispatch(Object(Magento\Framework\App\FrontController\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http))
#5 /opt/lampp/htdocs/Magento-CE-2.1.2_sample/vendor/magento/framework/Interception/Chain/Chain.php(63): Magento\Framework\Interception\Chain\Chain->invokeNext('Magento\\Framewo...', 'dispatch', Object(Magento\Framework\App\FrontController\Interceptor), Array, 'install')
#6 /opt/lampp/htdocs/Magento-CE-2.1.2_sample/vendor/magento/framework/Module/Plugin/DbStatusValidator.php(69): Magento\Framework\Interception\Chain\Chain->Magento\Framework\Interception\Chain\{closure}(Object(Magento\Framework\App\Request\Http))
#7 /opt/lampp/htdocs/Magento-CE-2.1.2_sample/vendor/magento/framework/Interception/Chain/Chain.php(67): Magento\Framework\Module\Plugin\DbStatusValidator->aroundDispatch(Object(Magento\Framework\App\FrontController\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http))
#8 /opt/lampp/htdocs/Magento-CE-2.1.2_sample/vendor/magento/framework/Interception/Chain/Chain.php(63): Magento\Framework\Interception\Chain\Chain->invokeNext('Magento\\Framewo...', 'dispatch', Object(Magento\Framework\App\FrontController\Interceptor), Array, 'front-controlle...')
#9 /opt/lampp/htdocs/Magento-CE-2.1.2_sample/vendor/magento/module-page-cache/Model/App/FrontController/VarnishPlugin.php(55): Magento\Framework\Interception\Chain\Chain->Magento\Framework\Interception\Chain\{closure}(Object(Magento\Framework\App\Request\Http))
#10 /opt/lampp/htdocs/Magento-CE-2.1.2_sample/vendor/magento/framework/Interception/Chain/Chain.php(67): Magento\PageCache\Model\App\FrontController\VarnishPlugin->aroundDispatch(Object(Magento\Framework\App\FrontController\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http))
#11 /opt/lampp/htdocs/Magento-CE-2.1.2_sample/vendor/magento/framework/Interception/Interceptor.php(138): Magento\Framework\Interception\Chain\Chain->invokeNext('Magento\\Framewo...', 'dispatch', Object(Magento\Framework\App\FrontController\Interceptor), Array, 'front-controlle...')
#12 /opt/lampp/htdocs/Magento-CE-2.1.2_sample/vendor/magento/module-page-cache/Model/App/FrontController/BuiltinPlugin.php(68): Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception\{closure}(Object(Magento\Framework\App\Request\Http))
#13 /opt/lampp/htdocs/Magento-CE-2.1.2_sample/vendor/magento/framework/Interception/Interceptor.php(142): Magento\PageCache\Model\App\FrontController\BuiltinPlugin->aroundDispatch(Object(Magento\Framework\App\FrontController\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http))
#14 /opt/lampp/htdocs/Magento-CE-2.1.2_sample/var/generation/Magento/Framework/App/FrontController/Interceptor.php(26): Magento\Framework\App\FrontController\Interceptor->___callPlugins('dispatch', Array, Array)
#15 /opt/lampp/htdocs/Magento-CE-2.1.2_sample/vendor/magento/framework/App/Http.php(135): Magento\Framework\App\FrontController\Interceptor->dispatch(Object(Magento\Framework\App\Request\Http))
#16 /opt/lampp/htdocs/Magento-CE-2.1.2_sample/vendor/magento/framework/App/Bootstrap.php(258): Magento\Framework\App\Http->launch()
#17 /opt/lampp/htdocs/Magento-CE-2.1.2_sample/index.php(39): Magento\Framework\App\Bootstrap->run(Object(Magento\Framework\App\Http))
#18 {main}
2 回答
我的问题也与您的问题相同,请将您的 etc/frontend/di.xml 更新为以下内容:
最后我解决了这个问题,这是由于在etc frontend di.xml
<item name="sortOrder" xsi:type="string">20</item>
中的sortorder . 我将20改为60并且错误消失了 .