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

Test for presence of module or fields


Go to End


3 Posts   2670 Views

Avatar
vwd

Community Member, 166 Posts

2 November 2011 at 2:06pm

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

Community Member, 215 Posts

2 November 2011 at 9:43pm

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

Community Member, 166 Posts

3 November 2011 at 11:27am

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