1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

getConfig() in another class

Discussion in 'Facepalm' started by TBNRShadowDev, Sep 16, 2017.

  1. TBNRShadowDev

    TBNRShadowDev Spider Jockey

    Messages:
    25
    GitHub:
    tbnrshadowdev
    Does anyone know how could I use getConfig() in a class that does not extend PluginBase?
    Example:
    Example.php and ExampleCommand.php where Example extends PluginBase and ExampleCommand extends Command, how do I set/get config from ExampleCommand.php?
    Thanks!
     
  2. jasonwynn10

    jasonwynn10 Moderator Poggit Reviewer

    Messages:
    1,489
    GitHub:
    jasonwynn10
    Assuming you mean PluginBase::getConfig() which returns a Config object, you can simply create a new object which links the the same file by setting a variable equal to the new object (assuming you know the path to the config)
    Another, probably easier, method would also be to pass your PluginBase object to your second class and access your config from there.
     
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.