phplogiczend-framework2zend-framework-modules

zf2 multiple module working with each other?


imagine we have a core module that has an AdminController

and another module called gallery that has an AdminController too

how can i make gallery module admin area works with core module's AdminController

or any other possible logic solution ?


Solution

  • You are describing the idea behind the ZfcAdmin module. Jurian even wrote up an RFC.

    Some ideas on what's required:

    What you need to do is in your child module, add the routes to the Admin module's route tree. Routes in ZF2 are tree-based so you can add to them from any module. This is made possible due to the merging of configuration which the ModuleManager does.

    You will also need your admin module to provide a root navigation configuration that your child module can add to.

    Finally, you need to sort out the layout. The easiest way is via a listener on the admin module that checks the route to see if it's in the admin tree. If so, it would set the admin layout.