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 #114 from atrocore/i-649d27b7bc2fae924
Browse files Browse the repository at this point in the history
Fixed Bug when saving private field in Asset
  • Loading branch information
rratsun authored Jun 30, 2023
2 parents 7a2f4a3 + 42c5701 commit c684178
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/Repositories/Asset.php
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ protected function beforeSave(Entity $entity, array $options = [])
protected function afterSave(Entity $entity, array $options = [])
{
if ($entity->isAttributeChanged('private')) {
$file = $this->getEntityManager()->getEntity('Attachment', $entity->get('fileId'));
$file = $entity->get('file');
if (!empty($file)) {
$file->set('private', $entity->get('private'));
$this->getEntityManager()->saveEntity($file);
Expand Down
11 changes: 10 additions & 1 deletion app/Services/Asset.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,15 @@ public function prepareEntityForOutput(Entity $entity)
}
}

public function isEntityUpdated(Entity $entity, \stdClass $data): bool
{
$file = $entity->get('file');
if (!empty($file)) {
$entity->set('private', $file->get('private'));
}
return parent::isEntityUpdated($entity, $data);
}

public function recheckAssetTypes(array $data): void
{
if (empty($data['assetId'])) {
Expand Down Expand Up @@ -183,7 +192,7 @@ public function getFileInfo(\Dam\Entities\Asset $asset)

/**
* @param \Dam\Entities\Asset $asset
* @param array $imageInfo
* @param array $imageInfo
*/
public function updateAttributes(\Dam\Entities\Asset $asset, array $imageInfo)
{
Expand Down

0 comments on commit c684178

Please sign in to comment.