Jump to:

17452 Posts in 4473 Topics by 1971 members

Archive

SilverStripe Forums » Archive » CMS Requirements

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

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

Page: 1
Go to End
Author Topic: 1393 Views
  • xmedeko
    Avatar
    Community Member
    94 Posts

    CMS Requirements Link to this post

    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.

  • Sam
    Avatar
    Administrator
    679 Posts

    Re: CMS Requirements Link to this post

    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',
    ));

  • xmedeko
    Avatar
    Community Member
    94 Posts

    Re: CMS Requirements Link to this post

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

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