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

Best way to determine if an object has been 'decorated'?


Go to End


3 Posts   931 Views

Avatar
vwd

Community Member, 166 Posts

20 January 2012 at 2:36am

Hi,

How do you determine if an object has been 'decorated' or if an extension has been added?

I thought of using method_exists(...) to see if a particular method existed in an object, but there are no occurrences of it in the SilverStripe code of so there must be more proper 'SilverStripe' way to do this.

In particular what I'm trying to do is determine programmatically if the Addressable module has been added to an object / controller (eg SiteConfig) before calling a method in a shortcode handler.

Thanks very much.
VWD

Avatar
martimiz

Forum Moderator, 1391 Posts

20 January 2012 at 5:03am

Maybe this:

if ($MyObject->hasExtension($extension)) ...

Avatar
vwd

Community Member, 166 Posts

4 February 2012 at 2:53am

@martimiz - Thank you for your reply. Sounds like exactly what I'm looking for.