Add plugin to RoutePluginManager


#1

Zend Framework 3. I try to extend Zend\Router\Http\Regex class to use unicode letters in url path. I was create a file Applicaion\Router\Http\UnicodeRegex.php in my Application module.
In my module.config.php file I add:

use Application\Router\Http\UnicodeRegex;

return [
    'router' => [
        'routes' => [
            ...
            'city' => [
                'type'  => UnicodeRegex::class,
                'options' => [
                    'regex' => '/city/(?<city>[\p{L}]+)',
                    'defaults' => [
                        'controller' => Controller\IndexController::class,
                        'action'     => 'city',
                    ],
                    'spec'  => '/city/%city%',
                ],
                'may_terminate' => true,
            ],
            ...
        ],
    ],
]

And I get an error: «Fatal error : Uncaught Zend\ServiceManager\Exception\ServiceNotFoundException: A plugin by the name “Application\Router\Http\UnicodeRegex” was not found in the plugin manager Zend\Router\RoutePluginManager in»
How I may to extend Zend\Router\Http\Regex class, import him and use in module.config.php? How to add my class to Zend\Router\RoutePluginManager?


About zf3 components's config confusion
#2

you can register your Application\Router\Http\UnicodeRegex under 'route_plugins' config, eg:

use Application\Router\Http\UnicodeRegex;
use Zend\Router\RouteInvokableFactory;

return [
// ...
    'route_plugins' => [
        'factories' => [
            UnicodeRegex::class => RouteInvokableFactory::class,
        ],
    ],

    'router' => [ /** **/]
    // ...
];