Doctrine:添加ORM配置文件
Doctrine: add ORM configuration file
我想在我的 Symfony 2.8 项目中添加一个自定义水化器。 official Doctrine 文档说要将以下代码添加到 ORM 配置文件中。
<?php
$em->getConfiguration()->addCustomHydrationMode('CustomHydrator', 'MyProject\Hydrators\CustomHydrator');
我的项目中还没有这样的文件,我应该在哪里创建它以及如何将它包含到我的 Symfony 应用程序中?
你应该在 Symfony 的官方文档中找到你需要的一切。
http://symfony.com/doc/current/reference/configuration/doctrine.html
Symfony 对大多数包使用 YAML 或 XML 配置文件。在您的情况下,您只需要在 doctrine.orm.entity_managers.YOUR_EM.hydrators
.
中添加保湿器
您可以将 Hydrator 文件放在您的 Bundle 中,路径示例:
\Your\Bundle\Hydrators\ListHydrator
更多信息:https://techpunch.co.uk/development/create-custom-doctrine2-hydrator-symfony2
我想在我的 Symfony 2.8 项目中添加一个自定义水化器。 official Doctrine 文档说要将以下代码添加到 ORM 配置文件中。
<?php
$em->getConfiguration()->addCustomHydrationMode('CustomHydrator', 'MyProject\Hydrators\CustomHydrator');
我的项目中还没有这样的文件,我应该在哪里创建它以及如何将它包含到我的 Symfony 应用程序中?
你应该在 Symfony 的官方文档中找到你需要的一切。
http://symfony.com/doc/current/reference/configuration/doctrine.html
Symfony 对大多数包使用 YAML 或 XML 配置文件。在您的情况下,您只需要在 doctrine.orm.entity_managers.YOUR_EM.hydrators
.
您可以将 Hydrator 文件放在您的 Bundle 中,路径示例:
\Your\Bundle\Hydrators\ListHydrator
更多信息:https://techpunch.co.uk/development/create-custom-doctrine2-hydrator-symfony2