/**
  * {@inheritdoc}
  */
 public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
 {
     /*
      * Register themes
      */
     $setup->getEventManager()->dispatch('theme_registration_from_filesystem');
     /**
      * Update theme's data
      */
     $fileCollection = $this->createTheme();
     $fileCollection->setItemObjectClass('Magento\\Theme\\Model\\Theme\\Data');
     $resourceCollection = $this->createThemeResource();
     $resourceCollection->setItemObjectClass('Magento\\Theme\\Model\\Theme\\Data');
     /** @var $theme \Magento\Framework\View\Design\ThemeInterface */
     foreach ($resourceCollection as $theme) {
         $themeType = $fileCollection->hasTheme($theme) ? \Magento\Framework\View\Design\ThemeInterface::TYPE_PHYSICAL : \Magento\Framework\View\Design\ThemeInterface::TYPE_VIRTUAL;
         $theme->setType($themeType)->save();
     }
     $fileCollection = $this->createTheme();
     $fileCollection->setItemObjectClass('Magento\\Theme\\Model\\Theme\\Data');
     $themeDbCollection = $this->createThemeResource();
     $themeDbCollection->setItemObjectClass('Magento\\Theme\\Model\\Theme\\Data');
     /** @var $theme \Magento\Framework\View\Design\ThemeInterface */
     foreach ($fileCollection as $theme) {
         $dbTheme = $themeDbCollection->getThemeByFullPath($theme->getFullPath());
         $dbTheme->setCode($theme->getCode());
         $dbTheme->save();
     }
     /**
      * Update rows in theme
      */
     $setup->getConnection()->update($setup->getTable('theme'), ['area' => 'frontend'], ['area = ?' => '']);
 }