Skip to content
This repository has been archived by the owner on May 16, 2024. It is now read-only.

Commit

Permalink
Merge pull request #125 from atrocore/id-p652951b80afe2166
Browse files Browse the repository at this point in the history
Id p652951b80afe2166
  • Loading branch information
rratsun committed Oct 31, 2023
2 parents 1d972de + 8c96c44 commit ef5afbd
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions app/Repositories/Asset.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

namespace Dam\Repositories;

use Atro\ORM\DB\RDB\Mapper;
use Dam\Core\AssetValidator;
use Doctrine\DBAL\ParameterType;
use Espo\Core\Exceptions\BadRequest;
Expand Down Expand Up @@ -43,14 +44,14 @@ public function clearAssetMetadata(Entity $asset): void

public function restoreClearAssetMetadata(Entity $asset): void
{
$this->getConnection()
->createQueryBuilder()
->update($this->getConnection()->quoteIdentifier('AssetMetadata'))
->set('deleted', ':deleted')
->where('asset_id = :assetId')
->setParameter('deleted', false, ParameterType::BOOLEAN)
->setParameter('asset_id', $asset->get('id'))
->executeQuery();
$this->getConnection()
->createQueryBuilder()
->update($this->getConnection()->quoteIdentifier('asset_metadata'))
->set('deleted', ":deleted")
->where('asset_id = :assetId')
->setParameter('deleted', false, Mapper::getParameterType(false))
->setParameter('assetId', $asset->get('id'))
->executeQuery();
}

public function updateMetadata(Entity $asset): void
Expand Down Expand Up @@ -212,15 +213,15 @@ protected function afterRemove(Entity $entity, array $options = [])
parent::afterRemove($entity, $options);
}

public function afterRestore($entity, array $options = []){
parent::afterRestore($entity, $options );
public function afterRestore($entity){
parent::afterRestore($entity);
if (!empty($attachmentId = $entity->get('fileId'))) {
$this->getConnection()
->createQueryBuilder()
->update($this->getConnection()->quoteIdentifier('Attachment'))
->update($this->getConnection()->quoteIdentifier('attachment'))
->set('deleted', ':deleted')
->where('id = :attachmentId')
->setParameter('deleted', false, ParameterType::BOOLEAN)
->setParameter('deleted', false, Mapper::getParameterType(false))
->setParameter('attachmentId', $attachmentId)
->executeQuery();
}
Expand Down

0 comments on commit ef5afbd

Please sign in to comment.