Welcome to the LimeSurvey Community Forum

Ask the community, share ideas, and connect with other LimeSurvey users!

How to check if current plugin is enabled or activated?

  • tassoman
  • tassoman's Avatar Topic Author
  • Offline
  • Premium Member
  • Premium Member
More
2 years 7 months ago #228127 by tassoman
Your LimeSurvey version: 3.x latest
==================
Hello there, I'm extending PluginManager\PluginBase class. I have name, description attributes but I can't find a method or attribute to evaluate if plugin was enabled.
My plugin is doing things, whatever. Just hooking also when disabled.

Inside init() method I've just subscribed to beforeAdminMenuRender. I'd like to add a trigger who subscribe only if plugin is enabled.

I've tried with $this->checkActive(__CLASS__) but dies with  Trying to get property 'active' of non-object

«All your survey answers are belong to us »

Please Log in to join the conversation.

  • tassoman
  • tassoman's Avatar Topic Author
  • Offline
  • Premium Member
  • Premium Member
More
2 years 7 months ago #228128 by tassoman
Nevermind -_- I founded, inside api!

Solution is $this->api->pluginIsActive($this->getName())

«All your survey answers are belong to us »
The following user(s) said Thank You: DenisChenu

Please Log in to join the conversation.

  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team & Official Partner
  • LimeSurvey Community Team & Official Partner
More
2 years 7 months ago #228258 by DenisChenu
… argl … it's in API …

I use own system always … (check in DB directly)

Else : currently i try to create helper for the tools
1. Yii::getPathOfAlidas : gitlab.com/SondagesPro/coreAndTools/relo...AnyResponse.php#L267
2. App()->getConfig : gitlab.com/SondagesPro/coreAndTools/relo...nyResponse.php#L1252

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member. - Professional support - Plugins, theme and development .
I don't answer to private message.

Please Log in to join the conversation.

  • tassoman
  • tassoman's Avatar Topic Author
  • Offline
  • Premium Member
  • Premium Member
More
2 years 7 months ago #228270 by tassoman
Oldschool singleton development sometimes can be a bit confusing. Really fast but needs a lot of discipline.

For plugin development, I better prefer using namespacing and dependency injection, but the important thing is to get things done in a safe, affordable and fast way.

«All your survey answers are belong to us »

Please Log in to join the conversation.

Moderators: holchtpartner

Lime-years ahead

Online-surveys for every purse and purpose