I have added a custom no route handler using the following code
<?xml version="0.1"?>
<config>
<type name="Magento\Framework\App\Router\NoRouteHandlerList">
<arguments>
<argument name="handlerClassesList" xsi:type="array">
<item name="hello" xsi:type="array">
<item name="class" xsi:type="string">Smartie\HelloRouter\App\Router\NoRouteHandler</item>
<item name="sortOrder" xsi:type="string">10</item>
</item>
</argument>
</arguments>
</type>
</config>
Which is all good it addes the handler and i proved it by
<?php
namespace Smartie\HelloRouter\App\Router;
class NoRouteHandler implements \Magento\Framework\App\Router\NoRouteHandlerInterface
{
public function process(\Magento\Framework\App\RequestInterface $request)
{
die('woop');
}
}
What i have noticed though is that if i return false in the process function i end up with Front controller reached 100 router match iterations. After looking at the NoRouteHandlerList it seems that by adding my new no route handler it actually replaces all of the no route handlers already added (the default one) and i wondered why?
The following similar code for adding a new router has the effect of appending a new router to the list
<type name="Magento\Framework\App\RouterList">
<arguments>
<argument name="routerList" xsi:type="array">
<item name="custom" xsi:type="array">
<item name="class" xsi:type="string">Smartie\HelloRouter\Controller\Router</item>
<item name="disable" xsi:type="boolean">false</item>
<item name="sortOrder" xsi:type="string">20</item>
</item>
</argument>
</arguments>
</type>
Note: This is magento 2 version 0.74.0-beta16