Yogesh Chaugule's Blog
In Drupal 8, a service is any object managed by the services container. Drupal 8 introduces the concept of services to decouple reusable functionality and makes these services pluggable and replaceable by registering them with a service container. Services are used to perform operations like accessing the database or sending an e-mail.
Using below example we can check if module is installed or not :
Modules are used to extend and customize Drupal Core. To install module normally we can navigate to "Admin => Extend" link in toolbar.
Like older versions of Drupal, Drupal 8 doesn't allow modules to be enable / disable. The only thing we can do is either install a module or completely uninstall it.
Below example shows how to install module using code:
In Drupal 8, module's weight is stored into ConfigFactory. Here's how to get or set module weight.
Get module weight:
As a developer we always been into position where we need to write a custom script which bootstrap's Drupal Core from code and do some operations. This is pretty straight forward when working single site. But when working with Multisite or sub-site, how we can do this.