Extend like function to merge an array of preferences into the options array.

Paramètres

(mixed) options: Array of preferences to merge into options:

1 call to CSSCompression_Option::merge()
CSSCompression_Option::option dans advagg_css_compress/css-compressor-3.x/src/lib/Option.inc
Maintainable access to the options array

Fichier

advagg_css_compress/css-compressor-3.x/src/lib/Option.inc, line 78

Classe

CSSCompression_Option
CSS Compressor [VERSION] [DATE] Corey Hart @ http://www.codenothing.com

Code

public function merge($options = array()) {
    $modes = CSSCompression::modes();
    if ($options && is_array($options) && count($options)) {
        $this->Control->mode = $this->custom;
        foreach ($this->options as $key => $value) {
            if (!isset($options[$key])) {
                continue;
            }
            else {
                if (strtolower($options[$key]) == 'on') {
                    $this->options[$key] = true;
                }
                else {
                    if (strtolower($options[$key]) == 'off') {
                        $this->options[$key] = false;
                    }
                    else {
                        $this->options[$key] = intval($options[$key]);
                    }
                }
            }
        }
    }
    else {
        if ($options && is_string($options) && array_key_exists($options, $modes)) {
            $this->Control->mode = $options;
            // Default all to true, the mode has to force false
            foreach ($this->options as $key => $value) {
                if ($key != 'readability') {
                    $this->options[$key] = true;
                }
            }
            // Merge mode into options
            foreach ($modes[$options] as $key => $value) {
                $this->options[$key] = $value;
            }
        }
    }
    return $this->options;
}