- Модуль: disk
- Путь к файлу: ~/bitrix/modules/disk/lib/file.php
- Класс: BitrixDiskFile
- Вызов: File::addVersion
public function addVersion(array $file, $createdBy, $disableJoin = false, array $options = [])
{
$this->errorCollection->clear();
$commentAttachedObjects = $options['commentAttachedObjects'] ?? true;
if(Configuration::isEnabledStorageSizeRestriction())
{
static::checkRequiredInputParams($file, array(
'FILE_SIZE'
));
if($this->errorCollection->hasErrors())
{
return null;
}
if(!$this->getStorage()->isPossibleToUpload($file['FILE_SIZE']))
{
$this->errorCollection[] = new Error(
Loc::getMessage('DISK_FILE_MODEL_ERROR_SIZE_RESTRICTION'), self::ERROR_SIZE_RESTRICTION
);
return null;
}
}
$needToJoin = !$disableJoin && $this->isNeedToJoinVersion($createdBy);
if(!$this->updateContent($file, $createdBy))
{
return null;
}
if($needToJoin)
{
$lastVersion = $this->joinVersion();
if ($lastVersion)
{
$this->cleanVersionsOverLimitByTime($createdBy);
$this->tryToRunBizProcAfterEdit();
return $lastVersion;
}
}
$versionModel = Version::add(array_merge(array(
'OBJECT_ID' => $this->id,
'FILE_ID' => $this->fileId,
'NAME' => $this->name,
'CREATED_BY' => $createdBy,
), $this->getHistoricalData()), $this->errorCollection);
if(!$versionModel)
{
return null;
}
$this->cleanVersionsOverLimitByCount($createdBy);
$this->cleanVersionsOverLimitByTime($createdBy);
if ($commentAttachedObjects)
{
$this->commentAttachedObjects($versionModel);
}
$this->resetHeadVersionToAttachedObject($versionModel);
if ($this->getGlobalContentVersion() == 1)
{
$this->tryToRunBizProcAfterCreate();
}
else
{
$this->tryToRunBizProcAfterEdit();
}
Application::getInstance()->getTaggedCache()->clearByTag("disk_file_{$this->id}");
return $versionModel;
}