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

Test for presence of module or fields


Reply

3 Posts   826 Views

Avatar
vwd

2 November 2011 at 2:06pm Community Member, 159 Posts

Hi,

Is there a conventional way of testing for the presence of Module or specific fields that a module might create?

Thanks very much.

VWD.

Avatar
Howard

2 November 2011 at 9:43pm Community Member, 215 Posts

You can check if a class exists by doing this:

if (class_exists('MyClass')) {
$myclass = new MyClass();
}


So you could check for a known class in the module and then assume that the module is installed - maybe not ideal...

Avatar
vwd

3 November 2011 at 11:27am Community Member, 159 Posts

Thanks @Howard, that'll do the trick.

So there isn't a Sapphire API to test for the presence of a module or widget?

Thanks again.

VWD