5use \Bitrix\Main\Localization\Loc;
27 private static $instance;
54 if (self::$instance ===
null)
56 self::$instance =
new static;
59 return self::$instance;
102 return array_key_exists($code, $this->registered);
125 $this->registered[$code] = [
126 self::REGISTERED_KEY_CODE => $code,
127 self::REGISTERED_KEY_LOCATION => $location,
130 if($code !==
'main.core' && $code !==
'core')
132 \CJSCore::markExtensionLoaded($code);
143 public function addAsset($code, $location =
null): void
148 foreach ($code as $item)
150 $this->
addAsset((
string)$item, $location);
174 if ($ext = \CJSCore::getExtInfo($code))
178 else if ($ext = Extension::getConfig($code))
183 else if ($type = self::detectType($code))
185 $asset = [$type => [$code]];
208 if (\CJSCore::isExtensionLoaded($code))
227 if (!isset($asset[$type]) || empty($asset[$type]))
232 if (!is_array($asset[$type]))
234 $asset[$type] = [$asset[$type]];
241 foreach ($asset[$type] as $rel)
252 foreach ($asset[$type] as $path)
254 if (\CMain::isExternalLink($path))
259 else if (self::detectType($path))
261 $this->resources->add($path, $type, $location);
270 foreach ($asset[$type] as $fontFile)
273 !\CMain::isExternalLink($fontFile)
303 $externalLink =
"<link href=\"$path\" type=\"text/css\" rel=\"stylesheet\">";
309 $externalLink =
"<script type=\"text/javascript\" src=\"$path\"></script>";
316 $externalLink =
'<link rel="preload" href="' . $path
317 .
'" as="font" crossorigin="anonymous" type="' . $fontType .
'" crossorigin>';
325 return $externalLink;
337 $path = parse_url($path)[
'path'];
338 $type = mb_strtolower(mb_substr(strrchr($path,
'.'), 1));
363 'woff2' =>
'font/woff2',
364 'woff' =>
'font/woff',
366 'eot' =>
'application/vnd.ms-fontobject',
367 'svg' =>
'image/svg+xml',
371 foreach ($available as $type => $value)
373 if (mb_strpos($path, $type) !==
false)
390 $this->resources->addString(trim($string));
402 "You must to pass ID of current landing to the \Bitrix\Landing\Assets\Manager::setOutput",
407 $this->builder->attachToLanding($lid);
408 $this->builder->setOutput();
static createByType(ResourceCollection $resources, string $type)
static verifyLocation($location)
getRegisteredAssetLocation(string $code)
addString(string $string)
processAsset(array $asset, int $location)
static checkFontLinkType(string $path)
const REGISTERED_KEY_CODE
isNeedAddAsset(string $code, int $location)
markAssetRegistered($code, $location)
createStringFromPath(string $path, string $type)
static detectType(string $path)
addAssetRecursive(string $code, $location=null)
const REGISTERED_KEY_LOCATION
addAsset($code, $location=null)
static rebuildWebpackForLanding($lid=[])
static markToRebuild($lid)
static markAllToRebuild()
static loadMessages($file)