summaryrefslogtreecommitdiff
path: root/vendor/doctrine/dbal/src/Configuration.php
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/doctrine/dbal/src/Configuration.php')
-rw-r--r--vendor/doctrine/dbal/src/Configuration.php156
1 files changed, 156 insertions, 0 deletions
diff --git a/vendor/doctrine/dbal/src/Configuration.php b/vendor/doctrine/dbal/src/Configuration.php
new file mode 100644
index 0000000..9aa001d
--- /dev/null
+++ b/vendor/doctrine/dbal/src/Configuration.php
@@ -0,0 +1,156 @@
1<?php
2
3declare(strict_types=1);
4
5namespace Doctrine\DBAL;
6
7use Doctrine\DBAL\Driver\Middleware;
8use Doctrine\DBAL\Exception\InvalidArgumentException;
9use Doctrine\DBAL\Schema\SchemaManagerFactory;
10use Psr\Cache\CacheItemPoolInterface;
11
12/**
13 * Configuration container for the Doctrine DBAL.
14 */
15class Configuration
16{
17 /** @var Middleware[] */
18 private array $middlewares = [];
19
20 /**
21 * The cache driver implementation that is used for query result caching.
22 */
23 private ?CacheItemPoolInterface $resultCache = null;
24
25 /**
26 * The callable to use to filter schema assets.
27 *
28 * @var callable
29 */
30 protected $schemaAssetsFilter;
31
32 /**
33 * The default auto-commit mode for connections.
34 */
35 protected bool $autoCommit = true;
36
37 private ?SchemaManagerFactory $schemaManagerFactory = null;
38
39 public function __construct()
40 {
41 $this->schemaAssetsFilter = static function (): bool {
42 return true;
43 };
44 }
45
46 /**
47 * Gets the cache driver implementation that is used for query result caching.
48 */
49 public function getResultCache(): ?CacheItemPoolInterface
50 {
51 return $this->resultCache;
52 }
53
54 /**
55 * Sets the cache driver implementation that is used for query result caching.
56 */
57 public function setResultCache(CacheItemPoolInterface $cache): void
58 {
59 $this->resultCache = $cache;
60 }
61
62 /**
63 * Sets the callable to use to filter schema assets.
64 */
65 public function setSchemaAssetsFilter(callable $schemaAssetsFilter): void
66 {
67 $this->schemaAssetsFilter = $schemaAssetsFilter;
68 }
69
70 /**
71 * Returns the callable to use to filter schema assets.
72 */
73 public function getSchemaAssetsFilter(): callable
74 {
75 return $this->schemaAssetsFilter;
76 }
77
78 /**
79 * Sets the default auto-commit mode for connections.
80 *
81 * If a connection is in auto-commit mode, then all its SQL statements will be executed and committed as individual
82 * transactions. Otherwise, its SQL statements are grouped into transactions that are terminated by a call to either
83 * the method commit or the method rollback. By default, new connections are in auto-commit mode.
84 *
85 * @see getAutoCommit
86 *
87 * @param bool $autoCommit True to enable auto-commit mode; false to disable it
88 */
89 public function setAutoCommit(bool $autoCommit): void
90 {
91 $this->autoCommit = $autoCommit;
92 }
93
94 /**
95 * Returns the default auto-commit mode for connections.
96 *
97 * @see setAutoCommit
98 *
99 * @return bool True if auto-commit mode is enabled by default for connections, false otherwise.
100 */
101 public function getAutoCommit(): bool
102 {
103 return $this->autoCommit;
104 }
105
106 /**
107 * @param Middleware[] $middlewares
108 *
109 * @return $this
110 */
111 public function setMiddlewares(array $middlewares): self
112 {
113 $this->middlewares = $middlewares;
114
115 return $this;
116 }
117
118 /** @return Middleware[] */
119 public function getMiddlewares(): array
120 {
121 return $this->middlewares;
122 }
123
124 public function getSchemaManagerFactory(): ?SchemaManagerFactory
125 {
126 return $this->schemaManagerFactory;
127 }
128
129 /** @return $this */
130 public function setSchemaManagerFactory(SchemaManagerFactory $schemaManagerFactory): self
131 {
132 $this->schemaManagerFactory = $schemaManagerFactory;
133
134 return $this;
135 }
136
137 /** @return true */
138 public function getDisableTypeComments(): bool
139 {
140 return true;
141 }
142
143 /**
144 * @param true $disableTypeComments
145 *
146 * @return $this
147 */
148 public function setDisableTypeComments(bool $disableTypeComments): self
149 {
150 if (! $disableTypeComments) {
151 throw new InvalidArgumentException('Column comments cannot be enabled anymore.');
152 }
153
154 return $this;
155 }
156}