22 private $jsPathList = [];
23 private $cssPathList = [];
34 private $errorCollection;
47 public function __construct($componentName, $templateName =
'', $params = [], $additionalResponseParams = [], $parentComponent = [], $functionParams = [], $status = self::STATUS_SUCCESS,
ErrorCollection $errorCollection =
null)
49 $this->asset = Asset::getInstance();
52 $this->asset->disableOptimizeCss();
53 $this->asset->disableOptimizeJs();
58 $APPLICATION->IncludeComponent(
65 $componentContent = ob_get_clean();
70 $this->collectAssetsPathList();
72 'status' => $this->status,
73 'data' => $componentContent,
75 'js' => $this->getJsList(),
76 'css' => $this->getCssList(),
77 'string' => $this->getStringList()
79 'additionalParams' => $additionalResponseParams,
80 'errors' => $this->getErrorsToResponse(),
84 private function collectAssetsPathList()
86 $this->asset->getCss();
87 $this->asset->getJs();
88 $this->asset->getStrings();
90 $this->jsPathList = $this->asset->getTargetList(
'JS');
91 $this->cssPathList = $this->asset->getTargetList(
'CSS');
97 private function getJsList()
101 foreach($this->jsPathList as $targetAsset)
103 $assetInfo = $this->asset->getAssetInfo($targetAsset[
'NAME'], AssetMode::ALL);
104 if (!empty($assetInfo[
'JS']))
106 $jsList = array_merge($jsList, $assetInfo[
'JS']);
116 private function getCssList()
120 foreach($this->cssPathList as $targetAsset)
122 $assetInfo = $this->asset->getAssetInfo($targetAsset[
'NAME'], AssetMode::ALL);
123 if (!empty($assetInfo[
'CSS']))
125 $cssList = array_merge($cssList, $assetInfo[
'CSS']);
135 private function getStringList()
138 foreach($this->cssPathList as $targetAsset)
140 $assetInfo = $this->asset->getAssetInfo($targetAsset[
'NAME'], AssetMode::ALL);
141 if (!empty($assetInfo[
'STRINGS']))
143 $strings = array_merge($strings, $assetInfo[
'STRINGS']);
147 foreach($this->jsPathList as $targetAsset)
149 $assetInfo = $this->asset->getAssetInfo($targetAsset[
'NAME'], AssetMode::ALL);
150 if (!empty($assetInfo[
'STRINGS']))
152 $strings = array_merge($strings, $assetInfo[
'STRINGS']);
156 $strings[] = $this->asset->showFilesList();
163 protected function getErrorsToResponse()
166 foreach ($this->errorCollection as $error)
170 'message' => $error->getMessage(),
171 'code' => $error->getCode(),
184 return $this->errorCollection->toArray();
194 return $this->errorCollection->getErrorByCode($code);
setHeaders(Web\HttpHeaders $headers)
__construct($componentName, $templateName='', $params=[], $additionalResponseParams=[], $parentComponent=[], $functionParams=[], $status=self::STATUS_SUCCESS, ErrorCollection $errorCollection=null)