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.

Archive /

Our old forums are still available as a read-only archive.

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

CMS Requirements


Go to End


3 Posts   1755 Views

Avatar
xmedeko

Community Member, 94 Posts

15 July 2007 at 2:39pm

Edited: 15/07/2007 2:43pm

Hi,
we are developing pluggable modules for SS and do not want to change Requirements in CMSMain::init() everytime when the new module is installed. So I have made a (maybe not optimal) solution:

[code php]
class Config {

// put CMS Requirements here
static function CMSRequirements() {
}

static final function AllCMSRequirements() {
foreach (ClassInfo::subclassesFor(__CLASS__) as $class) {
eval("$class::CMSRequirements();");
}
}

}

In the CMSMain::init() is only:
[code php]
Config::AllCMSRequirements()

Each module just subclasses the Config class and fills its Requirements to the CMSRequirements method.

I know, that this is not optimal, but it has the advantage, that this code is run only when is needed, i.e. when somebody works with CMS, and not when somebody just view the pages.

Avatar
Sam

Administrator, 690 Posts

16 July 2007 at 8:55pm

Creating an entire new class for this seems like overkill...

What about something like this in _config.php

CMSMain::add_requirements(array(
  'module/javascript/something.js',
  'other/javascript/another.js',
));

Avatar
xmedeko

Community Member, 94 Posts

17 July 2007 at 9:24am

Yeah, the new class is overkill. Your idea seems better.