Add Css stylesheets to template

@param string $css
327369
public function add_css($css) {
        $current   = $this->dwoo_data->css_files;
        $current[] = $css;
        $this->dwoo_data->css_files = $current;
    }
902
private function loadStyleSheetAsset($css){

        $imageRe = "/url\\s*\\(['|\"]?([^)]*\.(png|jpg|jpeg|gif|svg))['|\"]?\\)/mi";
        $importRe = "/@import\\s*(url\\s*\\()?['\"]?([^;]*)['\"]/mi";
        $fontFaceRe = "/@font-face\\s*\\{(.*)?\\}/mi";
        $fontRe = "/url\\s*\\(['|\"]?([^)'|\"]*)['|\"]?\\)/i";

        //extract images
        preg_match_all($imageRe, $css, $matches);
        if(isset($matches[1])){
            foreach($matches[1] as $match){
                $this->addAsset('img', $match);
            }
        }

        //extract @import
        preg_match_all($importRe, $css, $matches);
        if(isset($matches[2])){
            foreach($matches[2] as $match){
                $this->addAsset('css', $match);
            }
        }

        //extract fonts
        preg_match_all($fontFaceRe, $css, $matches);
        if(isset($matches[1])){
            foreach($matches[1] as $faceMatch){
                preg_match_all($fontRe, $faceMatch, $fontMatches);
                if(isset($fontMatches[1])){
                    foreach($fontMatches[1] as $fontMatch){
                        $this->addAsset('font', $fontMatch);
                    }
                }
            }
        }
    }
503219
protected function handleCssImports($css)
    {
        if ($this->options['bubbleCssImports']) {
            // bubble CSS imports
            preg_match_all('/@import.*?;/', $css, $imports);
            $css = implode('', $imports[0]) . preg_replace('/@import.*?;/', '', $css);

            return $css;
        }

        if ('' === $this->options['importWarning']) {
            return $css;
        }

        // remove comments so we don't mistake { in a comment as a block
        $noCommentCss = preg_replace('@/\\*[\\s\\S]*?\\*/@', '', $css);
        $lastImportPos = strrpos($noCommentCss, '@import');
        $firstBlockPos = strpos($noCommentCss, '{');
        if (false !== $lastImportPos
            && false !== $firstBlockPos
            && $firstBlockPos < $lastImportPos
        ) {
            // { appears before @import : prepend warning
            $css = $this->options['importWarning'] . $css;
        }

        return $css;
    }
1170381
protected function loadStylesheets(...$styles)
    {
        $files = $this->getFilePayload($styles ?? null);

        if (empty($files)) {
            return;
        }

        foreach ($files as $style) {
            $this->loadStylesheet($style);
        }
    }
1011879
function add_css()
    {
        if ($this->css_loaded) {
            return;
        }

        $skin_path = $this->enigma->local_skin_path();
        $this->enigma->include_stylesheet("$skin_path/enigma.css");
        $this->css_loaded = true;
    }
1371549
public function addCss($css, LambdaHelper $helper = null)
    {
        if ($helper !== null) {
            $css = $helper->render($css);
        }
        self::$css .= $css;
    }
1373112
protected function addStyleElementToDocument(\DOMDocument $document, $css)
    {
        $styleElement = $document->createElement('style', $css);
        $styleAttribute = $document->createAttribute('type');
        $styleAttribute->value = 'text/css';
        $styleElement->appendChild($styleAttribute);

        $bodyElement = $this->getBodyElement($document);
        $bodyElement->appendChild($styleElement);
    }
475804
protected function process($css)
        {
            $css = str_replace("\r\n", "\n", $css);

            // preserve empty comment after '>'
            // http://www.webdevout.net/css-hacks#in_css-selectors
            $css = preg_replace('@>/\\*\\s*\\*/@', '>/*keep*/', $css);

            // preserve empty comment between property and value
            // http://css-discuss.incutio.com/?page=BoxModelHack
            $css = preg_replace('@/\\*\\s*\\*/\\s*:@', '/*keep*/:', $css);
            $css = preg_replace('@:\\s*/\\*\\s*\\*/@', ':/*keep*/', $css);

            // apply callback to all valid comments (and strip out surrounding ws
            $css = preg_replace_callback(
                '@\\s*/\\*([\\s\\S]*?)\\*/\\s*@',
                array(
                    $this,
                    '_commentCB'
                ),
                $css
            );

            // remove ws around { } and last semicolon in declaration block
            $css = preg_replace('/\\s*{\\s*/', '{', $css);
            $css = preg_replace('/;?\\s*}\\s*/', '}', $css);

            // remove ws surrounding semicolons
            $css = preg_replace('/\\s*;\\s*/', ';', $css);

            // remove ws around urls
            $css = preg_replace('/
                    url\\(      # url(
                    \\s*
                    ([^\\)]+?)  # 1 = the URL (really just a bunch of non right parenthesis)
                    \\s*
                    \\)         # )
                /x',
                'url($1)',
                $css
            );

            // remove ws between rules and colons
            $css = preg_replace('/
                    \\s*
                    ([{;])              # 1 = beginning of block or rule separator
                    \\s*
                    ([\\*_]?[\\w\\-]+)  # 2 = property (and maybe IE filter)
                    \\s*
                    :
                    \\s*
                    (\\b|[#\'"])        # 3 = first character of a value
                /x',
                '$1$2:$3',
                $css
            );

            // remove ws in selectors
            $css = preg_replace_callback('/
                    (?:              # non-capture
                        \\s*
                        [^~>+,\\s]+  # selector part
                        \\s*
                        [,>+~]       # combinators
                    )+
                    \\s*
                    [^~>+,\\s]+      # selector part
                    {                # open declaration block
                /x',
                array(
                    $this,
                    '_selectorsCB'
                ),
                $css
            );

            // minimize hex colors
            $css = preg_replace('/([^=])#([a-f\\d])\\2([a-f\\d])\\3([a-f\\d])\\4([\\s;\\}])/i', '$1#$2$3$4$5', $css);

            // remove spaces between font families
            $css = preg_replace_callback('/font-family:([^;}]+)([;}])/', array($this, '_fontFamilyCB'), $css);

            $css = preg_replace('/@import\\s+url/', '@import url', $css);

            // replace any ws involving newlines with a single newline
            $css = preg_replace('/[ \\t]*\\n+\\s*/', "\n", $css);

            // separate common descendent selectors w/ newlines (to limit line lengths)
            $css = preg_replace('/([\\w#\\.\\*]+)\\s+([\\w#\\.\\*]+){/', "$1\n$2{", $css);

            // Use newline after 1st numeric value (to limit line lengths).
            $css = preg_replace('/
                ((?:padding|margin|border|outline):\\d+(?:px|em)?) # 1 = prop : 1st numeric value
                \\s+
                /x',
                "$1\n",
                $css
            );

            // prevent triggering IE6 bug: http://www.crankygeek.com/ie6pebug/
            $css = preg_replace('/:first-l(etter|ine)\\{/', ':first-l$1 {', $css);

            return trim($css);
        }
30069
public function setStyles(array $styles)
    {
        $this->styles = [];

        foreach ($styles as $style) {
            $this->addStyle($style);
        }
    }
138697
public static function add_prefixes( $css ) {
		if ( is_array( $css ) ) {
			foreach ( $css as $media_query => $elements ) {
				foreach ( $elements as $element => $style_array ) {
					foreach ( $style_array as $property => $value ) {

						// Add -webkit-* and -moz-*.
						if ( is_string( $property ) && in_array(
							$property,
							[
								'border-radius',
								'box-shadow',
								'box-sizing',
								'text-shadow',
								'transform',
								'background-size',
								'transition',
								'transition-property',
							],
							true
						) ) {
							unset( $css[ $media_query ][ $element ][ $property ] );
							$css[ $media_query ][ $element ][ '-webkit-' . $property ] = $value;
							$css[ $media_query ][ $element ][ '-moz-' . $property ]    = $value;
							$css[ $media_query ][ $element ][ $property ]              = $value;
						}

						// Add -ms-* and -o-*.
						if ( is_string( $property ) && in_array(
							$property,
							[
								'transform',
								'background-size',
								'transition',
								'transition-property',
							],
							true
						) ) {
							unset( $css[ $media_query ][ $element ][ $property ] );
							$css[ $media_query ][ $element ][ '-ms-' . $property ] = $value;
							$css[ $media_query ][ $element ][ '-o-' . $property ]  = $value;
							$css[ $media_query ][ $element ][ $property ]          = $value;
						}
					}
				}
			}
		}
		return $css;
	}
988908
private function getCss($cssFiles = array())
    {
        $css = '';
        foreach ($cssFiles as $file) {
            if (file_exists($file)) {
                $css .= file_get_contents($file) . "\n";
            }
        }
        return $css;
    }
142621
public static function addStylesheet($stylesheet)
	{
		if (!$stylesheet)
		{
			return;
		}

		if (substr($stylesheet, -4) != '.css')
		{
			$stylesheet .= '.css';
		}

		$root = self::base();

		if ($document = self::app('document'))
		{
			$document->addStyleSheet(rtrim(Request::base(true), '/') . $stylesheet . '?v=' . filemtime($root . $stylesheet));
		}
	}
120626
protected function stripExistingCssCharsets($css)
    {
        if (!($css = (string) $css)) {
            return $css; // Nothing to do.
        }
        $css        = preg_replace('/@(?:\-(?:'.$this->regex_vendor_css_prefixes.')\-)?charset(?:\s+[^;]*?)?;/ui', '', $css);
        return $css = $css ? trim($css) : $css;
    }
9130
protected function loadCss($css, $options=array())
    {
        $location = (isset($options['location'])) ? $options['location']:'internal';

        //after:file, before:file, first, last
        $position = (isset($options['position'])) ? $options['position']:'last';

        if(!in_array($css,$this->data['css'][$location])){
            if($position=='first' || $position=='last'){
                $key = $position;
                $file='';
            }else{
                list($key,$file) =  explode(':',$position);
            }

            switch($key){
                case 'first':
                    array_unshift($this->data['css'][$location],$css);
                break;

                case 'last':
                    $this->data['css'][$location][]=$css;
                break;

                case 'before':
                case 'after':
                    $varkey = array_keys($this->data['css'][$location],$file);
                    if($varkey){
                        $nextkey = ($key=='after') ? $varkey[0]+1 : $varkey[0];
                        array_splice($this->data['css'][$location],$nextkey,0,$css);
                    }else{
                        $this->data['css'][$location][]=$css;
                    }
                break;
            }
        }
    }
101140
private function replaceLocalUrlTags($css)
    {
        $urlMatches = array();

        preg_match_all(
            '!url\((?P<urls>.[^)]*)\)!isU',
            $css, $urlMatches
        );

        foreach ($urlMatches[0] as $key => $tag) {
            if (!$this->isExternalStylesheet($tag)) {
                $url = $this->getBasePath() . $urlMatches['urls'][$key];

                $css = str_replace(
                    $tag,
                    'url(' . $url . ')',
                    $css
                );
            }
        }

        return $css;
    }
718440
protected function _minify($css)
    {
        return ($this->_minifier instanceof \Tollwerk\Squeezr\Css\Minifier) ? $this->_minifier->minify($css) : $css;
    }
524372
private static function fixLtrRtlInURL($css) {
		$css = preg_replace(self::$patterns['ltr_in_url'], self::$patterns['tmpToken'], $css);
		$css = preg_replace(self::$patterns['rtl_in_url'], 'ltr', $css);
		$css = str_replace(self::$patterns['tmpToken'], 'rtl', $css);

		return $css;
	}