我在doctrine.yml
中设置了两个实体经理
我必须将存储库注入服务,但是问题是存储库始终采用默认的实体管理器。
如何将特定的实体管理器提供给存储库。
在symfony 4中,我们可以使用ServiceEntityRepository
答案 0 :(得分:2)
您可以尝试将Doctrine\Common\Persistence\ManagerRegistry
注入您的构造中。然后使用$managerRegistry->getManager('your_connection_name');
例如:
//use Doctrine\Common\Persistence\ManagerRegistry;
private $connection;
function __construct(ManagerRegistry $em)
{
$this->connection = $em->getManager('your_connection_name');
}
答案 1 :(得分:1)
您需要将它们分别设置为命名服务,并将其 Range("i10").Copy Range("K22")
Range("K22").Interior.ColorIndex = 4
Ws.Cells(22, 11).Borders.LineStyle = XlLineStyle.xlContinuous
ElseIf Range("i10") <> "" And Range("K22").Value > 0.5 Then
Range("i10").Copy Range("K22")
Range("K22").Interior.ColorIndex = 3
Ws.Cells(22, 11).Borders.LineStyle = XlLineStyle.xlContinuous
Else
If Range("i10") <> "" And Range("i10").Value > 0.25 And Range("i10").Value <= 0.5 Then
Range("i10").Copy Range("K22")
Range("K22").Interior.ColorIndex = 6
Ws.Cells(22, 11).Borders.LineStyle = XlLineStyle.xlContinuous
End If
End If
设置为services.yaml
文件,而不是延迟/自动加载它们。