/
Compiler.php
34 lines (30 loc) · 1.29 KB
/
Compiler.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<?php
namespace Concrete\Core\StyleCustomizer\Compiler;
use Concrete\Core\Entity\Page\Theme\CustomSkin;
use Concrete\Core\StyleCustomizer\Customizer\Customizer;
use Concrete\Core\StyleCustomizer\Customizer\Type\TypeInterface;
use Concrete\Core\StyleCustomizer\Normalizer\NormalizedVariableCollection;
use Concrete\Core\StyleCustomizer\Preset\PresetInterface;
class Compiler
{
/**
* @param Customizer $customizer
* @param PresetInterface $preset
* @param NormalizedVariableCollection $collection
* @return string
*/
public function compileFromPreset(Customizer $customizer, PresetInterface $preset, NormalizedVariableCollection $collection): string
{
$customizerType = $customizer->getType();
$presetType = $customizerType->getPresetType();
$processor = $customizerType->getStyleProcessor();
$file = $presetType->getEntryPointFile($preset);
$css = $processor->compileFileToString($file, $collection);
return $css;
}
public function compileFromCustomSkin(Customizer $customizer, CustomSkin $skin, NormalizedVariableCollection $collection): string
{
$preset = $customizer->getPresetByIdentifier($skin->getPresetStartingPoint());
return $this->compileFromPreset($customizer, $preset, $collection);
}
}