Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
n/a
0 / 0
n/a
0 / 0
CRAP
n/a
0 / 0
TranslationServiceProvider
n/a
0 / 0
n/a
0 / 0
1
n/a
0 / 0
 __invoke
n/a
0 / 0
n/a
0 / 0
1
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\tao\model\Translation\ServiceProvider;
24
25use oat\generis\model\data\Ontology;
26use oat\generis\model\DependencyInjection\ContainerServiceProviderInterface;
27use oat\generis\model\kernel\persistence\smoothsql\search\ComplexSearchService;
28use oat\generis\model\resource\Service\ResourceDeleter;
29use oat\oatbox\event\EventManager;
30use oat\oatbox\log\LoggerService;
31use oat\oatbox\user\UserLanguageServiceInterface;
32use oat\tao\model\featureFlag\FeatureFlagChecker;
33use oat\tao\model\featureFlag\Service\FeatureFlagPropertiesMapping;
34use oat\tao\model\Language\Business\Contract\LanguageRepositoryInterface;
35use oat\tao\model\TaoOntology;
36use oat\tao\model\Translation\Factory\ResourceTranslatableFactory;
37use oat\tao\model\Translation\Factory\ResourceTranslationFactory;
38use oat\tao\model\Translation\Form\Modifier\TranslationFormModifier;
39use oat\tao\model\Translation\Repository\ResourceTranslatableRepository;
40use oat\tao\model\Translation\Repository\ResourceTranslationRepository;
41use oat\tao\model\Translation\Service\ResourceLanguageRetriever;
42use oat\tao\model\Translation\Service\ResourceMetadataPopulateService;
43use oat\tao\model\Translation\Service\ResourceTranslatableRetriever;
44use oat\tao\model\Translation\Service\ResourceTranslatableStatusRetriever;
45use oat\tao\model\Translation\Service\ResourceTranslationRetriever;
46use oat\tao\model\Translation\Service\TranslatedIntoLanguagesSynchronizer;
47use oat\tao\model\Translation\Service\TranslationCreationService;
48use oat\tao\model\Translation\Service\TranslationDeletionService;
49use oat\tao\model\Translation\Service\TranslationSyncService;
50use oat\tao\model\Translation\Service\TranslationUniqueIdSetter;
51use oat\tao\model\Translation\Service\TranslationUpdateService;
52use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
53
54use function Symfony\Component\DependencyInjection\Loader\Configurator\service;
55
56/**
57 * @codeCoverageIgnore
58 */
59class TranslationServiceProvider implements ContainerServiceProviderInterface
60{
61    public function __invoke(ContainerConfigurator $configurator): void
62    {
63        $services = $configurator->services();
64        $services->set(ResourceMetadataPopulateService::class, ResourceMetadataPopulateService::class)
65            ->args(
66                [
67                    service(Ontology::SERVICE_ID),
68                ]
69            );
70
71        $services->set(ResourceTranslationRepository::class, ResourceTranslationRepository::class)
72            ->args(
73                [
74                    service(Ontology::SERVICE_ID),
75                    service(ComplexSearchService::SERVICE_ID),
76                    service(ResourceTranslationFactory::class),
77                    service(LoggerService::SERVICE_ID),
78                ]
79            );
80
81        $services->set(ResourceTranslatableRepository::class, ResourceTranslatableRepository::class)
82            ->args(
83                [
84                    service(Ontology::SERVICE_ID),
85                    service(ResourceTranslatableFactory::class)
86                ]
87            );
88
89        $services->set(ResourceTranslationFactory::class, ResourceTranslationFactory::class)
90            ->args(
91                [
92                    service(ResourceMetadataPopulateService::class)
93                ]
94            );
95
96        $services->set(ResourceTranslatableFactory::class, ResourceTranslatableFactory::class)
97            ->args(
98                [
99                    service(ResourceMetadataPopulateService::class)
100                ]
101            );
102
103        $services->set(ResourceTranslationRetriever::class, ResourceTranslationRetriever::class)
104            ->args(
105                [
106                    service(ResourceTranslationRepository::class)
107                ]
108            )
109            ->public();
110
111        $services->set(ResourceTranslatableRetriever::class, ResourceTranslatableRetriever::class)
112            ->args(
113                [
114                    service(ResourceTranslatableRepository::class)
115                ]
116            )
117            ->public();
118
119        $services
120            ->set(TranslationFormModifier::class, TranslationFormModifier::class)
121            ->args([
122                service(FeatureFlagChecker::class),
123                service(FeatureFlagPropertiesMapping::class),
124                service(Ontology::SERVICE_ID),
125            ]);
126
127        $services
128            ->set(TranslatedIntoLanguagesSynchronizer::class, TranslatedIntoLanguagesSynchronizer::class)
129            ->args([
130                service(Ontology::SERVICE_ID),
131                service(ResourceTranslationRepository::class),
132            ]);
133
134        $services
135            ->set(TranslationCreationService::class, TranslationCreationService::class)
136            ->args(
137                [
138                    service(Ontology::SERVICE_ID),
139                    service(ResourceTranslatableRepository::class),
140                    service(ResourceTranslationRepository::class),
141                    service(LanguageRepositoryInterface::class),
142                    service(LoggerService::SERVICE_ID),
143                    service(TranslatedIntoLanguagesSynchronizer::class),
144                    service(EventManager::SERVICE_ID),
145                ]
146            )
147            ->public();
148
149        $services
150            ->set(TranslationDeletionService::class, TranslationDeletionService::class)
151            ->args(
152                [
153                    service(Ontology::SERVICE_ID),
154                    service(ResourceDeleter::class),
155                    service(ResourceTranslationRepository::class),
156                    service(LoggerService::SERVICE_ID),
157                    service(TranslatedIntoLanguagesSynchronizer::class),
158                    service(EventManager::SERVICE_ID),
159                ]
160            )
161            ->public();
162
163        $services
164            ->set(TranslationUpdateService::class, TranslationUpdateService::class)
165            ->args(
166                [
167                    service(Ontology::SERVICE_ID),
168                    service(LoggerService::SERVICE_ID),
169                    service(TranslatedIntoLanguagesSynchronizer::class),
170                    service(EventManager::SERVICE_ID),
171                ]
172            )
173            ->public();
174
175        $services
176            ->set(TranslationSyncService::class, TranslationSyncService::class)
177            ->args([
178                service(Ontology::SERVICE_ID),
179                service(ResourceTranslationRepository::class),
180                service(LoggerService::SERVICE_ID),
181                service(TranslatedIntoLanguagesSynchronizer::class),
182            ])
183            ->public();
184
185        $services
186            ->set(ResourceLanguageRetriever::class, ResourceLanguageRetriever::class)
187            ->args([
188                service(UserLanguageServiceInterface::SERVICE_ID),
189            ])
190            ->public();
191
192        $services
193            ->set(TranslationUniqueIdSetter::class, TranslationUniqueIdSetter::class)
194            ->args([
195                service(FeatureFlagChecker::class),
196                service(Ontology::SERVICE_ID),
197            ]);
198
199        $services
200            ->set(ResourceTranslatableStatusRetriever::class, ResourceTranslatableStatusRetriever::class)
201            ->args([
202                service(Ontology::SERVICE_ID),
203                service(LoggerService::SERVICE_ID),
204            ])
205            ->public();
206
207        $services
208            ->get(FeatureFlagPropertiesMapping::class)
209            ->call(
210                'addFeatureProperties',
211                [
212                    'FEATURE_FLAG_TRANSLATION_ENABLED',
213                    [
214                        TaoOntology::PROPERTY_TRANSLATION_ORIGINAL_RESOURCE_URI,
215                        TaoOntology::PROPERTY_LANGUAGE,
216                        TaoOntology::PROPERTY_TRANSLATION_STATUS,
217                        TaoOntology::PROPERTY_TRANSLATION_PROGRESS,
218                        TaoOntology::PROPERTY_TRANSLATION_TYPE,
219                        TaoOntology::PROPERTY_TRANSLATED_INTO_LANGUAGES,
220                    ],
221                ]
222            );
223    }
224}