You are here

class SassExtentionsCompassConfig in Sassy 7

Compass extension configuration class. @package PHamlP @subpackage Sass.extensions.compass

Hierarchy

Expanded class hierarchy of SassExtentionsCompassConfig

File

phamlp/sass/extensions/compass/config.php, line 17

View source
class SassExtentionsCompassConfig {
  public static $config;
  private static $defaultConfig = array(
    'project_path' => '',
    'http_path' => '/',
    'css_dir' => 'css',
    'css_path' => '',
    'http_css_path' => '',
    'fonts_dir' => 'fonts',
    'fonts_path' => '',
    'http_fonts_path' => '',
    'images_dir' => 'images',
    'images_path' => '',
    'http_images_path' => '',
    'javascripts_dir' => 'javascripts',
    'javascripts_path' => '',
    'http_javascripts_path' => '',
    'relative_assets' => true,
  );

  /**
   * Sets configuration settings or returns a configuration setting.
   * @param mixed array: configuration settings; string: configuration setting to return
   * @return string configuration setting. Null if setting does not exist.
   */
  public function config($config) {
    if (is_array($config)) {
      self::$config = array_merge(self::$defaultConfig, $config);
      self::setDefaults();
    }
    elseif (is_string($config) && isset(self::$config[$config])) {
      return self::$config[$config];
    }
  }

  /**
   * Sets default values for paths not specified
   */
  private static function setDefaults() {
    foreach (array(
      'css',
      'images',
      'fonts',
      'javascripts',
    ) as $asset) {
      if (empty(self::$config[$asset . '_path'])) {
        self::$config[$asset . '_path'] = self::$config['project_path'] . DIRECTORY_SEPARATOR . self::$config[$asset . '_dir'];
      }
      if (empty(self::$config['http_' . $asset . '_path'])) {
        self::$config['http_' . $asset . '_path'] = self::$config['http_path'] . self::$config[$asset . '_dir'];
      }
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
SassExtentionsCompassConfig::$config public static property
SassExtentionsCompassConfig::$defaultConfig private static property
SassExtentionsCompassConfig::config public function * Sets configuration settings or returns a configuration setting. *
SassExtentionsCompassConfig::setDefaults private static function * Sets default values for paths not specified