Jump to:

22972 Posts in 11596 Topics by 2824 members

General Questions

SilverStripe Forums » General Questions » Overrule #modelascontrollerroutes in routes.yml

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 224 Views
  • martimiz
    Avatar
    Forum Moderator
    1035 Posts

    Overrule #modelascontrollerroutes in routes.yml Link to this post

    Hi all

    This has been bugging me for the best part of a year now, and I'm beginning to think the use of wildcards in YAML isn't as innocent as it seems.

    For my LanguagePrefix module, I'm still trying to overrule/replace the modelascontrollerroutes, without success. If I'm correct, this is how the framework/cms routes are prioritized (and I placed my rule where I think it should be):

    rootroutes -> Before *
    modelascontrollerroutes -> Before: *, After: rootroutes
    languageprefixroutes -> Before: ???, After: ???
    coreroutes -> Before: *, After: rootroutes, modelascontrollerroutes
    adminroutes -> Before: *, After: rootroutes, coreroutes, modelascontrollerroutes
    legacycmsroutes -> After: adminroutes

    Obviously I want my lanuageprefixroutes after the modelascontrollerroutes, but before the coreroutes. After is easy, but Before always triggers the conflict error, whatever I try. Below one of many tries:

    ---
    Name: 'languageprefixroutes'
    After: 'cms/routes#modelascontrollerroutes'
    Before: 'framework/routes#coreroutes' <-- look, no wildcards
    ---

    Has anyone ever succeeded in doing this? Can it actually be done?

    Thanks, Martine

  • Willr
    Avatar
    Forum Moderator
    5462 Posts

    Re: Overrule #modelascontrollerroutes in routes.yml Link to this post

    I think the Wildcard approach is not the right one. If you remove the Before: * for coreroutes, adminroutes does that solve your issue? I wonder if these should only define after segments and let modules conclude if they need to be placed after *.

  • martimiz
    Avatar
    Forum Moderator
    1035 Posts

    Re: Overrule #modelascontrollerroutes in routes.yml Link to this post

    Hi Will,
    Thanks. I guess if I remove the Before:'*' from framework and cms routes, i won't have a problem positioning my rule after #coreroutes and before #adminroutes.

    I absolutely think framework and cms routes can easily be set up without the use of wildcards, and that would definitely solve the problem for other modules.

    I posted this on core dev some months ago, but unfortunately there was no response at that time

    https://groups.google.com/forum/m/#!searchin/silverstripe-dev/Routes.yml/silverstripe-dev/njFeb3ZJ_jc

    The documentation states that priority is determined based on the number of wildcards used, where Before '*' stands for three wildcards, Before:'#adminroutes' stands for two, so something like Before 'framework/routes#adminroutes' should at least have presedence, but that doesn't seem to be that simple.

    Maybe I should set it up again, do all the test and submit a pull...

  • Willr
    Avatar
    Forum Moderator
    5462 Posts

    Re: Overrule #modelascontrollerroutes in routes.yml Link to this post

    Tests sound like the best place to start!

    224 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.