Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
assetcollector.php
1<?php
3
4use Bitrix\Main\Page\Asset;
5
12{
13 protected $assetCollectionStarted = false;
14
15 public function startAssetCollection()
16 {
17 if(!$this->assetCollectionStarted)
18 {
19 $this->resetAssets();
20 $this->assetCollectionStarted = true;
21 }
22 }
23
24 public function getCollectedAssets()
25 {
26 $result = array_merge(
27 $this->parseResourceString(Asset::getInstance()->getJs()),
28 $this->parseResourceString(Asset::getInstance()->getCss())
29 );
30
31 return array_unique($result);
32 }
33
34 protected function resetAssets()
35 {
36 global $APPLICATION;
37
38 $APPLICATION->ShowAjaxHead(true, false, false, false);
39 }
40
41 protected function parseResourceString($string)
42 {
43 $result = array();
44 $string = preg_split("/\\r\\n|\\r|\\n/", $string);
45 foreach($string as $v)
46 {
47 $v = trim((string)$v);
48 if($v !== '')
49 {
50 $result[] = $v;
51 }
52 }
53
54 return array_unique($result);
55 }
56}