Elgg  Version 3.0
CssCompiler.php
Go to the documentation of this file.
1 <?php
2 
3 namespace Elgg\Assets;
4 
5 use Elgg\Config;
6 use Elgg\Includer;
9 
15 class CssCompiler {
16 
20  protected $config;
21 
25  protected $hooks;
26 
34  $this->config = $config;
35  $this->hooks = $hooks;
36  }
37 
46  public function compile($css, array $options = []) {
47  $defaults = [
48  'minify' => false, // minify handled by _elgg_views_minify
49  'formatter' => 'single-line', // shows lowest byte size
50  'versioning' => false, // versioning done by Elgg
51  'rewrite_import_urls' => false,
52  ];
53 
54  $config = (array) $this->config->css_compiler_options;
55 
56  $options = array_merge($defaults, $config, $options);
57 
58  $default_vars = $this->getDefaultVars();
59  $custom_vars = (array) elgg_extract('vars', $options, []);
60  $vars = array_merge($default_vars, $custom_vars);
61 
62  $options['vars'] = $this->hooks->trigger('vars:compiler', 'css', $options, $vars);
63 
64  return csscrush_string($css, $options);
65  }
66 
71  protected function getDefaultVars() {
72  $file = Paths::elgg() . 'engine/theme.php';
74  }
75 }
static includeFile($file)
Include a file with as little context as possible.
Definition: Includer.php:18
if(!array_key_exists($filename, $text_files)) $file
static elgg()
Get the Elgg codebase path with "/".
Definition: Paths.php:44
$defaults
getDefaultVars()
Default Elgg theme variables.
Definition: CssCompiler.php:71
$css
Definition: maintenance.php:16
$options
Elgg admin footer.
Definition: footer.php:6
__construct(Config $config, PluginHooksService $hooks)
Constructor.
Definition: CssCompiler.php:33
compile($css, array $options=[])
Compile CSS.
Definition: CssCompiler.php:46
elgg_extract($key, $array, $default=null, $strict=true)
Checks for $array[$key] and returns its value if it exists, else returns $default.
Definition: elgglib.php:1131
Compile CSS with CSSCrush.
Definition: CssCompiler.php:15
$vars['type']
Definition: save.php:11