Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

General Questions /

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

Extending an extension?


Reply


3 Posts   265 Views

Avatar
svandragt

Community Member, 44 Posts

20 February 2014 at 4:00am

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?

Avatar
Willr

Forum Moderator, 5513 Posts

22 February 2014 at 9:06pm

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?

Avatar
svandragt

Community Member, 44 Posts

23 February 2014 at 2:37am

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.