Beispiel #1
0
 protected function getCssContents()
 {
     /** @var HtmlThemeInterface $theme */
     $theme = $this->theme;
     // check last modification
     $lastModification = 0;
     foreach ($theme->getHtmlCssDependencies() as $item) {
         $filename = $theme->getResourcesPath() . $item;
         if (file_exists($filename)) {
             $lastModification = max($lastModification, filemtime($filename));
         }
     }
     // cache
     $cacheFile = sprintf('%s/ladybug_cache/theme/%s.css', sys_get_temp_dir(), $theme->getName());
     $lastModificationCache = file_exists($cacheFile) ? filemtime($cacheFile) : -1;
     if ($lastModification > $lastModificationCache) {
         $pce = new \CssEmbed\CssEmbed();
         $css = '';
         foreach ($theme->getHtmlCssDependencies() as $item) {
             $file = $theme->getResourcesPath() . $item;
             $minCss = file_get_contents($file);
             $pce->setRootDir(dirname($file));
             $css .= $pce->embedString($minCss);
         }
         if (!is_dir(dirname($cacheFile))) {
             mkdir(dirname($cacheFile));
         }
         file_put_contents($cacheFile, $css);
     } else {
         $css = file_get_contents($cacheFile);
     }
     return $css;
 }
Beispiel #2
0
#!/usr/bin/php
<?php 
$config = ['git_urls' => ['https://github.com/krichprollsch/phpCssEmbed.git' => 'cssembed/'], 'autoload_config' => ['cssembed/src/CssEmbed/' => 'CssEmbed'], 'example' => function () {
    $css = '.test { display: none; }';
    $pce = new \CssEmbed\CssEmbed();
    echo $pce->embedString($css);
}];
if ($return_config) {
    return $config;
}
require_once __DIR__ . '/_yf_autoloader.php';
new yf_autoloader($config);