• Модуль: disk
  • Путь к файлу: ~/bitrix/modules/disk/lib/uf/controller.php
  • Класс: BitrixDiskUfController
  • Вызов: Controller::processActionListFolders
protected function processActionListFolders($storageId, $folderId = null)
{
	$storage = Storage::loadById($storageId);
	if(!$storage)
	{
		$this->errorCollection[] = new Error(
			"Could not find storage by id {$storageId}",
			self::ERROR_COULD_NOT_FIND_STORAGE
		);
		$this->sendJsonErrorResponse();
	}

	$securityContext = $storage->getCurrentUserSecurityContext();
	if(!$folderId)
	{
		$folder = $storage->getRootObject();
	}
	else
	{
		$folder = Folder::loadById($folderId);
		if(!$folder)
		{
			$this->errorCollection[] = new Error(
				Loc::getMessage('DISK_UF_CONTROLLER_ERROR_COULD_NOT_FIND_FIND_FOLDER'),
				self::ERROR_COULD_NOT_FIND_FOLDER
			);
			$this->sendJsonErrorResponse();
		}
	}

	$response = array();
	foreach($folder->getChildren($securityContext) as $baseObject)
	{
		/** @var BaseObject $baseObject */

		$isFolder = $baseObject instanceof Folder;
		if($isFolder && !$baseObject->canAdd($securityContext))
		{
			continue;
		}

		$response[] = array(
			'id' => $baseObject->getId(),
			'type' => $isFolder? 'folder' : 'file',
			'name' => $baseObject->getName(),
			'size' => $isFolder? null : $baseObject->getSize(),
		);
	}

	$this->sendJsonResponse($response);
}