I added zfcUser
module to my project via Composer and overrided it in the module ZfcUserOverride
. I want trailing slash work, so I added route in overrided module.
zfcUserOverride
file module.config.php
contents below:
<?php
$config = array(
'view_manager' => array(
'template_path_stack' => array(
'zfcuser' => __DIR__ . '/../view',
),
),
'controllers' => array(
'invokables' => array(
'zfcuser' => 'ZfcUserOverride\Controller\UserController',
),
)
);
$config['router']['routes']['zfcuser']['child_routes']['trailing_slash'] = array(
'type' => 'Literal',
'options' => array(
'route' => '/',
'defaults' => array(
'controller' => 'zfcuser',
'action' => 'index',
),
),
);
return $config;
I added new path, everythin is working correct.
But what if I want remove route? How to do this? I need somethink like:
$config['router']['routes']['zfcuser']['child_routes']['login'] = null;
Help please. Thank you.
Here the answer.
@Sharikov Vladislav, I want to say something to you.
In this question I answered to your question and you choose the correct answer to somebody that just update his answer with my content 10 hours later.
I do not want to start a flame war, what I ask is just to be correct to whom used its time to help you.
And also I think you must use search engines prior to post here, you are asking a question for every single step of your development process and it is clear you are putting no effort on searching a solution by yourself.
Just sayin..
In zfcUserOverride
you will need to override the route config rather than add a new one.
This can easily be done by using the same array key when defining the routes.
For example; should I wish to modify the login
route to allow the extra slash I would use this:
// zfcUserOverride/config/module.config.php
'router' => array(
'routes' => array(
'zfcuser' => array(
'child_routes' => array(
'login' => array(
'type' => 'Segment',
'options' => array(
'route' => '/login[/]',
),
),
),
),
),
);
Internally ZF2 will combine/merge all module configuration into one complete array using array_replace_recursive()
. Matching configuration keys will therefore be replaced by modules that have loaded after.
So you will also need to ensure that you have it correctly configured in application.config.php
array(
'modules' => array(
//...
'ZfcUser',
'ZfcUserOverride', // Loads after
// ...
),
);