1
|
|
|
<?php |
2
|
|
|
/* |
3
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
4
|
|
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
5
|
|
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
6
|
|
|
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
7
|
|
|
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
8
|
|
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
9
|
|
|
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
10
|
|
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
11
|
|
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
12
|
|
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
13
|
|
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
14
|
|
|
* |
15
|
|
|
* This software consists of voluntary contributions made by many individuals |
16
|
|
|
* and is licensed under the MIT license. For more information, see |
17
|
|
|
* <http://www.doctrine-project.org>. |
18
|
|
|
*/ |
19
|
|
|
|
20
|
|
|
namespace Doctrine\DBAL; |
21
|
|
|
|
22
|
|
|
use Doctrine\DBAL\Logging\SQLLogger; |
23
|
|
|
use Doctrine\Common\Cache\Cache; |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* Configuration container for the Doctrine DBAL. |
27
|
|
|
* |
28
|
|
|
* @since 2.0 |
29
|
|
|
* @author Guilherme Blanco <[email protected]> |
30
|
|
|
* @author Jonathan Wage <[email protected]> |
31
|
|
|
* @author Roman Borschel <[email protected]> |
32
|
|
|
* @internal When adding a new configuration option just write a getter/setter |
33
|
|
|
* pair and add the option to the _attributes array with a proper default value. |
34
|
|
|
*/ |
35
|
|
|
class Configuration |
36
|
|
|
{ |
37
|
|
|
/** |
38
|
|
|
* The attributes that are contained in the configuration. |
39
|
|
|
* Values are default values. |
40
|
|
|
* |
41
|
|
|
* @var array |
42
|
|
|
*/ |
43
|
|
|
protected $_attributes = []; |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* Sets the SQL logger to use. Defaults to NULL which means SQL logging is disabled. |
47
|
|
|
* |
48
|
|
|
* @param \Doctrine\DBAL\Logging\SQLLogger|null $logger |
49
|
|
|
* |
50
|
|
|
* @return void |
51
|
|
|
*/ |
52
|
259 |
|
public function setSQLLogger(SQLLogger $logger = null) |
53
|
|
|
{ |
54
|
259 |
|
$this->_attributes['sqlLogger'] = $logger; |
55
|
259 |
|
} |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* Gets the SQL logger that is used. |
59
|
|
|
* |
60
|
|
|
* @return \Doctrine\DBAL\Logging\SQLLogger|null |
61
|
|
|
*/ |
62
|
262 |
|
public function getSQLLogger() |
63
|
|
|
{ |
64
|
262 |
|
return $this->_attributes['sqlLogger'] ?? null; |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* Gets the cache driver implementation that is used for query result caching. |
69
|
|
|
* |
70
|
|
|
* @return \Doctrine\Common\Cache\Cache|null |
71
|
|
|
*/ |
72
|
10 |
|
public function getResultCacheImpl() |
73
|
|
|
{ |
74
|
10 |
|
return $this->_attributes['resultCacheImpl'] ?? null; |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
/** |
78
|
|
|
* Sets the cache driver implementation that is used for query result caching. |
79
|
|
|
* |
80
|
|
|
* @param \Doctrine\Common\Cache\Cache $cacheImpl |
81
|
|
|
* |
82
|
|
|
* @return void |
83
|
|
|
*/ |
84
|
10 |
|
public function setResultCacheImpl(Cache $cacheImpl) |
85
|
|
|
{ |
86
|
10 |
|
$this->_attributes['resultCacheImpl'] = $cacheImpl; |
87
|
10 |
|
} |
88
|
|
|
|
89
|
|
|
/** |
90
|
|
|
* Sets the filter schema assets expression. |
91
|
|
|
* |
92
|
|
|
* Only include tables/sequences matching the filter expression regexp in |
93
|
|
|
* schema instances generated for the active connection when calling |
94
|
|
|
* {AbstractSchemaManager#createSchema()}. |
95
|
|
|
* |
96
|
|
|
* @param string $filterExpression |
97
|
|
|
* |
98
|
|
|
* @return void |
99
|
|
|
*/ |
100
|
|
|
public function setFilterSchemaAssetsExpression($filterExpression) |
101
|
|
|
{ |
102
|
|
|
$this->_attributes['filterSchemaAssetsExpression'] = $filterExpression; |
103
|
|
|
} |
104
|
|
|
|
105
|
|
|
/** |
106
|
|
|
* Returns filter schema assets expression. |
107
|
|
|
* |
108
|
|
|
* @return string|null |
109
|
|
|
*/ |
110
|
64 |
|
public function getFilterSchemaAssetsExpression() |
111
|
|
|
{ |
112
|
64 |
|
return $this->_attributes['filterSchemaAssetsExpression'] ?? null; |
113
|
|
|
} |
114
|
|
|
|
115
|
|
|
/** |
116
|
|
|
* Sets the default auto-commit mode for connections. |
117
|
|
|
* |
118
|
|
|
* If a connection is in auto-commit mode, then all its SQL statements will be executed and committed as individual |
119
|
|
|
* transactions. Otherwise, its SQL statements are grouped into transactions that are terminated by a call to either |
120
|
|
|
* the method commit or the method rollback. By default, new connections are in auto-commit mode. |
121
|
|
|
* |
122
|
|
|
* @param boolean $autoCommit True to enable auto-commit mode; false to disable it. |
123
|
|
|
* |
124
|
|
|
* @see getAutoCommit |
125
|
|
|
*/ |
126
|
1 |
|
public function setAutoCommit($autoCommit) |
127
|
|
|
{ |
128
|
1 |
|
$this->_attributes['autoCommit'] = (boolean) $autoCommit; |
129
|
1 |
|
} |
130
|
|
|
|
131
|
|
|
/** |
132
|
|
|
* Returns the default auto-commit mode for connections. |
133
|
|
|
* |
134
|
|
|
* @return boolean True if auto-commit mode is enabled by default for connections, false otherwise. |
135
|
|
|
* |
136
|
|
|
* @see setAutoCommit |
137
|
|
|
*/ |
138
|
132 |
|
public function getAutoCommit() |
139
|
|
|
{ |
140
|
132 |
|
return $this->_attributes['autoCommit'] ?? true; |
141
|
|
|
} |
142
|
|
|
} |
143
|
|
|
|