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.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

General Questions /

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

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

Extending an extension?


Go to End


3 Posts   1105 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, 5523 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.