• Модуль: disk
  • Путь к файлу: ~/bitrix/modules/disk/lib/volume/cleaner.php
  • Класс: BitrixDiskVolumeCleaner
  • Вызов: Cleaner::getSecurityContext
private function getSecurityContext(DiskUser $user, DiskBaseObject $object): SecurityContext
{
	static $securityContextCache = [];

	$userId = $user->getId();
	$storageId = $object->getStorageId();

	if (!isset($securityContextCache[$userId][$storageId]) || !($securityContextCache[$userId][$storageId] instanceof SecurityContext))
	{
		if (!isset($securityContextCache[$userId]))
		{
			$securityContextCache[$userId] = [];
		}

		if ($user->isAdmin())
		{
			$securityContextCache[$userId][$storageId] = new DiskSecurityFakeSecurityContext($userId);
		}
		else
		{
			$securityContextCache[$userId][$storageId] = $object->getStorage()->getSecurityContext($userId);
		}
	}

	return $securityContextCache[$userId][$storageId];
}