src/PHPDish/Bundle/ThemeBundle/CacheWarmer/TemplatePathsCacheWarmer.php
public function warmUp($cacheDir)
    {

        /** @var TemplateReferenceInterface[] $allTemplates */
        $allTemplates = $this->finder->findAllTemplates();
        $filesystem = new Filesystem();
        $templates = array();

        // 不用主题
        $themes = $this->themeManager->getThemes();
        array_unshift($themes, null);
        foreach ($themes as $theme) {
            $keySuffix = $theme ? '|' . $theme->getName() : '';
            foreach ($allTemplates as $template) {
                $this->themeManager->setCurrentTheme($theme); //覆盖当前主题
                $key = $template->getLogicalName() . $keySuffix;
                $templates[$key]
                    = rtrim($filesystem->makePathRelative($this->locator->locate($template), $cacheDir), '/');
            }
        }

        $templates = str_replace("' => '", "' => __DIR__.'/", var_export($templates, true));
        $this->writeCacheFile($cacheDir.'/templates.php', sprintf("<?php return %s;\n", $templates));
    }
public function warmUp($cacheDir)
    {

        /** @var TemplateReferenceInterface[] $allTemplates */
        $allTemplates = $this->finder->findAllTemplates();
        $filesystem = new Filesystem();
        $templates = array();

        // 不用主题
        $themes = $this->themeManager->getThemes();
        array_unshift($themes, null);
        foreach ($themes as $theme) {
            $keySuffix = $theme ? '|' . $theme->getName() : '';
            foreach ($allTemplates as $template) {
                $this->themeManager->setCurrentTheme($theme); //覆盖当前主题
                $key = $template->getLogicalName() . $keySuffix;
                $templates[$key]
                    = rtrim($filesystem->makePathRelative($this->locator->locate($template), $cacheDir), '/');
            }
        }

        $templates = str_replace("' => '", "' => __DIR__.'/", var_export($templates, true));
        $this->writeCacheFile($cacheDir.'/templates.php', sprintf("<?php return %s;\n", $templates));
    }
{@inheritdoc}