Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 65
0.00% covered (danger)
0.00%
0 / 1
CRAP
0.00% covered (danger)
0.00%
0 / 1
TranslationServiceProvider
0.00% covered (danger)
0.00%
0 / 65
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 1
 __invoke
0.00% covered (danger)
0.00%
0 / 65
0.00% covered (danger)
0.00%
0 / 1
2
1<?php
2
3/**
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; under version 2
7 * of the License (non-upgradable).
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
17 *
18 * Copyright (c) 2024 (original work) Open Assessment Technologies SA.
19 */
20
21declare(strict_types=1);
22
23namespace oat\taoQtiItem\model\Translation\ServiceProvider;
24
25use oat\generis\model\data\Ontology;
26use oat\generis\model\DependencyInjection\ContainerServiceProviderInterface;
27use oat\oatbox\log\LoggerService;
28use oat\tao\model\TaoOntology;
29use oat\tao\model\Translation\Service\ResourceLanguageRetriever;
30use oat\tao\model\Translation\Service\ResourceTranslatableStatusRetriever;
31use oat\tao\model\Translation\Service\TranslationCreationService;
32use oat\tao\model\Translation\Service\TranslationUniqueIdSetter;
33use oat\taoQtiItem\model\qti\Identifier\Service\QtiIdentifierSetter;
34use oat\taoQtiItem\model\qti\Service;
35use oat\taoQtiItem\model\Translation\Service\QtiLanguageRetriever;
36use oat\taoQtiItem\model\Translation\Service\QtiLanguageSetter;
37use oat\taoQtiItem\model\Translation\Service\ResourceTranslatableStatusHandler;
38use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
39use tao_models_classes_LanguageService;
40
41use function Symfony\Component\DependencyInjection\Loader\Configurator\service;
42
43class TranslationServiceProvider implements ContainerServiceProviderInterface
44{
45    public function __invoke(ContainerConfigurator $configurator): void
46    {
47        $services = $configurator->services();
48
49        $services
50            ->set(QtiLanguageRetriever::class, QtiLanguageRetriever::class)
51            ->args([
52                service(Service::class),
53                service(LoggerService::SERVICE_ID),
54            ]);
55
56        $services
57            ->get(ResourceLanguageRetriever::class)
58            ->call(
59                'setRetriever',
60                [
61                    TaoOntology::CLASS_URI_ITEM,
62                    service(QtiLanguageRetriever::class),
63                ]
64            );
65
66        $services
67            ->set(QtiLanguageSetter::class, QtiLanguageSetter::class)
68            ->args([
69                service(Service::class),
70                service(LoggerService::SERVICE_ID),
71                service(Ontology::SERVICE_ID),
72                service(tao_models_classes_LanguageService::class),
73            ]);
74
75        $services
76            ->set(ResourceTranslatableStatusHandler::class, ResourceTranslatableStatusHandler::class)
77            ->args([
78                service(Service::class),
79                service(LoggerService::SERVICE_ID),
80                service(Ontology::SERVICE_ID),
81            ]);
82
83        $services
84            ->get(TranslationUniqueIdSetter::class)
85            ->call(
86                'addQtiIdentifierSetter',
87                [
88                    service(QtiIdentifierSetter::class),
89                    TaoOntology::CLASS_URI_ITEM,
90                ]
91            );
92
93        $services
94            ->get(TranslationCreationService::class)
95            ->call(
96                'addPostCreation',
97                [
98                    TaoOntology::CLASS_URI_ITEM,
99                    service(QtiLanguageSetter::class),
100                ]
101            )
102            ->call(
103                'addPostCreation',
104                [
105                    TaoOntology::CLASS_URI_ITEM,
106                    service(TranslationUniqueIdSetter::class),
107                ]
108            );
109
110        $services
111            ->get(ResourceTranslatableStatusRetriever::class)
112            ->call(
113                'addCallable',
114                [
115                    TaoOntology::CLASS_URI_ITEM,
116                    service(ResourceTranslatableStatusHandler::class),
117                ]
118            );
119    }
120}