Jump to:

23459 Posts in 18906 Topics by 2877 members

General Questions

SilverStripe Forums » General Questions » Best way to determine if an object has been 'decorated'?

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: 375 Views
  • vwd
    Avatar
    Community Member
    158 Posts

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

    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

  • martimiz
    Avatar
    Forum Moderator
    1078 Posts

    Re: Best way to determine if an object has been 'decorated'? Link to this post

    Maybe this:

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

  • vwd
    Avatar
    Community Member
    158 Posts

    Re: Best way to determine if an object has been 'decorated'? Link to this post

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

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