Skip to content

Commit

Permalink
fix: allow to sync test metadata to DataStore after translation sync
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrielfs7 committed Dec 24, 2024
1 parent 9f2b6c9 commit 9436a9c
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?php

/**
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; under version 2
* of the License (non-upgradable).
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Copyright (c) 2024 (original work) Open Assessment Technologies SA.
*/

declare(strict_types=1);

namespace oat\taoTests\models\Translation\Service;

use core_kernel_classes_Resource;
use oat\oatbox\event\EventManager;
use oat\taoTests\models\event\TestUpdatedEvent;
use Psr\Log\LoggerInterface;

class TranslateIntoLanguagesHandler
{
private LoggerInterface $logger;
private EventManager $eventManager;

public function __construct(LoggerInterface $logger, EventManager $eventManager)
{
$this->logger = $logger;
$this->eventManager = $eventManager;
}

public function __invoke(core_kernel_classes_Resource $originalTest): void
{
$this->logger->debug(sprintf('Force original test sync %s at %s', $originalTest->getUri(), __METHOD__));

$this->eventManager->trigger(new TestUpdatedEvent($originalTest->getUri()));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,21 @@

use oat\generis\model\data\Ontology;
use oat\generis\model\DependencyInjection\ContainerServiceProviderInterface;
use oat\oatbox\event\EventManager;
use oat\oatbox\log\LoggerService;
use oat\tao\model\resources\Service\InstanceCopier;
use oat\tao\model\TaoOntology;
use oat\tao\model\featureFlag\FeatureFlagChecker;
use oat\tao\model\Translation\Form\Modifier\TranslationFormModifier as TaoTranslationFormModifier;
use oat\tao\model\Translation\Service\ResourceLanguageRetriever;
use oat\tao\model\Translation\Service\ResourceMetadataPopulateService;
use oat\tao\model\Translation\Service\TranslatedIntoLanguagesSynchronizer;
use oat\tao\model\Translation\Service\TranslationCreationService;
use oat\taoTests\models\TaoTestOntology;
use oat\taoTests\models\Translation\Form\Modifier\TranslationFormModifier;
use oat\taoTests\models\Translation\Form\Modifier\TranslationFormModifierProxy;
use oat\taoTests\models\Translation\Listener\TestCreatedEventListener;
use oat\taoTests\models\Translation\Service\TranslateIntoLanguagesHandler;
use oat\taoTests\models\Translation\Service\TranslationPostCreationService;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;

Expand Down Expand Up @@ -99,6 +102,15 @@ public function __invoke(ContainerConfigurator $configurator): void
]
);

$services
->set(TranslateIntoLanguagesHandler::class, TranslateIntoLanguagesHandler::class)
->args(
[
service(LoggerService::SERVICE_ID),
service(EventManager::SERVICE_ID),
]
);

$services
->get(TranslationCreationService::class)
->call(
Expand All @@ -115,5 +127,15 @@ public function __invoke(ContainerConfigurator $configurator): void
service(TranslationPostCreationService::class)
]
);

$services
->get(TranslatedIntoLanguagesSynchronizer::class)
->call(
'addCallback',
[
TaoOntology::CLASS_URI_TEST,
service(TranslateIntoLanguagesHandler::class)
]
);
}
}

0 comments on commit 9436a9c

Please sign in to comment.