2
votes

I am working on developing a module in magento2.The problem is with the routing-where the router return $this->actionFactory->create('Magento\Framework\App\Action\Forward'); does not redirect to my module,contorller and the action specified in the code;it thorws an exception Front controller reached 100 router match iterations.Any help would be highly appreciated.Thanks in advance!

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
Finally I get over the issue, it was due to sortorder in etc frontend di.xml <item name="sortOrder" xsi:type="string">20</item> .I changed 20 to 60 and the error disappeared.Verdu
Thanks.. Your solution helps me!Lalita

2 Answers

2
votes

Finally I get over the issue, it was due to sortorder in etc frontend di.xml <item name="sortOrder" xsi:type="string">20</item> .I changed 20 to 60 and the error disappeared.

0
votes

My issue was also the same as yours, please update your etc/frontend/di.xml to the following:

<item name="sortOrder" xsi:type="string">60</item>