init
This commit is contained in:
+33
@@ -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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user