本文整理汇总了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;
}