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/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>