ZF2 - overriding the configuration of the ZFcUser provider module

EDIT: I just found a solution myself. Since my ContentManagerController extends AbstractRestfulController, it naturally does not perform any index actions. Therefore, the field "action" in the array "defaults" must be redefined "or". Then the appropriate action, depending on the type of HTTP request, will be invoked as expected. Where is my mind

Here's the updated code. The change

'defaults' => array( 'controller' => 'zfcuser', 'action' => 'index', ), 

to

 'defaults' => array( 'controller' => 'ContentManager\Controller\ContentManager', 'action' => '', // or null ), 

--- Original post ---

I am trying to redefine the routes of a provider module ( ZFcUser ) from a module of a custom module (ContentManager). config.php. ContentManagerController extends the original UserController. I do not want to touch on ZFcUser module.config.php, as this can lead to trouble after the proposed update through the composer. I want to strictly circumvent any configurations made by me from the source files of the providers. Just redefining

 'route' => '/user', 

to

 'route' => '/cms', 

works for now, but that’s not what I want to achieve. So, I need to also replace the controller entry

 'defaults' => array( 'controller' => 'zfcuser', 'action' => 'index', ), 

from

 'defaults' => array( 'controller' => 'ContentManager\Controller\ContentManager', ), 

But that gives me a 404 error.

 The requested controller was unable to dispatch the request. Controller: ContentManager\Controller\ContentManager 

Both controllers seem to be in conflict. When I comment out the 'defaults' array in then ZFcUser module.config.php my ContentManagerController is called as expected. I also made sure my module is registered after ZFcUser. Therefore, revaluation should work, afayk.

I have already researched a lot, but I can’t understand what is happening here. The strategies described here and there do not do the trick.

 return array( 'controllers' => array( 'invokables' => array( 'ContentManager\Controller\ContentManager' => 'ContentManager\Controller\ContentManagerController', ), ), 'router' => array( 'routes' => array( 'zfcuser' => array( 'type' => 'Literal', 'priority' => 1000, 'options' => array( 'route' => '/cms', 'defaults' => array( 'controller' => 'ContentManager\Controller\ContentManager', ), ), 'may_terminate' => true, 'child_routes' => array( . . . ), ), ), ), ); 

Thanks for your help!

+4
source share
1 answer

The author found a state of mind, but did not answer the question (he edits it), I just copy it in response.

I just found a solution myself. Since my ContentManagerController extends AbstractRestfulController, it naturally does not perform any index actions. Therefore, the field "action" in the array "defaults" must be redefined "or". Then the appropriate action, depending on the type of HTTP request, will be invoked as expected. Where is my mind

Here's the updated code. The change

 'defaults' => array( 'controller' => 'zfcuser', 'action' => 'index', ), 

to

 'defaults' => array( 'controller' => 'ContentManager\Controller\ContentManager', 'action' => '', // or null ), 
+1
source

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


All Articles