Thursday, 12 September 2013

ZF2 Doctrine Repository Fatal Error

ZF2 Doctrine Repository Fatal Error

Trying to get my EntityRepository, but I'm getting a Fatal Error, Class
'Doctrine\Orm\EntityRepository' not found
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>

No comments:

Post a Comment