コード例 #1
0
 /**
  * Uninstall theme from database registry
  *
  * @param OutputInterface $output
  * @param array $themePaths
  * @return void
  */
 public function uninstallRegistry(OutputInterface $output, array $themePaths)
 {
     $output->writeln('<info>Removing ' . implode(', ', $themePaths) . ' from database');
     foreach ($themePaths as $themePath) {
         $this->themeProvider->getThemeByFullPath($themePath)->delete();
     }
 }
コード例 #2
0
 /**
  * Check theme if has child virtual and physical theme
  *
  * @param string[] $themePaths
  * @return string[]
  */
 public function checkChildTheme($themePaths)
 {
     $messages = [];
     $themeHasVirtualChildren = [];
     $themeHasPhysicalChildren = [];
     $parentChildMap = $this->getParentChildThemeMap();
     foreach ($themePaths as $themePath) {
         $theme = $this->themeProvider->getThemeByFullPath($themePath);
         if ($theme->hasChildThemes()) {
             $themeHasVirtualChildren[] = $themePath;
         }
         if (isset($parentChildMap[$themePath])) {
             $themeHasPhysicalChildren[] = $themePath;
         }
     }
     if (!empty($themeHasVirtualChildren)) {
         $text = count($themeHasVirtualChildren) > 1 ? ' are parents of' : ' is a parent of';
         $messages[] = implode(', ', $themeHasVirtualChildren) . $text . ' virtual theme.' . ' Parent themes cannot be uninstalled.';
     }
     if (!empty($themeHasPhysicalChildren)) {
         $text = count($themeHasPhysicalChildren) > 1 ? ' are parents of' : ' is a parent of';
         $messages[] = implode(', ', $themeHasPhysicalChildren) . $text . ' physical theme.' . ' Parent themes cannot be uninstalled.';
     }
     return $messages;
 }
コード例 #3
0
 public function testGetByFullPath()
 {
     $path = 'frontend/Magento/luma';
     $collectionFactory = $this->getMock('Magento\\Theme\\Model\\ResourceModel\\Theme\\CollectionFactory', ['create'], [], '', false);
     $collectionMock = $this->getMock('Magento\\Theme\\Model\\ResourceModel\\Theme\\Collection', [], [], '', false);
     $theme = $this->getMock('Magento\\Framework\\View\\Design\\ThemeInterface', [], [], '', false);
     $collectionMock->expects($this->once())->method('getThemeByFullPath')->with($path)->will($this->returnValue($theme));
     $collectionFactory->expects($this->once())->method('create')->will($this->returnValue($collectionMock));
     $themeFactory = $this->getMock('\\Magento\\Theme\\Model\\ThemeFactory', [], [], '', false);
     $themeProvider = new ThemeProvider($collectionFactory, $themeFactory);
     $this->assertSame($theme, $themeProvider->getThemeByFullPath($path));
 }
コード例 #4
0
 /**
  * Remove all records related to the theme(s) in the database
  *
  * @param string[] $themePaths
  * @return void
  */
 private function removeFromDb(array $themePaths)
 {
     foreach ($themePaths as $themePath) {
         $this->themeProvider->getThemeByFullPath($themePath)->delete();
     }
 }