code: public function setModuleStatus($moduleName, $isActive)
      {
          $moduleConfigFile = $this->getModuleConfigFilePath($moduleName);
          $configXml = $this->loadXmlFile($moduleConfigFile);
          if ($configXml === false) {
              throw new Exception("Unable to parse module configuration file {$moduleConfigFile}");
          }
  
          $configXml->modules->{$moduleName}->active = $isActive ? 'true' : 'false';
  
          // save
          if ($this->saveXml($configXml, $moduleConfigFile) === false) {
              throw new Exception("Unable to save module configuration file {$moduleConfigFile}. Check to see if web server user has write permissions.");
          }
      }
docs: Sets active status for specified module
  
  @param string $moduleName
  @param bool $isActive
  @throws Exception