本文整理匯總了PHP中Assets::factory方法的典型用法代碼示例。如果您正苦於以下問題:PHP Assets::factory方法的具體用法?PHP Assets::factory怎麽用?PHP Assets::factory使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Assets
的用法示例。
在下文中一共展示了Assets::factory方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: test_inline
public function test_inline()
{
$assets = Assets::factory('test_name')->process(FALSE)->css('test.css')->js('test.js');
$inline = $assets->inline();
$this->assertContains('.test { display: block; }', $inline);
$this->assertContains('var test;', $inline);
}
示例2: _load_assets
protected function _load_assets($config)
{
if (isset($config['head'])) {
Assets::factory('head')->load($config['head']);
}
if (isset($config['body'])) {
Assets::factory('body')->load($config['body']);
}
}
示例3: __construct
/**
* Конструктор
*/
public function __construct($config)
{
parent::__construct($config);
if (self::$is_init) {
return;
}
// Важно повесить хук именно таким образом, чтобы информация выводилась до остальных скриптов
hook('head', array($this, 'hookHead'));
$this->js = Assets::factory('scripts', config('assets.js'));
$this->css = Assets::factory('styles', config('assets.css'));
self::$is_init = TRUE;
}
示例4: _run_js
/**
* Pre-compile js files
*
* @access protected
* @return void
*/
protected function _run_js()
{
$filename = Arr::get($this->_config, 'compile_config_filename', 'asset_defs');
$config = Kohana::$config->load('js');
$js_array = [];
$js_settings = Kohana::$config->load($filename . '.js') ?: [];
$js_settings = [];
foreach ($config as $key => $value) {
// Create new assets object
$asset = Assets::factory()->js($value)->force_recompile($this->_force_recompile);
if ($hash = $asset->get('js', true)) {
$js_array[$key] = $hash;
}
}
if (!empty($js_array)) {
if ($js_settings !== $js_array) {
$return_array = $js_array;
// Cleanup
$files = glob(DOCROOT . $this->_compile_paths['js'] . '*');
foreach ($files as $file) {
preg_match('/\\/([a-zA-Z0-9_]+).js$/', $file, $matches);
if ($match = Arr::get($matches, 1)) {
if (!in_array($match, $js_array)) {
@unlink($file);
}
}
}
}
}
return $return_array;
}