Skip to content

Commit

Permalink
Update AssetLicenceGroupManager functionality (#81)
Browse files Browse the repository at this point in the history
- fixed update licences in asset licence group.
  • Loading branch information
TomasHermanek authored May 9, 2024
1 parent 771b935 commit 3f5c5db
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## [1.9.1](https://github.com/anzusystems/core-dam-bundle/compare/1.9.0...1.9.1) (2024-05-09)

### Fixes
* update licence collection in `AssetLicenceGroup` update

## [1.9.0](https://github.com/anzusystems/core-dam-bundle/compare/1.8.2...1.9.0) (2024-04-25)

### Features
Expand Down
17 changes: 16 additions & 1 deletion src/Domain/AssetLicenceGroup/AssetLicenceGroupManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@
namespace AnzuSystems\CoreDamBundle\Domain\AssetLicenceGroup;

use AnzuSystems\CommonBundle\Domain\AbstractManager;
use AnzuSystems\CoreDamBundle\Entity\AssetLicence;
use AnzuSystems\CoreDamBundle\Entity\AssetLicenceGroup;
use AnzuSystems\CoreDamBundle\Entity\DamUser;
use Doctrine\Common\Collections\Collection;

final class AssetLicenceGroupManager extends AbstractManager
{
Expand All @@ -26,7 +29,19 @@ public function update(AssetLicenceGroup $assetLicenceGroup, AssetLicenceGroup $
;
$this->colUpdate(
oldCollection: $assetLicenceGroup->getLicences(),
newCollection: $newAssetLicenceGroup->getLicences()
newCollection: $newAssetLicenceGroup->getLicences(),
addElementFn: function (Collection $oldCollection, AssetLicence $licence) use ($assetLicenceGroup): bool {
$licence->getGroups()->add($assetLicenceGroup);
$oldCollection->add($licence);

return true;
},
removeElementFn: function (Collection $oldCollection, AssetLicence $licence) use ($assetLicenceGroup): bool {
$licence->getGroups()->removeElement($assetLicenceGroup);
$oldCollection->removeElement($licence);

return true;
}
);
$this->flush($flush);

Expand Down

0 comments on commit 3f5c5db

Please sign in to comment.