Subversion-Projekte lars-tiefland.laravel_shop

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
148 lars 1
<?php
2
 
3
namespace Doctrine\DBAL\Driver;
4
 
5
use Doctrine\DBAL\Connection;
6
use Doctrine\DBAL\Driver\API\ExceptionConverter;
7
use Doctrine\DBAL\Driver\API\PostgreSQL;
8
use Doctrine\DBAL\Exception;
9
use Doctrine\DBAL\Platforms\AbstractPlatform;
10
use Doctrine\DBAL\Platforms\PostgreSQL100Platform;
11
use Doctrine\DBAL\Platforms\PostgreSQL94Platform;
12
use Doctrine\DBAL\Platforms\PostgreSQLPlatform;
13
use Doctrine\DBAL\Schema\PostgreSQLSchemaManager;
14
use Doctrine\DBAL\VersionAwarePlatformDriver;
15
use Doctrine\Deprecations\Deprecation;
16
 
17
use function assert;
18
use function preg_match;
19
use function version_compare;
20
 
21
/**
22
 * Abstract base implementation of the {@see Driver} interface for PostgreSQL based drivers.
23
 */
24
abstract class AbstractPostgreSQLDriver implements VersionAwarePlatformDriver
25
{
26
    /**
27
     * {@inheritdoc}
28
     */
29
    public function createDatabasePlatformForVersion($version)
30
    {
31
        if (preg_match('/^(?P<major>\d+)(?:\.(?P<minor>\d+)(?:\.(?P<patch>\d+))?)?/', $version, $versionParts) === 0) {
32
            throw Exception::invalidPlatformVersionSpecified(
33
                $version,
34
                '<major_version>.<minor_version>.<patch_version>',
35
            );
36
        }
37
 
38
        $majorVersion = $versionParts['major'];
39
        $minorVersion = $versionParts['minor'] ?? 0;
40
        $patchVersion = $versionParts['patch'] ?? 0;
41
        $version      = $majorVersion . '.' . $minorVersion . '.' . $patchVersion;
42
 
43
        if (version_compare($version, '10.0', '>=')) {
44
            return new PostgreSQL100Platform();
45
        }
46
 
47
        Deprecation::trigger(
48
            'doctrine/dbal',
49
            'https://github.com/doctrine/dbal/pull/5060',
50
            'PostgreSQL 9 support is deprecated and will be removed in DBAL 4.'
51
                . ' Consider upgrading to Postgres 10 or later.',
52
        );
53
 
54
        return new PostgreSQL94Platform();
55
    }
56
 
57
    /**
58
     * {@inheritdoc}
59
     */
60
    public function getDatabasePlatform()
61
    {
62
        return new PostgreSQL94Platform();
63
    }
64
 
65
    /**
66
     * {@inheritdoc}
67
     *
68
     * @deprecated Use {@link PostgreSQLPlatform::createSchemaManager()} instead.
69
     */
70
    public function getSchemaManager(Connection $conn, AbstractPlatform $platform)
71
    {
72
        Deprecation::triggerIfCalledFromOutside(
73
            'doctrine/dbal',
74
            'https://github.com/doctrine/dbal/pull/5458',
75
            'AbstractPostgreSQLDriver::getSchemaManager() is deprecated.'
76
                . ' Use PostgreSQLPlatform::createSchemaManager() instead.',
77
        );
78
 
79
        assert($platform instanceof PostgreSQLPlatform);
80
 
81
        return new PostgreSQLSchemaManager($conn, $platform);
82
    }
83
 
84
    public function getExceptionConverter(): ExceptionConverter
85
    {
86
        return new PostgreSQL\ExceptionConverter();
87
    }
88
}