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