试图获取我的EntityRepository,但是我收到致命错误,找不到类'Doctrine \ Orm \ EntityRepository'
Module.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(),
);
}
...
UserTypeFactory.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;
}
}
Doctrine Config(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>
答案 0 :(得分:0)
深夜节目的缩影。包是“Doctrine \ ORM \ EntityRepository”而不是“Doctrine \ Orm \ Entity ...”