/**
  * Retrieve list of unknown themes
  *
  * @param string[] $themePaths
  * @return string[]
  */
 protected function getUnknownThemes($themePaths)
 {
     $result = [];
     foreach ($themePaths as $themePath) {
         if (!$this->themeCollection->hasTheme($this->themeCollection->getThemeByFullPath($themePath))) {
             $result[] = $themePath;
         }
     }
     return $result;
 }
Example #2
0
 /**
  * Validate given full theme paths
  *
  * @param string[] $themePaths
  * @return string[]
  */
 private function validate($themePaths)
 {
     $messages = [];
     $unknownPackages = [];
     $unknownThemes = [];
     $installedPackages = $this->composer->getRootRequiredPackages();
     foreach ($themePaths as $themePath) {
         if (array_search($this->getPackageName($themePath), $installedPackages) === false) {
             $unknownPackages[] = $themePath;
         }
         if (!$this->themeCollection->hasTheme($this->themeCollection->getThemeByFullPath($themePath))) {
             $unknownThemes[] = $themePath;
         }
     }
     $unknownPackages = array_diff($unknownPackages, $unknownThemes);
     if (!empty($unknownPackages)) {
         $text = count($unknownPackages) > 1 ? ' are not installed Composer packages' : ' is not an installed Composer package';
         $messages[] = '<error>' . implode(', ', $unknownPackages) . $text . '</error>';
     }
     if (!empty($unknownThemes)) {
         $messages[] = '<error>Unknown theme(s): ' . implode(', ', $unknownThemes) . '</error>';
     }
     return $messages;
 }