init
This commit is contained in:
+31
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Esun\MultiLocaleTranslation\Plugin\Wiki;
|
||||
|
||||
use Esun\MultiLocaleTranslation\Model\WikiTranslationApplier;
|
||||
use Esun\Wiki\Model\ResourceModel\Homepage\Collection;
|
||||
|
||||
class ApplyWikiHomepageCollectionTranslation
|
||||
{
|
||||
private bool $applying = false;
|
||||
|
||||
public function __construct(private readonly WikiTranslationApplier $translationApplier)
|
||||
{
|
||||
}
|
||||
|
||||
public function afterLoad(Collection $subject, Collection $result): Collection
|
||||
{
|
||||
if ($this->applying) {
|
||||
return $result;
|
||||
}
|
||||
$this->applying = true;
|
||||
try {
|
||||
$this->translationApplier->applyMany($result->getItems(), true);
|
||||
} finally {
|
||||
$this->applying = false;
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user