2

I have more than 50 menus which I need to create custom. as per the module structure, we need to create routing.yml in root folder. but I want to do something like this below:

   myModule
      -  products(folder)
              - routing.yml
              - src(folder)
                - productController  
      -  brands(folder)
              - routing.yml
              - src(folder)
                - brandsController.php    
      - myModule.info.yml
      - myModule.module

is it way to do achive something like this.

I just want to make code seperation and avoid to add all routes in routing.yml

4

Instead of adding multiple routing files, you can define products, brands as modules inside your main module and then can define routing file for each of them like what is done in aggregator module in core. aggregator-module-core

2

The routing.yml can split by multiple files. You can include separate routing files in your routing.yml file.

acme_demo_user:
  resource: "@acmeDemoBundle/Resources/config/routing/user_routing.yml"
  prefix: /user
acme_demo_vehicles:
  resource: "@acmeDemoBundle/Resources/config/routing/vehicles_routing.yml"
  prefix: /vehicles
.............
.............

It would works in symfony not sure in drupal 8, I hope it would works in drupal 8 too. Source : https://stackoverflow.com/questions/16355385/symfony2-splitting-routing-yml-in-multiple-files

0

the included routing files in a single file reouting.yml does not work under drupal because in drupal there is not the notion of bundle

I tested by passing the module name and also the namespace but it does not work

myroute_form:
  resource: "@module_name/routing/salesforce_front_routing.yml"

myroute_form2:
  resource: "@Drupal/module_name/routing/salesforce_front_routing.yml"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.