• Модуль: landing
  • Путь к файлу: ~/bitrix/modules/landing/lib/block.php
  • Класс: BitrixLandingBlock
  • Вызов: Block::getAsset
public function getAsset($type = null)
{
	static $asset = array();

	if (!is_string($type))
	{
		return [];
	}

	if (!isset($asset[$this->code]))
	{
		$asset[$this->code] = array(
			'css' => array(),
			'js' => array(),
			'ext' => array(),
			'class' => array()
		);

		// additional asset first
		if ($this->repoId)
		{
			$manifest = Repo::getBlock($this->repoId);
		}
		else if ($path = self::getBlockPath($this->code))
		{
			$manifest = include $this->docRoot . $path . '/.description.php';
			$manifest['timestamp'] = file_exists($this->docRoot . $path . '/.description.php')
									? filectime($this->docRoot . $path . '/.description.php')
									: time();
		}

		if (isset($manifest['block']['namespace']))
		{
			$classFile = self::BLOCKS_DIR;
			$classFile .= '/' . $manifest['block']['namespace'] . '/';
			$classFile .= $this->code . '/class.php';
			$classFile = getLocalPath($classFile);
			if ($classFile)
			{
				$asset[$this->code]['class'][] = $this->docRoot . $classFile;
			}
		}

		// prepare by subtype
		if (
			isset($manifest['block']['subtype']) &&
			(
				!isset($params['miss_subtype']) ||
				$params['miss_subtype'] !== true
			)
		)
		{
			$subtypes = $manifest['block']['subtype'];
			if (!is_array($subtypes))
			{
				$subtypes = [$subtypes];
			}

			foreach ($subtypes as $subtype)
			{
				$subtypeClass = '\Bitrix\Landing\Subtype\';
				$subtypeClass .= $subtype;
				if (class_exists($subtypeClass))
				{
					$manifest = $subtypeClass::prepareManifest(
						$manifest,
						$this,
						isset($manifest['block']['subtype_params'])
							? (array)$manifest['block']['subtype_params']
							: array()
					);
				}
			}
		}

		foreach (array_keys($asset[$this->code]) as $ass)
		{
			if (
				isset($manifest['assets'][$ass]) &&
				!empty($manifest['assets'][$ass])
			)
			{
				foreach ($manifest['assets'][$ass] as $file)
				{
					if (!is_string($file))
					{
						continue;
					}
					if ($ass != 'ext')
					{
						$asset[$this->code][$ass][] = trim($file);
					}
					// for rest block allowed only this
					else if (
						!$this->repoId ||
						in_array($file, $this->allowedExtensions)
					)
					{
						$asset[$this->code][$ass][] = trim($file);
					}
				}
				$asset[$this->code][$ass] = array_unique($asset[$this->code][$ass]);
			}
		}

		// next is phis files
		if (isset($path) && $path)
		{
			// base files next
			$file = $path . '/' . ($this->metaData['DESIGNER_MODE'] ? 'design_' : '') . self::CSS_FILE_NAME;
			if (file_exists($this->docRoot . $file))
			{
				$asset[$this->code]['css'][] = $file;
			}
			$file = $path . '/' . self::JS_FILE_NAME;
			if (file_exists($this->docRoot . $file))
			{
				$asset[$this->code]['js'][] = $file;
			}
		}
	}

	$designerBlockManifest = $this->parseManifest();
	if (!empty($designerBlockManifest['assets']))
	{
		foreach ($designerBlockManifest['assets'] as $key => $assets)
		{
			$asset[$this->code][$key] = array_merge($asset[$this->code][$key], $assets);
			$asset[$this->code][$key] = array_unique($asset[$this->code][$key]);
		}
	}

	return $asset[$this->code][$type] ?? $asset[$this->code];
}