Beispiel #1
0
 /**
  * Compile the css for a platform and a theme just as a preview
  *
  * @param ServiceBase $api
  * @param array $args
  *
  * @return string Plaintext css
  */
 public function previewCSS(ServiceBase $api, array $args)
 {
     // If `preview` is defined, it means that the call was made by the Theme Editor in Studio so we want to return
     // plain text/css
     // Validating arguments
     $platform = isset($args['platform']) ? $args['platform'] : 'base';
     $themeName = isset($args['themeName']) ? $args['themeName'] : 'default';
     $minify = isset($args['min']) ? true : false;
     $theme = new SidecarTheme($platform, $themeName);
     $theme->loadVariables();
     $theme->setVariables($args);
     $theme->setVariable('baseUrl', '"../../styleguide/assets"');
     $api->setHeader('Content-type', 'text/css');
     $css = $theme->previewCss($minify);
     $api->setHeader('Content-Length', strlen($css));
     echo $css;
     return;
 }