programmatically enable and disable theme from update hook I need to programmatically update my default theme and disable bartik on a live site. I know I need to update the config. In Drupal 7 I would have used theme_enable(), but I am not sure how to do this in Drupal 8. 
Below my function sets 'mycustomtheme' by default but it does not enable the theme. Thanks in advance.

  function mysite_deploy_update_8001() {
      \Drupal::configFactory()
      -&gt;getEditable('system.theme')
      -&gt;set('default', 'mycustomtheme')
      -&gt;save();
    }
Use the theme installer service to enable and disable themes .

Install a list of themes:

\Drupal::service('theme_installer')-&gt;install(['mytheme']);


Uninstall a list of themes:

\Drupal::service('theme_installer')-&gt;uninstall(['mytheme']);


Reference: https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Extension%21ThemeInstaller.php/function/ThemeInstaller%3A%3Ainstall/8.2.x

Instead of writing to the config you can use the theme handler to set a default theme:

\Drupal::service('theme_handler')-&gt;setDefault('mytheme');