32 lines
773 B
PHP
32 lines
773 B
PHP
<?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;
|
|
}
|
|
}
|