How to remove route on overrided module?

后端 未结 2 746
无人及你
无人及你 2021-01-29 09:05

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 overr

2条回答
  •  不思量自难忘°
    2021-01-29 09:39

    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
            // ... 
        ),
    );
    

提交回复
热议问题