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