- Модуль: recyclebin
- Путь к файлу: ~/bitrix/modules/recyclebin/lib/internals/entity.php
- Класс: BitrixRecyclebinInternalsEntity
- Вызов: Entity::save
public function save()
{
$result = new Result;
$data = [
'NAME' => $this->getTitle(),
'SITE_ID' => $this->getSiteId(),
'ENTITY_ID' => $this->getEntityId(),
'ENTITY_TYPE' => $this->getEntityType(),
'MODULE_ID' => $this->getModuleId(),
'USER_ID' => $this->getOwnerId()
];
try
{
$recyclebin = RecyclebinTable::add($data);
$resultData = [ 'ID'=>$recyclebin->getId() ];
if (!$recyclebin->isSuccess())
{
$result->addErrors($recyclebin->getErrors());
}
else
{
$this->setId($recyclebin->getId());
foreach ($this->getData() as $action => $data)
{
$dataResult = RecyclebinDataTable::add(
[
'RECYCLEBIN_ID' => $this->getId(),
'ACTION' => $action,
'DATA' => serialize($data)
]
);
if($dataResult->isSuccess())
{
if(!isset($resultData['DATA']))
{
$resultData['DATA'] = [];
}
$resultData['DATA'][$action] = $dataResult->getId();
}
}
foreach ($this->getFiles() as $fileId => $storageType)
{
RecyclebinFileTable::add(
[
'RECYCLEBIN_ID' => $this->getId(),
'FILE_ID' => $fileId,
'STORAGE_TYPE' => $storageType['STORAGE_TYPE']
]
);
}
}
$result->setData($resultData);
}
catch (Exception $e)
{
$result->addError(new Error($e->getMessage(), $e->getCode()));
}
return $result;
}