【发布时间】:2019-03-12 09:13:15
【问题描述】:
现有的问题没有帮助。 我仍在学习 Symfony 并建立一个现有项目。试图从我的应用程序目录运行教义装置。
./app/console doctrine:fixtures:load --env test
运行它会给我以下错误
运行命令“doctrine:fixtures:load --env test --em default”时抛出错误。消息:“在链配置的命名空间 _XyzProjectName\CalendarContext\Domain\Model、Integration\GetFeedbackBundle\Model、_XyzProjectName\AccountingProcessContext\Domain\Model、_XyzProjectName\CaseContext\Domain 中找不到类 'ClientPortal\GenericBundle\Document\Accountant'” {"exception":"[object] (Doctrine\Common\Persistence\Mapping\MappingException(code: 0): 在链配置的命名空间_XyzProjectName\CalendarContext\Domain\ 中找不到类'ClientPortal\GenericBundle\Document\Accountant'模型、Integration\GetFeedbackBundle\Model、_XyzProjectName\AccountingProcessContext\Domain\Model、_XyzProjectName\CaseContext\Domain 在 /usr/local/var/www/1800-api/vendor/doctrine/persistence/lib/Doctrine/Common/Persistence/Mapping /MappingException.php:22)
当试图持久化类的对象时抛出这个异常
'ClientPortal\GenericBundle\Document\Accountant'
这是我在 config.yml 中的教义
doctrine:
dbal:
driver: pdo_pgsql
host: '%database_host%'
dbname: '%database_name%'
user: '%database_user%'
password: '%database_password%'
orm:
auto_generate_proxy_classes: "%kernel.debug%"
auto_mapping: true
mappings:
CalendarBundle:
prefix: '_XyzProjectName\CalendarContext\Domain\Model'
IntegrationGetFeedbackBundle:
prefix: 'Integration\GetFeedbackBundle\Model'
AccountingProcessBundle:
prefix: '_XyzProjectName\AccountingProcessContext\Domain\Model'
CaseBundle:
prefix: '_XyzProjectName\CaseContext\Domain'
GenericBundle:
type: "annotation"
prefix: 'ClientPortal\GenericBundle\Document'
dir: 'src'
is_bundle: false
引发此异常的 sn-p
$account = new ClientPortal\GenericBundle\Document\Accountant();//full namespace added for clarity - also this file lies in the same directory structure.
$account->setSfAccountantId($accountantId);
$account->setUsername($username);
$manager = new ObjectManager;
$manager->persist( $account ); //This throws the above mentioned exception
我的想法是,文件 ClientPortal\GenericBundle\Document\Accountant.php 正在自动加载,因为在其对象实例化时没有抛出异常。但是,配置或映射缺少一些东西,因为学说不知道如何持久化它的对象。
[源码][1]会计类
在 AppKernel 下注册的 GenericBundle(s)
new Website\GenericBundle\WebsiteGenericBundle(),
new Admin\GenericBundle\AdminGenericBundle(),
new ClientPortal\GenericBundle\ClientPortalGenericBundle(),
new TaxApp\GenericBundle\TaxAppGenericBundle(),
【问题讨论】:
-
嗨,您是否尝试将
ClientPortal\GenericBundle\Document添加到教义配置中的mappings部分? -
我们对 ClientPortal\GenericBundle\Document 配置一无所知。请提供更多信息。
-
@EugeneR 是的,我已经尝试在那里添加它。你能用确切的语法建议你的方法吗?
-
@vytsci 嘿,我不确定你到底需要什么。但是我添加了一些关于调用各个方法和目录结构的信息。如果您需要任何东西,请告诉我。
-
@Aman ClientPortal\GenericBundle\Document like EugeneR 建议尝试将其添加到映射中。因为它没有实体命名空间所以学说是看不到的。
标签: symfony