/** * @return \Generator */ private function getPathMacros() { foreach (array_reverse($this->themeConfig->getTwigTemplatePaths()) as $path) { $pathMacros = glob($path . '/macros/*'); foreach ($pathMacros as $pathMacro) { $name = basename($pathMacro, '.twig'); $filename = basename($pathMacro); (yield $name => 'macros/' . $filename); } } }
/** * @param string $rootScssDirectory * @param TwigThemeConfig $themeConfig * @param string | null $formatter * @param string | null $cacheDir */ public function __construct($rootScssDirectory, TwigThemeConfig $themeConfig, $formatter = 'compressed', $cacheDir = null) { $scssImportPaths = $themeConfig->getScssImportPaths(); $scssCompiler = new Compiler(); $scssCompiler->setImportPaths($scssImportPaths); $this->salt = $formatter . $rootScssDirectory . json_encode($scssImportPaths); switch ($formatter) { case 'expanded': $scssCompiler->setFormatter(\Leafo\ScssPhp\Formatter\Expanded::class); break; case 'compact': $scssCompiler->setFormatter(\Leafo\ScssPhp\Formatter\Compact::class); break; case 'compressed': $scssCompiler->setFormatter(\Leafo\ScssPhp\Formatter\Compressed::class); break; } $this->server = new Server($rootScssDirectory, $cacheDir, $scssCompiler); $this->server->showErrorsAsCSS(true); }
/** * @return TwigThemeConfig */ protected function getThemeConfig() { $themePath = TwigThemeConfig::getThemePath(env('THEME')); $themeConfig = TwigThemeConfig::loadConfig($themePath); return $themeConfig; }
<?php use inklabs\KommerceTemplates\Lib\TwigThemeConfig; $config = new TwigThemeConfig('Bootstrap', 'Deprecated Bootstrap theme', __DIR__, TwigThemeConfig::getBaseThemePath()); $config->addScssImportPath(realpath(__DIR__ . '/../../../../../vendor') . '/twbs/bootstrap-sass/assets/stylesheets'); return $config;
<?php use inklabs\KommerceTemplates\Lib\TwigThemeConfig; return new TwigThemeConfig('Cardinal', 'The default theme for 2016', __DIR__, TwigThemeConfig::getThemePath('bootstrap'));
<?php use inklabs\KommerceTemplates\Lib\TwigThemeConfig; return new TwigThemeConfig('Vintage', 'Minimal theme extending from Cardinal', __DIR__, TwigThemeConfig::getThemePath('cardinal'));
<?php use inklabs\KommerceTemplates\Lib\TwigThemeConfig; return new TwigThemeConfig('Foundation', 'Deprecated Foundation theme', __DIR__, TwigThemeConfig::getBaseThemePath());