How to delete a route on an overridden module?

I added the module zfcUserto my project through Composer and redefined it in the module ZfcUserOverride. I need to work with a slash, so I added a route to the redefined module.

ZfcUserOverridefile module.config.phpbelow:

<?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 a new path, each of which works correctly.

But what if I want to delete a route? How to do it? I need something like:

$config['router']['routes']['zfcuser']['child_routes']['login'] = null;

Help me please. Thank.

-1
source share
2 answers

Here is the answer.

@ , - . , -, 10 . , , , .

, , , , .

..

-1

zfcUserOverride , .

, .

; login, , :

// zfcUserOverride/config/module.config.php
'router' => array(
    'routes' => array(
        'zfcuser' => array(
            'child_routes' => array(
                'login' => array(
                    'type' => 'Segment',
                    'options' => array(
                        'route' => '/login[/]',
                    ),
                ),
             ),
         ),
    ),
);

ZF2 / , array_replace_recursive(). , .

, , application.config.php

array(
    'modules' => array(
        //...
        'ZfcUser',
        'ZfcUserOverride', // Loads after
        // ... 
    ),
);
+2

Source: https://habr.com/ru/post/1539231/


All Articles