diff --git a/app/Repositories/Asset.php b/app/Repositories/Asset.php index 51584a1..308c7dc 100644 --- a/app/Repositories/Asset.php +++ b/app/Repositories/Asset.php @@ -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); diff --git a/app/Services/Asset.php b/app/Services/Asset.php index 1fdaec5..fa1e2ab 100644 --- a/app/Services/Asset.php +++ b/app/Services/Asset.php @@ -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'])) { @@ -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) {