Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
doctrine-dbal
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Tomáš Trávníček
doctrine-dbal
Commits
d3fd4f6d
Unverified
Commit
d3fd4f6d
authored
Jul 08, 2020
by
Sergei Morozov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Introduce the driver middleware interface
parent
386309c0
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
41 additions
and
2 deletions
+41
-2
Configuration.php
src/Configuration.php
+25
-2
Middleware.php
src/Driver/Middleware.php
+12
-0
DriverManager.php
src/DriverManager.php
+4
-0
No files found.
src/Configuration.php
View file @
d3fd4f6d
...
...
@@ -3,16 +3,19 @@
namespace
Doctrine\DBAL
;
use
Doctrine\Common\Cache\Cache
;
use
Doctrine\DBAL\Driver\Middleware
;
use
Doctrine\DBAL\Logging\SQLLogger
;
/**
* Configuration container for the Doctrine DBAL.
*
* @internal When adding a new configuration option just write a getter/setter
* pair and add the option to the _attributes array with a proper default value.
* @internal
*/
class
Configuration
{
/** @var Middleware[] */
private
$middlewares
=
[];
/**
* The attributes that are contained in the configuration.
* Values are default values.
...
...
@@ -108,4 +111,24 @@ class Configuration
{
return
$this
->
_attributes
[
'autoCommit'
]
??
true
;
}
/**
* @param Middleware[] $middlewares
*
* @return $this
*/
public
function
setMiddlewares
(
array
$middlewares
)
:
self
{
$this
->
middlewares
=
$middlewares
;
return
$this
;
}
/**
* @return Middleware[]
*/
public
function
getMiddlewares
()
:
array
{
return
$this
->
middlewares
;
}
}
src/Driver/Middleware.php
0 → 100644
View file @
d3fd4f6d
<?php
declare
(
strict_types
=
1
);
namespace
Doctrine\DBAL\Driver
;
use
Doctrine\DBAL\Driver
;
interface
Middleware
{
public
function
wrap
(
Driver
$driver
)
:
Driver
;
}
src/DriverManager.php
View file @
d3fd4f6d
...
...
@@ -146,6 +146,10 @@ final class DriverManager
$driver
=
new
$className
();
foreach
(
$config
->
getMiddlewares
()
as
$middleware
)
{
$driver
=
$middleware
->
wrap
(
$driver
);
}
$wrapperClass
=
Connection
::
class
;
if
(
isset
(
$params
[
'wrapperClass'
]))
{
if
(
!
is_subclass_of
(
$params
[
'wrapperClass'
],
$wrapperClass
))
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment