Magento ver. 2.3.2
I am writing a Magento 2 module. I'm trying to re-write a CMS page URL:
https://www.test.com/url-test/cat1/cat2/cat3/
https://www.test.com/url-test?path=/cat1/cat2/cat3/
I have a widget on the CMS page url-test that handles the logic of what is passed in GET['path'].
I cannot get the Router to fire at all (display the die() cmd). I've played with different values for the di sortOrder. I've tried overriding default routers. All to no avail.
I don't have a /etc/frontend/routes.xml file as I don't think I need it.
/etc/frontend/dii.xml:
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<type name="Magento\Framework\App\RouterList">
<arguments>
<argument name="routerList" xsi:type="array">
<item name="test_router" xsi:type="array">
<item name="class" xsi:type="string">Me\MyModule\Controller\Router</item>
<item name="disable" xsi:type="boolean">false</item>
<item name="sortOrder" xsi:type="string">1</item>
</item>
</argument>
</arguments>
</type>
</config>
/Controller/Router.php:
namespace Me\MyModule\Controller;
class Router implements \Magento\Framework\App\RouterInterface
{
private $actionFactory;
public function __construct(\Magento\Framework\App\ActionFactory $actionFactory)
{
$this->actionFactory = $actionFactory;
}
public function match(\Magento\Framework\App\RequestInterface $request)
{
die("test Router");
$pathInfo = $request->getPathInfo();
return null;
}
}