You are here

protected function Minifier::lock in Advanced CSS/JS Aggregation 8.4

Same name and namespace in other branches
  1. 8.2 advagg_js_minify/jshrink.inc \JShrink\Minifier::lock()
  2. 8.3 advagg_js_minify/jshrink.inc \JShrink\Minifier::lock()
  3. 7.2 advagg_js_compress/jshrink.inc \JShrink\Minifier::lock()

Replace patterns in the given string and store the replacement

Parameters

string $js The string to lock:

Return value

bool

File

advagg_js_minify/jshrink.inc, line 591

Class

Minifier
Minifier

Namespace

JShrink

Code

protected function lock($js) {

  /* lock things like <code>"asd" + ++x;</code> */
  $lock = '"LOCK---' . crc32(time()) . '"';
  $matches = array();
  preg_match('/([+-])(\\s+)([+-])/S', $js, $matches);
  if (empty($matches)) {
    return $js;
  }
  $this->locks[$lock] = $matches[2];
  $js = preg_replace('/([+-])\\s+([+-])/S', "\$1{$lock}\$2", $js);

  /* -- */
  return $js;
}