Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
n/a
0 / 0
n/a
0 / 0
CRAP
n/a
0 / 0
PersistenceServiceProvider
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) 2022 (original work) Open Assessment Technologies SA (under the project TAO-PRODUCT);
19 *
20 * @author Gabriel Felipe Soares <gabriel.felipe.soares@taotesting.com>
21 */
22
23declare(strict_types=1);
24
25namespace oat\generis\persistence;
26
27use common_persistence_sql_Platform;
28use common_persistence_SqlPersistence;
29use Doctrine\DBAL\Query\QueryBuilder;
30use oat\generis\model\DependencyInjection\ContainerServiceProviderInterface;
31use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
32
33use function Symfony\Component\DependencyInjection\Loader\Configurator\service;
34
35/**
36 * @codeCoverageIgnore
37 */
38class PersistenceServiceProvider implements ContainerServiceProviderInterface
39{
40    public const DEFAULT_SQL_PERSISTENCE = common_persistence_SqlPersistence::class . '::default';
41    public const DEFAULT_SQL_PLATFORM = common_persistence_sql_Platform::class . '::default';
42    public const DEFAULT_QUERY_BUILDER = QueryBuilder::class . '::default';
43
44    public function __invoke(ContainerConfigurator $configurator): void
45    {
46        $services = $configurator->services();
47
48        $services->set(self::DEFAULT_SQL_PERSISTENCE, common_persistence_SqlPersistence::class)
49            ->factory(
50                [
51                    service(PersistenceManager::SERVICE_ID),
52                    'getPersistenceById'
53                ]
54            )
55            ->args(
56                [
57                    'default'
58                ]
59            )
60            ->public();
61
62        $services->set(self::DEFAULT_SQL_PLATFORM, common_persistence_sql_Platform::class)
63            ->factory(
64                [
65                    service(self::DEFAULT_SQL_PERSISTENCE),
66                    'getPlatForm'
67                ]
68            );
69
70        $services->set(self::DEFAULT_QUERY_BUILDER, QueryBuilder::class)
71            ->factory(
72                [
73                    service(self::DEFAULT_SQL_PLATFORM),
74                    'getQueryBuilder'
75                ]
76            )->share(false);
77    }
78}