/**
  * @param ThemeInterface $mainTheme
  *
  * @return array
  */
 private function extractResourcesFromTheme(ThemeInterface $mainTheme)
 {
     /** @var ThemeInterface[] $themes */
     $themes = array_reverse($this->themeHierarchyProvider->getThemeHierarchy($mainTheme));
     $resources = [];
     foreach ($themes as $theme) {
         $paths = $this->translationFilesFinder->findTranslationFiles($theme->getPath());
         foreach ($paths as $path) {
             $resources[] = new ThemeTranslationResource($mainTheme, $path);
         }
     }
     return $resources;
 }
 public function findTranslationFiles(ThemeInterface $theme)
 {
     $files = $this->translationFilesFinder->findTranslationFiles($theme);
     /**
      * PHP 5.* bug, fixed in PHP 7: https://bugs.php.net/bug.php?id=50688
      * "usort(): Array was modified by the user comparison function"
      */
     @usort($files, function ($firstFile, $secondFile) use($theme) {
         $firstFile = str_replace($theme->getPath(), '', $firstFile);
         $secondFile = str_replace($theme->getPath(), '', $secondFile);
         return strpos($secondFile, 'translations') - strpos($firstFile, 'translations');
     });
     return $files;
 }
 function it_puts_application_translations_files_before_bundle_translations_files(TranslationFilesFinderInterface $translationFilesFinder, ThemeInterface $theme)
 {
     $translationFilesFinder->findTranslationFiles($theme)->willReturn(['/some/path/to/theme/AcmeBundle/messages.en.yml', '/some/path/to/theme/translations/messages.en.yml', '/some/path/to/theme/YcmeBundle/messages.en.yml']);
     $this->findTranslationFiles($theme)->shouldHaveFirstElement('/some/path/to/theme/translations/messages.en.yml');
 }
 function it_returns_resources_locales_while_using_more_than_one_theme(TranslationFilesFinderInterface $translationFilesFinder, ThemeRepositoryInterface $themeRepository, ThemeHierarchyProviderInterface $themeHierarchyProvider, ThemeInterface $mainTheme, ThemeInterface $parentTheme)
 {
     $themeRepository->findAll()->willReturn([$mainTheme, $parentTheme]);
     $themeHierarchyProvider->getThemeHierarchy($mainTheme)->willReturn([$mainTheme, $parentTheme]);
     $themeHierarchyProvider->getThemeHierarchy($parentTheme)->willReturn([$parentTheme]);
     $mainTheme->getPath()->willReturn('/main/theme/path');
     $mainTheme->getName()->willReturn('main-theme/name');
     $parentTheme->getPath()->willReturn('/parent/theme/path');
     $parentTheme->getName()->willReturn('parent-theme/name');
     $translationFilesFinder->findTranslationFiles('/main/theme/path')->willReturn(['/main/theme/path/messages.en.yml']);
     $translationFilesFinder->findTranslationFiles('/parent/theme/path')->willReturn(['/parent/theme/path/messages.en.yml']);
     $this->getResourcesLocales()->shouldReturn(['en@main-theme-name', 'en@parent-theme-name']);
 }