Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
{
public function __construct(
private ContentBlockRepository $contentBlockRepository,
private EntityManagerInterface $entityManager,
) {
}

Expand All @@ -41,8 +40,6 @@ function (ContentBlock $contentBlock) use ($copyContentBlocksToOtherLocale, &$id
},
$contentBlocksToCopy
);

$this->entityManager->flush();
}

private function getContentBlocksToCopy(Locale $locale): array
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
{
public function __construct(
private ContentBlockRepository $contentBlockRepository,
private EntityManagerInterface $entityManager,
) {
}

Expand All @@ -27,8 +26,6 @@ public function __invoke(CreateContentBlock $createContentBlock): void
$this->contentBlockRepository->add($contentBlock);

$createContentBlock->setContentBlockEntity($contentBlock);

$this->entityManager->flush();
}

private function getNewExtraId(): int
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
{
public function __construct(
private ContentBlockRepository $contentBlockRepository,
private EntityManagerInterface $entityManager,
) {
}

Expand All @@ -24,7 +23,5 @@ public function __invoke(DeleteContentBlock $deleteContentBlock): void
);

Model::deleteExtraById($deleteContentBlock->contentBlock->getExtraId());

$this->entityManager->flush();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
{
public function __construct(
private ContentBlockRepository $contentBlockRepository,
private EntityManagerInterface $entityManager,
) {
}

Expand All @@ -22,7 +21,5 @@ public function __invoke(UpdateContentBlock $updateContentBlock): void
$this->contentBlockRepository->add($contentBlock);

$updateContentBlock->setContentBlockEntity($contentBlock);

$this->entityManager->flush();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ function (ContentBlock $contentBlock): void {
);
}

// We don't flush here, see http://disq.us/p/okjc6b
$this->getEntityManager()->persist($contentBlock);
$this->save();
}

public function getNextIdForLanguage(Locale $locale): int
Expand Down Expand Up @@ -72,12 +72,18 @@ public function findOneByRevisionIdAndLocale(?int $revisionId, Locale $locale):

public function removeByIdAndLocale($id, Locale $locale): void
{
// We don't flush here, see http://disq.us/p/okjc6b
array_map(
function (ContentBlock $contentBlock): void {
$this->getEntityManager()->remove($contentBlock);
},
(array) $this->findBy(['id' => $id, 'locale' => $locale])
);

$this->save();
}

public function save(): void
{
$this->getEntityManager()->flush();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
{
public function __construct(
private MediaGalleryRepository $mediaGalleryRepository,
private EntityManagerInterface $entityManager,
) {
}

Expand All @@ -23,7 +22,5 @@ public function __invoke(CreateMediaGallery $createMediaGallery): void

// We redefine the mediaGallery, so we can use it in an action
$createMediaGallery->setMediaGalleryEntity($mediaGallery);

$this->entityManager->flush();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
public function __construct(
private MediaGalleryRepository $mediaGalleryRepository,
private MediaItemRepository $mediaItemRepository,
private EntityManagerInterface $entityManager,
) {
}

Expand All @@ -34,7 +33,5 @@ public function __invoke(DeleteMediaGallery $deleteMediaGallery): void
}

$this->mediaGalleryRepository->remove($deleteMediaGallery->mediaGallery);

$this->entityManager->flush();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@
namespace Backend\Modules\MediaGalleries\Domain\MediaGallery\Command;

use Backend\Modules\MediaGalleries\Domain\MediaGallery\MediaGallery;
use Backend\Modules\MediaGalleries\Domain\MediaGallery\MediaGalleryRepository;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\Messenger\Attribute\AsMessageHandler;

#[AsMessageHandler]
final readonly class UpdateMediaGalleryHandler
{
public function __construct(
private EntityManagerInterface $entityManager,
private MediaGalleryRepository $mediaGalleryRepository,
) {
}

Expand All @@ -19,6 +20,6 @@ public function __invoke(UpdateMediaGallery $updateMediaGallery): void
// We redefine the mediaGallery, so we can use it in an action
$updateMediaGallery->setMediaGalleryEntity(MediaGallery::fromDataTransferObject($updateMediaGallery));

$this->entityManager->flush();
$this->mediaGalleryRepository->save();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ final class MediaGalleryRepository extends EntityRepository
public function add(MediaGallery $mediaGallery): void
{
$this->getEntityManager()->persist($mediaGallery);
$this->save();
}

public function existsByTitle(string $title, ?string $ignoreMediaGalleryId = null): bool
Expand Down Expand Up @@ -47,5 +48,11 @@ public function findOneById(?string $id = null): MediaGallery
public function remove(MediaGallery $mediaGallery): void
{
$this->getEntityManager()->remove($mediaGallery);
$this->save();
}

public function save(): void
{
$this->getEntityManager()->flush();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
{
public function __construct(
private MediaFolderRepository $mediaFolderRepository,
private EntityManagerInterface $entityManager,
) {
}

Expand All @@ -24,7 +23,5 @@ public function __invoke(CreateMediaFolder $createMediaFolder): void

// We redefine the MediaFolder, so we can use it in an action
$createMediaFolder->setMediaFolderEntity($mediaFolder);

$this->entityManager->flush();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,5 @@ public function __invoke(DeleteMediaFolder $deleteMediaFolder): void
$mediaFolder = $deleteMediaFolder->mediaFolder;

$this->mediaFolderRepository->remove($mediaFolder);

$this->entityManager->flush();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@
namespace Backend\Modules\MediaLibrary\Domain\MediaFolder\Command;

use Backend\Modules\MediaLibrary\Domain\MediaFolder\MediaFolder;
use Backend\Modules\MediaLibrary\Domain\MediaFolder\MediaFolderRepository;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\Messenger\Attribute\AsMessageHandler;

#[AsMessageHandler]
final readonly class UpdateMediaFolderHandler
{
public function __construct(
private EntityManagerInterface $entityManager,
private MediaFolderRepository $mediaFolderRepository,
) {
}

Expand All @@ -19,6 +20,6 @@ public function __invoke(UpdateMediaFolder $updateMediaFolder): void
// We redefine the MediaFolder, so we can use it in an action
$updateMediaFolder->setMediaFolderEntity(MediaFolder::fromDataTransferObject($updateMediaFolder));

$this->entityManager->flush();
$this->mediaFolderRepository->save();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ final class MediaFolderRepository extends EntityRepository
{
public function add(MediaFolder $mediaFolder): void
{
// We don't flush here, see http://disq.us/p/okjc6b
$this->getEntityManager()->persist($mediaFolder);
$this->save();
}

private function bumpFolderCount(int $folderId, array &$counts): void
Expand Down Expand Up @@ -82,7 +82,12 @@ public function getCountsForMediaGroup(MediaGroup $mediaGroup): array

public function remove(MediaFolder $mediaFolder): void
{
// We don't flush here, see http://disq.us/p/okjc6b
$this->getEntityManager()->remove($mediaFolder);
$this->save();
}

public function save(): void
{
$this->getEntityManager()->flush();
}
}
Loading