Timeline for How can I check if a module is enabled?
Current License: CC BY-SA 4.0
10 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Nov 16, 2020 at 14:30 | comment | added | avpaderno♦ |
This is exactly the same as the code shown from the other answer, which is preferable when the Drupal class has an helper method. If a hook is only using a service, I would not use injection; in the case the services are more than one, it's possible to write code that uses injection, via a class.
|
|
S Nov 16, 2020 at 9:03 | history | suggested | Joao Ventura | CC BY-SA 4.0 |
Fix quote, make clear this is not injection, and space before curly brace
|
Nov 16, 2020 at 7:17 | review | Suggested edits | |||
S Nov 16, 2020 at 9:03 | |||||
Nov 16, 2020 at 7:11 | comment | added | Joao Ventura | Even though this is not an injection, this code is probably the best you can have if running in a hook_update_nnn() function in your module's .install file, as there's no way of injecting services in a functional context. | |
S May 28, 2018 at 18:29 | history | rollback | itsdarrylnorris |
Rollback to Revision 1 - Edit approval overridden by post owner or moderator
|
|
May 28, 2018 at 10:39 | history | suggested | Antoine Subit | CC BY-SA 4.0 |
Update the result of function moduleExists() + add API doc link
|
May 28, 2018 at 7:09 | review | Suggested edits | |||
S May 28, 2018 at 18:29 | |||||
Apr 12, 2018 at 1:10 | comment | added | George |
\Drupal::moduleHandler ends up just making an equivalent call to get the "module_handler" service anyway (see the moduleHandler doco). The key word in Clives comment was injecting, i.e. passing the service to a constructor.
|
|
Oct 9, 2016 at 10:01 | vote | accept | Patrick Kenny | ||
Oct 9, 2016 at 9:05 | history | answered | itsdarrylnorris | CC BY-SA 3.0 |