You are here

public function SassParser::__construct in Sassy 7.3

Same name and namespace in other branches
  1. 7 phamlp/sass/SassParser.php \SassParser::__construct()

Constructor. Sets parser options

Parameters

array $options:

Return value

SassParser

File

phpsass/SassParser.php, line 309

Class

SassParser
SassParser class. Parses {@link http://sass-lang.com/ .sass and .sccs} files. @package PHamlP @subpackage Sass

Code

public function __construct($options = array()) {
  if (!is_array($options)) {
    if (isset($options['debug']) && $options['debug']) {
      throw new SassException('Options must be an array');
    }
    $options = count((array) $options) ? (array) $options : array();
  }
  if (!empty($options['vendor_properties'])) {
    if ($options['vendor_properties'] === true) {
      $this->vendor_properties = $this->_vendorProperties;
    }
    elseif (is_array($options['vendor_properties'])) {
      $this->vendor_properties = array_merge($this->_vendorProperties, $options['vendor_properties']);
    }
  }
  unset($options['language'], $options['vendor_properties']);
  $basepath = $_SERVER['PHP_SELF'];
  $basepath = substr($basepath, 0, strrpos($basepath, '/') + 1);
  $defaultOptions = array(
    'basepath' => $basepath,
    'cache' => self::CACHE,
    'cache_location' => dirname(__FILE__) . DIRECTORY_SEPARATOR . self::CACHE_LOCATION,
    'css_location' => dirname(__FILE__) . DIRECTORY_SEPARATOR . self::CSS_LOCATION,
    'debug_info' => FALSE,
    'filename' => array(
      'dirname' => '',
      'basename' => '',
    ),
    'functions' => array(),
    'load_paths' => array(),
    'load_path_functions' => array(),
    'line' => 1,
    'line_numbers' => FALSE,
    'style' => SassRenderer::STYLE_NESTED,
    'syntax' => SassFile::SASS,
    'debug' => FALSE,
  );
  $options = array_merge($defaultOptions, $options);
  self::$functions = $options['functions'];
  unset($options['functions']);
  foreach ($options as $name => $value) {
    if (property_exists($this, $name)) {
      $this->{$name} = $value;
    }
  }
  self::$instance = $this;
  $GLOBALS['SassParser_debug'] = $this->debug;
}