To get list of modules programmatically, please use following code:
$modulesList = \Drupal::service('extension.list.module')->reset()->getList(); if (! empty($modulesList)) { echo "<strong>Modules List:</strong>"; echo "<br/>"; foreach ($modulesList as $moduleName => $moduleObj) { echo "<br/>"; echo '<strong>Machine Name: </strong>' . $moduleName; echo "<br/>"; echo '<strong>Humand Readable Name: </strong>' . $moduleObj->info['name']; echo "<br/>"; echo '<strong>Description: </strong>' . $moduleObj->info['description']; echo "<br/>"; echo '<strong>Package: </strong>' . $moduleObj->info['package']; echo "<br/>"; echo "-----------------------------------------------------------------"; } }
Output:
Modules List:
Machine Name: action
Humand Readable Name: Actions
Description: Perform tasks on specific events triggered within the system.
Package: Core
-----------------------------------------------------------------
Machine Name: aggregator
Humand Readable Name: Aggregator
Description: Aggregates syndicated content (RSS, RDF, and Atom feeds) from external sources.
Package: Core
-----------------------------------------------------------------
Machine Name: automated_cron
Humand Readable Name: Automated Cron
Description: Provides an automated way to run cron jobs, by executing them at the end of a server response.
Package: Core
-----------------------------------------------------------------
Machine Name: ban
Humand Readable Name: Ban
Description: Enables banning of IP addresses.
Package: Core
-----------------------------------------------------------------
Machine Name: basic_auth
Humand Readable Name: HTTP Basic Authentication
Description: Provides the HTTP Basic authentication provider
Package: Web services
-----------------------------------------------------------------
......
No comments:
Post a Comment