This commit is contained in:
2026-09-15 10:35:56 +08:00
commit 782f8ea7aa
4086 changed files with 631288 additions and 0 deletions
@@ -0,0 +1,33 @@
<?php
declare(strict_types=1);
namespace Esun\MultiLocaleTranslation\Plugin\Blog;
use Esun\MultiLocaleTranslation\Model\BlogPostTranslationApplier;
use Mageplaza\Blog\Model\ResourceModel\Post\Collection;
class ApplyStoreTranslationToPostCollection
{
private bool $applying = false;
public function __construct(
private readonly BlogPostTranslationApplier $translationApplier
) {
}
public function afterLoad(Collection $subject, Collection $result): Collection
{
if ($this->applying) {
return $result;
}
$this->applying = true;
try {
$this->translationApplier->applyMany($result->getItems());
} finally {
$this->applying = false;
}
return $result;
}
}