如何在 zend framework 3 中的实体管理器配置学说中添加功能

How to add functions in entity manager configuration doctrine in zend framework 3

我目前有一个控制器和一个控制器工厂

AbcControllerFactory

public function __invoke(ContainerInterface $container, $requestedName, array $options = null){
    $entityManager                   =  $container->get("doctrine.entitymanager.orm_default");
    return new AbcController($entityManager);
}

和 AbcController

private $entityManager;
public function __construct($entityManager){
    $this->entityManager             =  $entityManager;
}

我正在尝试使用这个学说库

doctrine library for json functions

但唯一的问题是我无法添加这些功能

$config = new \Doctrine\ORM\Configuration();
$config->addCustomStringFunction(DqlFunctions\JsonExtract::FUNCTION_NAME, DqlFunctions\JsonExtract::class);
$config->addCustomStringFunction(DqlFunctions\JsonSearch::FUNCTION_NAME, DqlFunctions\JsonSearch::class);

我对这个理论有点陌生。谁能帮助我如何在现有的实体管理器配置中添加这些功能

这是我的 local.php 文件,其中存储了所有信息

return [
"doctrine" => [
    "connection" => [
        "orm_default" => [
            "driverClass" => PDOMySqlDriver::class,
            "params" => [
                "driver"             => "pdo_mysql",
                "dsn"                => "mysql:dbname=abc;host=localhost;charset=utf8",
                "host"     => "localhost",
                "user"     => "root",
                "password" => "",
                "dbname"   => "abc",
            ]
        ],
    ],
],

];

好吧,这对我来说有点迟钝。但是,我发现您可以在控制器中添加这样的功能:

$this->entityManager->getConfiguration()->addCustomStringFunction(DqlFunctions\JsonExtract::FUNCTION_NAME, DqlFunctions\JsonExtract::class);
$this->entityManager->getConfiguration()->addCustomStringFunction(DqlFunctions\JsonSearch::FUNCTION_NAME, DqlFunctions\JsonSearch::class);