Skip to content

Commit cbe640c

Browse files
Fix L5.2.11 breaking change in PresenceVerifier + support defining custom connection
1 parent 651f9e0 commit cbe640c

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

src/Validation/DoctrinePresenceVerifier.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,13 @@ class DoctrinePresenceVerifier implements PresenceVerifierInterface
1313
*/
1414
protected $registry;
1515

16+
/**
17+
* The database connection to use.
18+
*
19+
* @var string
20+
*/
21+
protected $connection = null;
22+
1623
/**
1724
* @param ManagerRegistry $registry
1825
*/
@@ -109,6 +116,10 @@ protected function queryExtraConditions(array $extra, QueryBuilder $builder)
109116
*/
110117
protected function getEntityManager($entity)
111118
{
119+
if (!is_null($this->connection)) {
120+
return $this->registry->getManager($this->connection);
121+
}
122+
112123
return $this->registry->getManagerForClass($entity);
113124
}
114125

@@ -121,4 +132,16 @@ protected function prepareParam($column)
121132
{
122133
return str_replace('.', '', $column);
123134
}
135+
136+
/**
137+
* Set the connection to be used.
138+
*
139+
* @param string $connection
140+
*
141+
* @return void
142+
*/
143+
public function setConnection($connection)
144+
{
145+
$this->connection = $connection;
146+
}
124147
}

0 commit comments

Comments
 (0)