Jump to:

23478 Posts in 18950 Topics by 2878 members

General Questions

SilverStripe Forums » General Questions » Extending an extension?

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: 181 Views
  • svandragt
    Avatar
    Community Member
    44 Posts

    Extending an extension? Link to this post

    I'm currently developing an extension that can be used by page types and other extensions.

    I'm running code in the onAfterInit() method of my extension, and I want to allow other extensions to run code before that.
    However Extension isn't extending Object, so I cannot create my own extension points.

    I can't ensure that my code is run after all other onAfterInit() code (what if another module also wants to run last), so do I have any options?

  • Willr
    Avatar
    Forum Moderator
    5502 Posts

    Re: Extending an extension? Link to this post

    AFAIK, no you don't have any control over making sure your extension is 'last' in the Extension API.

    In an application you could add the extension before your extension and then in theory your extension would run last. By using the config system you could specify that your config comes after any other config so might run last?

  • svandragt
    Avatar
    Community Member
    44 Posts

    Re: Extending an extension? Link to this post

    FYI After further experimentation, the most robust solution I've found was to simply use the config.yml API.

    Initially, I was using After: "*" however my onAfterInit method was then loaded before everything else (testing through Debug statements). Therefore the result I settled on is to define Before: "mysite" because it seems onAfterInit is not applied in the correct logical order.

    181 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.