Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 43
0.00% covered (danger)
0.00%
0 / 7
CRAP
0.00% covered (danger)
0.00%
0 / 1
DeliveryServiceProvider
0.00% covered (danger)
0.00%
0 / 43
0.00% covered (danger)
0.00%
0 / 7
56
0.00% covered (danger)
0.00%
0 / 1
 __invoke
0.00% covered (danger)
0.00%
0 / 6
0.00% covered (danger)
0.00%
0 / 1
2
 registerDeliveryPatchRequestHandlers
0.00% covered (danger)
0.00%
0 / 4
0.00% covered (danger)
0.00%
0 / 1
2
 registerRequestHandlers
0.00% covered (danger)
0.00%
0 / 14
0.00% covered (danger)
0.00%
0 / 1
2
 registerRepositories
0.00% covered (danger)
0.00%
0 / 2
0.00% covered (danger)
0.00%
0 / 1
2
 registerRequestValidators
0.00% covered (danger)
0.00%
0 / 2
0.00% covered (danger)
0.00%
0 / 1
2
 registerFactories
0.00% covered (danger)
0.00%
0 / 7
0.00% covered (danger)
0.00%
0 / 1
2
 registerServices
0.00% covered (danger)
0.00%
0 / 8
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) 2022 (original work) Open Assessment Technologies SA;
19 *
20 * @author Sergei Mikhailov <sergei.mikhailov@taotesting.com>
21 */
22
23declare(strict_types=1);
24
25namespace oat\taoDeliveryRdf\model\Delivery\ServiceProvider;
26
27use oat\generis\model\DependencyInjection\ContainerServiceProviderInterface;
28use oat\oatbox\event\EventManager;
29use oat\tao\model\Lists\Business\Validation\DependsOnPropertyValidator;
30use oat\taoDeliveryRdf\model\Delivery\Business\Service\DeliveryService;
31use oat\taoDeliveryRdf\model\Delivery\DataAccess\DeliveryRepository;
32use oat\taoDeliveryRdf\model\Delivery\Presentation\Web\Form\DeliveryFormFactory;
33use oat\taoDeliveryRdf\model\Delivery\Presentation\Web\RequestHandler\DeliveryPatchRequestHandler;
34use oat\taoDeliveryRdf\model\Delivery\Presentation\Web\RequestHandler\DeliverySearchRequestHandler;
35use oat\taoDeliveryRdf\model\Delivery\Presentation\Web\RequestHandler\JsonDeliveryPatchRequestHandler;
36use oat\taoDeliveryRdf\model\Delivery\Presentation\Web\RequestHandler\UrlEncodedFormDeliveryPatchRequestHandler;
37use oat\taoDeliveryRdf\model\Delivery\Presentation\Web\RequestValidator\DeliverySearchRequestValidator;
38use oat\taoDeliveryRdf\model\validation\DeliveryValidatorFactory;
39use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
40use Symfony\Component\DependencyInjection\Loader\Configurator\ServicesConfigurator;
41
42use function Symfony\Component\DependencyInjection\Loader\Configurator\service;
43
44class DeliveryServiceProvider implements ContainerServiceProviderInterface
45{
46    public function __invoke(ContainerConfigurator $configurator): void
47    {
48        $services = $configurator->services();
49
50        $this->registerRequestValidators($services);
51        $this->registerRequestHandlers($services);
52        $this->registerFactories($services);
53        $this->registerRepositories($services);
54        $this->registerServices($services);
55    }
56
57    private function registerDeliveryPatchRequestHandlers(ServicesConfigurator $services): void
58    {
59        $services
60            ->set(UrlEncodedFormDeliveryPatchRequestHandler::class, UrlEncodedFormDeliveryPatchRequestHandler::class);
61        $services
62            ->set(JsonDeliveryPatchRequestHandler::class, JsonDeliveryPatchRequestHandler::class);
63    }
64
65    private function registerRequestHandlers(ServicesConfigurator $services): void
66    {
67        $services
68            ->set(DeliveryPatchRequestHandler::class, DeliveryPatchRequestHandler::class)
69            ->public()
70            ->args([
71                service(DeliverySearchRequestHandler::class),
72                service(UrlEncodedFormDeliveryPatchRequestHandler::class),
73                service(JsonDeliveryPatchRequestHandler::class),
74            ]);
75
76        $services
77            ->set(DeliverySearchRequestHandler::class, DeliverySearchRequestHandler::class)
78            ->args([
79                service(DeliverySearchRequestValidator::class),
80            ]);
81
82        $this->registerDeliveryPatchRequestHandlers($services);
83    }
84
85    private function registerRepositories(ServicesConfigurator $services): void
86    {
87        $services
88            ->set(DeliveryRepository::class, DeliveryRepository::class);
89    }
90
91    private function registerRequestValidators(ServicesConfigurator $services): void
92    {
93        $services
94            ->set(DeliverySearchRequestValidator::class, DeliverySearchRequestValidator::class);
95    }
96
97    private function registerFactories(ServicesConfigurator $services): void
98    {
99        $services
100            ->set(DeliveryFormFactory::class, DeliveryFormFactory::class)
101            ->public()
102            ->args([
103                service(DeliveryValidatorFactory::class),
104                service(DependsOnPropertyValidator::class),
105            ]);
106    }
107
108    private function registerServices(ServicesConfigurator $services): void
109    {
110        $services
111            ->set(DeliveryService::class, DeliveryService::class)
112            ->public()
113            ->args([
114                service(DeliveryRepository::class),
115                service(DeliveryFormFactory::class),
116                service(EventManager::class),
117            ]);
118    }
119}