首页 > 代码库 > Magento2:在Router.php Submiting POST表单Redict问题

Magento2:在Router.php Submiting POST表单Redict问题

我创建自定义表单,当我试图提交。它会去我的自定义Router.php

应用程序\代码\自定义\模块\控制器\ Router.php

HTTP://本地主机/ magento2 /自定义/职位/回复/

if (strpos($request->getServer(‘REQUEST_URI‘), ‘reply‘) !== false) {     $request->setModuleName(‘module‘)->setControllerName(‘posts‘)->setActionName(‘reply‘);    return $this->actionFactory->create(                    ‘Magento\Framework\App\Action\Forward‘, [‘request‘ => $request]    );}

以下提供错误。

1例外(S):异常#0(LogicException):前端控制器达到100路由器匹配的迭代

对于其他的简单罗列网页,它与POST表单rediction精唯一的问题。

我已经加入小型工作例如,它可以帮助你。

应用程序\代码\供应商\模块\和registration.php

<?php/** * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */\Magento\Framework\Component\ComponentRegistrar::register(    \Magento\Framework\Component\ComponentRegistrar::MODULE,    ‘Vendor_Module‘,    __DIR__);

\程序\代码\供应商\模块\等\ module.xml

<?xml version="1.0"?><config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Module/etc/module.xsd">    <module name="Vendor_Module" setup_version="2.0.0"></module></config>

\程序\代码\供应商\模块\等\前端\ routes.xml

<?xml version="1.0"?><config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../lib/internal/Magento/Framework/App/etc/routes.xsd">    <router id="standard">        <route id="sometest" frontName="sometest">            <module name="Vendor_Module" />        </route>    </router></config>

\程序\代码\供应商\模块\等\前端\ di.xml

<?xml version="1.0"?><config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../lib/internal/Magento/Framework/ObjectManager/etc/config.xsd">    <type name="Magento\Framework\App\RouterList">        <arguments>            <argument name="routerList" xsi:type="array">                <item name="sometest" xsi:type="array">                    <item name="class" xsi:type="string">Vendor\Module\Router</item>                    <item name="disable" xsi:type="boolean">false</item>                    <item name="sortOrder" xsi:type="string">1</item>                </item>            </argument>        </arguments>    </type></config>

\程序\代码\供应商\模块\控制器\ Router.php

 <?php    namespace Vendor\Module\Controller;    class Router implements \Magento\Framework\App\RouterInterface    {        protected $actionFactory;        protected $_response;        public function __construct(            \Magento\Framework\App\ActionFactory $actionFactory,            \Magento\Framework\App\ResponseInterface $response        ) {            $this->actionFactory = $actionFactory;            $this->_response = $response;        }        public function match(\Magento\Framework\App\RequestInterface $request)        {            //$request->setModuleName(‘module‘)->setControllerName(‘test‘)->setActionName(‘test‘);$request->setModuleName(‘cms‘)->setControllerName(‘page‘)->setActionName(‘view‘)->setParam(‘page_id‘, 4);            return $this->actionFactory->create(                ‘Magento\Framework\App\Action\Forward‘,                [‘request‘ => $request]            );        }    }

为了测试我已经转发到连我与我的定制控制器测试了CMS页面。

$请求 - > setModuleName(“CMS”) - > setControllerName(“页”) - > setActionName(‘查看‘) - > setParam(‘PAGE_ID‘,4);

Magento2:在Router.php Submiting POST表单Redict问题