public function testFilterUrls() { $content = 'body { background: url(../images/bg.gif); }'; $matches = array(); $actual = CssUtils::filterUrls($content, function ($match) use(&$matches) { $matches[] = $match['url']; }); $this->assertEquals(array('../images/bg.gif'), $matches); }
public function rewrite() { $target = $this->target; return CssUtils::filterUrls($this->originalContent, function ($matches) use($target) { // root relative if (isset($matches['url'][0]) && '/' == $matches['url'][0]) { // ensure target is properly formatted $target = rtrim($target, '/'); // return the corrected content return str_replace($matches['url'], $target . $matches['url'], $matches[0]); } return $matches[0]; }); }
/** * @see CssUtils::filterUrls() */ protected function filterUrls($content, $callback, $limit = -1, &$count = 0) { return CssUtils::filterUrls($content, $callback, $limit, $count); }