【发布时间】:2014-05-13 20:17:18
【问题描述】:
已经有一些关于这个主题的其他问题,但没有一个是真正有帮助的。我是 Symfony 的新手,所以很难理解它。
我在文件 Client\IntranetBundle\LDAP\LDAPAuthenticationProvider.php 中,此代码导致错误:
$user = new LDAPUser($username);
我确实添加了它的命名空间:
use Client\IntranetBundle\LDAP\LDAPUser;
LDAPUser 实现 UserInterface
我得到的错误是
The class 'Client\IntranetBundle\LDAP\LDAPUser' was not found in the chain
configured namespaces Client\ClientBundle\Entity
这是什么意思?根据我的阅读,它与映射有关。
我在 config.yml 中的 Doctrine orm 设置为:
orm:
auto_generate_proxy_classes: %kernel.debug%
auto_mapping: true
希望你能帮助我。
编辑#1:
其实我发现不是
$user = new LDAPUser($username);
这是导致错误的原因,但它是在我尝试保留此实体时:
$entityManager->persist($user);
编辑 #2:
我对映射出了什么问题感到困惑:
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping
http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
<entity name="Client\IntranetBundle\LDAP\LDAPUser" table="users" repository-class="Client\ClientBundle\Repository\UserRepository">
<id name="id" type="integer" column="id">
<generator strategy="AUTO" />
</id>
<field name="username" column="username" type="string" length="100" />
</entity>
也许是因为我在两个捆绑包之间跳跃?
【问题讨论】:
-
persist 导致错误(不是 new 实体实例化)