• Модуль: disk
  • Путь к файлу: ~/bitrix/modules/disk/lib/rest/service/storage.php
  • Класс: BitrixDiskRestServiceStorage
  • Вызов: Storage::getForApp
protected function getForApp()
{
	if(!$this->restServer->getAppId())
	{
		throw new AccessException("Application context required");
	}

	$driver  = DiskDriver::getInstance();
	$appData = AppTable::getList(array('filter' => array('=CLIENT_ID' => $this->restServer->getAppId())))->fetch();
	if(!$appData || empty($appData['ID']) || empty($appData['CODE']))
	{
		throw new RestException('Could not find application by app_id.', RestException::ERROR_NOT_FOUND);
	}

	$storage = $driver->getStorageByRestApp($appData['ID']);
	if(!$storage)
	{
		$storage = $driver->addRestAppStorage(array(
			'ENTITY_ID' => $appData['ID'],
			'NAME' => $appData['CODE'],
		));
		if(!$storage)
		{
			$this->errorCollection->add($driver->getErrors());
			return null;
		}
	}

	return $storage;
}