public function setThemePaths(ThemeInterface $theme, array $overrides = []) { // Allow Theme namespace to access other namespaces foreach ($overrides as $override) { // Get paths we need to override $paths = $this->getPaths($override); // For each path we find, allow @Theme to access it $this->prependPaths($paths, 'Theme'); } // Get Directories $templateDirectories = array_reverse($theme->getTemplateDirectories()); // Setup the Theme Template Paths $this->prependPaths($templateDirectories, 'Theme'); // Setup overrides (So when you call @MyNamespace it will call the theme templates instead) foreach ($overrides as $override) { $this->prependPaths($templateDirectories, $override); } // Create @Parent namespace, don't include the current theme $themeDirectory = $theme->getTemplateDirectories(true); $parentDirectories = array_filter($templateDirectories, function ($directory) use($themeDirectory) { return $themeDirectory !== $directory; }); $this->prependPaths($parentDirectories, 'Parent'); }
protected function checkUniqueness(ThemeInterface $theme, SplFileInfo $themeFile, InputInterface $input, OutputInterface $output) { $parentDirectory = $theme->getTemplateDirectories(true); $parentFile = $parentDirectory . '/' . $themeFile->getRelativePathname(); if ($this->compareFiles($themeFile, $parentFile)) { $question = sprintf('<question>"%s" is the same as the template in the <info>%s</info> theme, would you like to remove it from your current theme?</question>', $themeFile->getRelativePathname(), $theme->getName()); if ($this->getHelper('dialog')->askConfirmation($output, $question, false)) { $this->getFilesystem()->remove($themeFile); $output->writeln('Removed ' . $themeFile); $output->writeln(''); } } if ($theme->getParentTheme()) { $this->checkUniqueness($theme->getParentTheme(), $themeFile, $input, $output); } }