engine.lessphp.inc 966 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. /**
  3. * Class \LessEngineLessphp
  4. */
  5. class LessEngineLessphp extends LessEngine {
  6. /**
  7. * @var \lessc
  8. */
  9. private $less_php_parser;
  10. /**
  11. * Instantiates new instances of \lessc.
  12. *
  13. * @param string $input_file_path
  14. *
  15. * @see \lessc
  16. */
  17. public function __construct($input_file_path) {
  18. parent::__construct($input_file_path);
  19. $this->less_php_parser = new lessc();
  20. }
  21. /**
  22. * {@inheritdoc}
  23. * This compiles using engine specific function calls.
  24. */
  25. public function compile() {
  26. $compiled_styles = NULL;
  27. try {
  28. foreach ($this->import_directories as $directory) {
  29. $this->less_php_parser->addImportDir($directory);
  30. }
  31. $cache = $this->less_php_parser->cachedCompile($this->input_file_path);
  32. $this->dependencies = array_keys($cache['files']);
  33. $compiled_styles = $cache['compiled'];
  34. }
  35. catch (Exception $e) {
  36. throw $e;
  37. }
  38. return $compiled_styles;
  39. }
  40. }