本文整理汇总了PHP中Resource::setFile方法的典型用法代码示例。如果您正苦于以下问题:PHP Resource::setFile方法的具体用法?PHP Resource::setFile怎么用?PHP Resource::setFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Resource
的用法示例。
在下文中一共展示了Resource::setFile方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addResource
private function addResource($type, $file_names, $single = false)
{
if ($single) {
if (count($file_names) > 1) {
$file_names = array($file_names[0]);
}
$Resource = new Resource();
$type == 'file' ? $Resource->setFile($file_names[0]) : $Resource->setString($file_names[0]);
/*$Resource->setDriver($this->driver);*/
$this->resources[] = $Resource;
$Resource->collection = $this;
return $Resource;
} else {
$class = __CLASS__;
$Collection = new $class();
$Collection->collection = $this;
$this->resources[] = $Collection;
foreach ($file_names as $data) {
if (is_string($data)) {
$type == 'file' ? $Collection->addSingleFile($data) : $Collection->addSingleString($data);
} else {
$type == 'file' ? $Collection->addFile($data) : $Collection->addString($data);
}
}
return $Collection;
}
}
示例2: array
([;|}])
/ixs', '$1$2; $1hand$3'), 'opacity' => array('/
(opacity\\s*:\\s*)
(\\d*(?:\\.\\d*)?)
([;|}])
/ixs', function ($matches) {
return $matches[1] . $matches[2] . '; ' . 'filter: alpha(opacity=' . round(floatval($matches[2]) * 100) . ');' . '-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=' . round(floatval($matches[2]) * 100) . ')"' . $matches[3];
}, true));
foreach ($replace_pairs as $rule) {
if (!empty($rule[2])) {
$string = preg_replace_callback($rule[0], $rule[1], $string);
} else {
$string = preg_replace($rule[0], $rule[1], $string);
}
}
return $string;
};
$CSS = new Resource('CSS');
$CSS->setFile('css/w3-correct.css')->handler($handleBorderRadius)->inline()->handler(function ($string) {
return '/* Author: Anton Ruban */' . "\r\n" . $string;
})->flush();
$JS = new Resource();
$JS->driver('JavaScript')->setFile('js/example.js')->handler(function ($string) {
$packer = new JavaScriptPacker($string);
return $packer->pack();
})->inline()->file('tmp/example.js')->flush();
?>
<div id="foobar" style="border: 1px solid #D0D0D0; padding: 20px; width: 300px;">Hello, world</div>
</body>
</html>
示例3: Resource
<?php
include 'init.php';
$JS = new Resource(new DriverJavaScript(array('base-uri' => '/')));
$JS->setFile('js/example.js');
$JS->flush();