You are here

class LessEngineLess_php in Less CSS Preprocessor 7.4

Same name and namespace in other branches
  1. 8 engines/engine.less_php.inc \LessEngineLess_php

Class \LessEngineLess_php

Hierarchy

Expanded class hierarchy of LessEngineLess_php

1 string reference to 'LessEngineLess_php'
less_less_engines in ./less.module
Implements hook_less_engines().

File

engines/engine.less_php.inc, line 6

View source
class LessEngineLess_php extends LessEngine {

  /**
   * @var \Less_Parser
   */
  private $less_php_parser;

  /**
   * Instantiates new instances of \Less_Parser.
   *
   * @param string $input_file_path
   *
   * @see \Less_Parser
   */
  public function __construct($input_file_path) {
    parent::__construct($input_file_path);
    $this->less_php_parser = new Less_Parser();
  }

  /**
   * {@inheritdoc}
   * This compiles using engine specific function calls.
   */
  public function compile() {
    $compiled_styles = NULL;
    try {
      if ($this->source_maps_enabled) {
        $this->less_php_parser
          ->SetOption('sourceMap', $this->source_maps_enabled);
        $this->less_php_parser
          ->SetOption('sourceMapBasepath', $this->source_maps_base_path);
        $this->less_php_parser
          ->SetOption('sourceMapRootpath', $this->source_maps_root_path);
      }

      // Less.js does not allow path aliasing. Set aliases to blank for consistency.
      $this->less_php_parser
        ->SetImportDirs(array_fill_keys($this->import_directories, ''));
      $this->less_php_parser
        ->parseFile($this->input_file_path);
      $this->less_php_parser
        ->ModifyVars($this->variables);
      $compiled_styles = $this->less_php_parser
        ->getCss();
      $this->dependencies = $this->less_php_parser
        ->AllParsedFiles();
    } catch (Exception $e) {
      throw $e;
    }
    return $compiled_styles;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
LessEngine::$dependencies protected property This will get populated with a list of files that $input_file_path depended on through @import statements.
LessEngine::$import_directories protected property List of directories that are to be used for @import lookups.
LessEngine::$input_file_path protected property Path to the input .less file.
LessEngine::$source_maps_base_path protected property
LessEngine::$source_maps_enabled protected property Flag if source maps are enabled.
LessEngine::$source_maps_root_path protected property
LessEngine::$variables protected property This contains any variables that are to be modified into the output.
LessEngine::getDependencies public function Returns list of dependencies. Overrides LessEngineInterface::getDependencies 1
LessEngine::modifyVariables public function Set/override variables. Overrides LessEngineInterface::modifyVariables
LessEngine::setImportDirectories public function Set list of lookup directories for @import statements. Overrides LessEngineInterface::setImportDirectories
LessEngine::setSourceMaps public function Enable Overrides LessEngineInterface::setSourceMaps
LessEngineLess_php::$less_php_parser private property
LessEngineLess_php::compile public function This compiles using engine specific function calls. Overrides LessEngineInterface::compile
LessEngineLess_php::__construct public function Instantiates new instances of \Less_Parser. Overrides LessEngine::__construct