src/View/Helper/LessHelper.php
public function process($source, $force = true)
    {
        list ($webRoot, $source) = $this->_findWebRoot($source);
        $lessFile = FS::clean($webRoot . Configure::read('App.lessBaseUrl') . $source, '/');

        $this->_setForce($force);
        $less = new Less($this->_config);

        if (!FS::isFile($lessFile)) {
            return null;
        }

        list($source, $isExpired) = $less->compile($lessFile);

        if ($isExpired) {
            $cacheId  = FS::firstLine($source);
            $comment  = '/* resource:' . str_replace(FS::clean(ROOT, '/'), '', $lessFile) . ' */' . PHP_EOL;
            $fileHead = implode('', [$cacheId, Str::low($comment)]);

            $css = $this->_normalizeContent($source, $fileHead);
            $this->_write($source, $css);
        }

        $source = str_replace(FS::clean(APP_ROOT . '/' . Configure::read('App.webroot'), '/'), '', $source);

        return $source;
    }
public function process($source, $force = true)
    {
        list ($webRoot, $source) = $this->_findWebRoot($source);
        $lessFile = FS::clean($webRoot . Configure::read('App.lessBaseUrl') . $source, '/');

        $this->_setForce($force);
        $less = new Less($this->_config);

        if (!FS::isFile($lessFile)) {
            return null;
        }

        list($source, $isExpired) = $less->compile($lessFile);

        if ($isExpired) {
            $cacheId  = FS::firstLine($source);
            $comment  = '/* resource:' . str_replace(FS::clean(ROOT, '/'), '', $lessFile) . ' */' . PHP_EOL;
            $fileHead = implode('', [$cacheId, Str::low($comment)]);

            $css = $this->_normalizeContent($source, $fileHead);
            $this->_write($source, $css);
        }

        $source = str_replace(FS::clean(APP_ROOT . '/' . Configure::read('App.webroot'), '/'), '', $source);

        return $source;
    }
public function process ( $ source , $ force = true ) { list ( $ webRoot , $ source ) = $ this -> _findWebRoot ( $ source ) ; $ lessFile = FS :: clean ( $ webRoot . Configure :: read ( 'App.lessBaseUrl' ) . $ source , '/' ) ; $ this -> _setForce ( $ force ) ; $ less = new Less ( $ this -> _config ) ; if ( ! FS :: isFile ( $ lessFile ) ) { return null ; } list ( $ source , $ isExpired ) = $ less -> compile ( $ lessFile ) ; if ( $ isExpired ) { $ cacheId = FS :: firstLine ( $ source ) ; $ comment = '/* resource:' . str_replace ( FS :: clean ( ROOT , '/' ) , '' , $ lessFile ) . ' */' . PHP_EOL ; $ fileHead = implode ( '' , [ $ cacheId , Str :: low ( $ comment ) ] ) ; $ css = $ this -> _normalizeContent ( $ source , $ fileHead ) ; $ this -> _write ( $ source , $ css ) ; } $ source = str_replace ( FS :: clean ( APP_ROOT . '/' . Configure :: read ( 'App.webroot' ) , '/' ) , '' , $ source ) ; return $ source ; }
Process less file.

@param string $source
@param bool $force
@return string|null
@throws \JBZoo\Less\Exception
Process less file .