更新以反映讨论
我想实现一些自定义逻辑来选择正确的实体管理器。我认为这就像覆盖doctrine.class 参数、扩展Doctrine\Bundle\DoctrineBundle\Registry 和覆盖getManager() 方法一样简单。但是,当我这样做时,我收到以下错误:
ErrorException: Warning: strtolower() expects parameter 1 to be string, object given in /Applications/MAMP/htdocs/nmevent/app/bootstrap.php.cache line 119
这是代码:
<?php
namespace NM\Bundle\MultiTenantBundle\Doctrine;
use Doctrine\Bundle\DoctrineBundle\Registry;
class TenantRegistry extends Registry
{
/**
* {@inheritdoc}
*
* @throws \InvalidArgumentException
*/
public function getManager($name = null)
{
if (null === $name) {
$name = $this->defaultManager;
}
$managers = $this->getManagers();
if (!isset($managers[$name])) {
throw new \InvalidArgumentException(sprintf('Doctrine %s Manager named "%s" does not exist.', $this->getName(), $name));
}
return $this->getService($managers[$name]);
}
}
我在这里想念什么?