0

试图获取我的 EntityRepository,但我遇到了致命错误,找不到类 'Doctrine\Orm\EntityRepository'

模块.php

<?php
...
public function getServiceConfig()
{
    return array(
        'abstract_factories' => array(),
        'aliases' => array(),
        'factories' => array(
            'rd.user.usertypes' => 'User\Factory\UserTypeFactory',
        ),
        'invokables' => array(
            'orm' => 'Doctrine\ORM\EntityManager',
        ),
        'services' => array(),
        'shared' => array(),
    );
}
...

用户类型工厂.php

namespace User\Factory;

use Zend\ServiceManager\FactoryInterface;
use Zend\ServiceManager\ServiceLocatorInterface;
use User\Service\UserType;

class UserTypeFactory implements FactoryInterface
{
    public function createService(ServiceLocatorInterface $sm)
    {
        $usertypes = new UserType();
        $usertypes->setEntityManager($sm->get('Doctrine\Orm\EntityManager'));
        $repo = $usertypes->getEntityManager()->getRepository('User\Repository\UserTypeRepository');
        $mattertypes->setEntityRepository($repo);
        return $mattertypes;
    }
}

教义配置 (config/xml/User.Entity.UserType.dcm.xml)

<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://raw.github.com/doctrine/doctrine2/master/doctrine-mapping.xsd">

    <entity name="User\Entity\UserType" table="userTypes" repository-class="User\Repository\MatterTypeRepository">
        <field name="typeId" type="integer" />
        <field name="name" type="string" />
        <id name="id" column="id" type="integer">
            <generator strategy="AUTO" />
        </id>
    </entity>
</doctrine-mapping>
4

1 回答 1

0

深夜编程的缩影。包是“Doctrine\ORM\EntityRepository”而不是“Doctrine\Orm\Entity...”

于 2013-09-15T21:33:25.023 回答