public static function loadFromFile($file, $urlroot = false) { $extractor = Core::make('Concrete\\Package\\AssetPipeline\\Src\\Asset\\UtilityInterface')->getValueExtractorForFile($file, $urlroot); if (!is_object($extractor)) { throw new Exception(t("Invalid file for value extraction: %s", $file)); } $vl = new static(); $bv = new BasicValue('preset-fonts-file'); $bv->setValue($extractor->extractFontsFile()); $vl->addValue($bv); foreach (array('ColorStyle', 'TypeStyle', 'ImageStyle', 'SizeStyle') as $type) { $cls = '\\Concrete\\Core\\StyleCustomizer\\Style\\' . $type; $o = new $cls(); if (!$o instanceof ExtractableStyleInterface) { throw new Exception(t("The following style type is not extractable: %s", $type)); } $values = $o->getValuesFromExtractor($extractor); $vl->addValues($values); } return $vl; }
public static function loadFromLessFile($file, $urlroot = false) { $l = new Less_Parser(); $parser = $l->parseFile($file, $urlroot, true); $vl = new static(); $rules = $parser->rules; // load required preset variables. foreach ($rules as $rule) { if (preg_match('/@preset-fonts-file/i', isset($rule->name) ? $rule->name : '', $matches)) { $value = $rule->value->value[0]->value[0]->value; $bv = new BasicValue('preset-fonts-file'); $bv->setValue($value); $vl->addValue($bv); } } foreach (array('ColorStyle', 'TypeStyle', 'ImageStyle', 'SizeStyle') as $type) { $o = '\\Concrete\\Core\\StyleCustomizer\\Style\\' . $type; $values = call_user_func_array(array($o, 'getValuesFromVariables'), array($rules)); $vl->addValues($values); } return $vl; }