本文整理匯總了PHP中Assetic\Asset\FileAsset::getContent方法的典型用法代碼示例。如果您正苦於以下問題:PHP FileAsset::getContent方法的具體用法?PHP FileAsset::getContent怎麽用?PHP FileAsset::getContent使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Assetic\Asset\FileAsset
的用法示例。
在下文中一共展示了FileAsset::getContent方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: testLazyLoading
public function testLazyLoading()
{
$asset = new FileAsset(__FILE__);
$this->assertEmpty($asset->getContent(), 'The asset content is empty before load');
$asset->load();
$this->assertNotEmpty($asset->getContent(), 'The asset content is not empty after load');
}
示例2: testBeautify
public function testBeautify()
{
$this->filter->setBeautify(true);
$this->filter->filterDump($this->asset);
$this->assertContains(' foo', $this->asset->getContent());
$this->assertNotContains('/**', $this->asset->getContent());
}
示例3: testFilter
/**
* @dataProvider getImages
*/
public function testFilter($image)
{
$asset = new FileAsset($image);
$asset->load();
$before = $asset->getContent();
$this->filter->filterDump($asset);
$this->assertNotEmpty($asset->getContent(), '->filterLoad() sets content');
$this->assertNotEquals($before, $asset->getContent(), '->filterLoad() changes the content');
$this->assertMimeType('image/png', $asset->getContent(), '->filterLoad() creates PNG data');
}
示例4: testFilter
public function testFilter()
{
$asset = new FileAsset(__DIR__ . '/fixtures/home.jpg');
$asset->load();
$before = $asset->getContent();
$this->filter->filterDump($asset);
$this->assertNotEmpty($asset->getContent(), '->filterLoad() sets content');
$this->assertNotEquals($before, $asset->getContent(), '->filterDump() changes the content');
$this->assertMimeType('image/jpeg', $asset->getContent(), '->filterDump() creates JPEG data');
}
示例5: asset
/**
* @param $path String target path
* @return \Assetic\Filter\FileAsset
*/
public function asset($opts = array())
{
$asset = new FileAsset($this->real_path);
$ext = strtolower(substr($this->real_path, strrpos($this->real_path, '.')));
if (in_array($ext, array('.css', '.scss'))) {
//il faut rajouter la méthode asset-url
$scss = new ScssphpFilter();
if (isset($opts['compass']) && $opts['compass']) {
$scss->enableCompass(true);
}
$scss->registerFunction('aphet_url', function ($args, $scss) {
if ($args[0][0] === 'string') {
$url = is_array($args[0][2][0]) ? $args[0][2][0][2][0] : $args[0][2][0];
} else {
throw new \Exception('je ne sais pas quoi faire là');
}
if (strpos($url, '?') !== false) {
list($url, $query) = explode('?', $url);
} else {
$query = null;
}
if (strpos($url, '#') !== false) {
list($url, $hash) = explode('#', $url);
} else {
$hash = null;
}
return 'url(' . aphet_url($url) . ($query ? "?{$query}" : '') . ($hash ? "?{$hash}" : '') . ')';
});
$asset->ensureFilter($scss);
} elseif ($ext === '.js') {
$filter = new \Assetic\Filter\CallablesFilter(function ($asset) {
$asset->setContent(preg_replace_callback('/aphet_url\\((.*)\\)/', function ($match) {
return '\'' . aphet_url(json_decode($match[1])) . '\'';
}, $asset->getContent()));
});
$asset->ensureFilter($filter);
}
return $asset;
}