I have the following problem, setup Entities with annotation in:

root/model/Entities

>From this I generated both proxies and repositories.

Configured my module using:

'doctrine' => array(
        'driver' => array(
            // defines an annotation driver with two paths, and names it 
`my_annotation_driver`
            'my_annotation_driver' => array(
                'class' => 'Doctrine\ORM\Mapping\Driver\AnnotationDriver',
                'cache' => 'array',
                'paths' => array(__DIR__ . '/../../../model/Entities'
                ),
            ),
            // default metadata driver, aggregates all other drivers into a 
single one.
            // Override `orm_default` only if you know what you're doing
            'orm_default' => array(
                'drivers' => array(
                    // register `my_annotation_driver` for any entity under 
namespace `Entities`
                    'Entities' => 'my_annotation_driver'
                )
            )
        )
    )

For example one of my model classes is called Genre and looks like:

<?php

namespace Entities;

use Doctrine\ORM\Mapping as ORM;
use Entities\Product;

/**
 * @ORM\Entity(repositoryClass="GenreRepository") @ORM\Table(name="genres")
 * */
class Genre
{

    /** @ORM\Id @ORM\Column(type="integer", unique=true) 
@ORM\GeneratedValue * */
    protected $id;

    /** @ORM\Column(type="string") * */
    protected $name;

    /** @ORM\Column(type="integer", nullable=true) * */
    protected $ranking;

    /**
     * Unidirectional - Many-To-One
     *
     * @ORM\ManyToOne(targetEntity="Product")
     */
    protected $product;

    /**
     * Get id
     *
     * @return integer 
     */
    public function getId()
    {
        return $this->id;
    }

    /**
     * Set name
     *
     * @param string $name
     * @return Genre
     */
    public function setName($name)
    {
        $this->name = $name;

        return $this;
    }

    /**
     * Get name
     *
     * @return string 
     */
    public function getName()
    {
        return $this->name;
    }

    /**
     * Set ranking
     *
     * @param integer $ranking
     * @return Genre
     */
    public function setRanking($ranking)
    {
        $this->ranking = $ranking;

        return $this;
    }

    /**
     * Get ranking
     *
     * @return integer 
     */
    public function getRanking()
    {
        return $this->ranking;
    }

    /**
     * Set product
     *
     * @param Product $product
     * @return Genre
     */
    public function setProduct(Product $product = null)
    {
        $this->product = $product;

        return $this;
    }

    /**
     * Get product
     *
     * @return \Product 
     */
    public function getProduct()
    {
        return $this->product;
    }

}

In the controller I try to obtain the GenreRepository, however I keep 
getting:

Doctrine\Common\Persistence\Mapping\MappingException: Class Genre does not 
exist


Here is my Controller:

<?php

namespace Cms\Controller;

use \Cms\Form\AlbumForm,
    \Cms\Model\Album,
    \Entities\Genre,
    \Exception,
    \Zend\Feed\PubSubHubbub\HttpResponse,
    \Zend\Mvc\Controller\AbstractActionController,
    \Zend\Mvc\MvcEvent,
    \Zend\View\Model\ViewModel,
    \Zend\XmlRpc\Response;

class AlbumController extends AbstractActionController
{

    protected $albumTable;

    public function getAlbumTable()
    {
        if (!$this->albumTable)
        {
            $sm = $this->getServiceLocator();
            $this->albumTable = $sm->get('Cms\Model\AlbumTable');
        }
        return $this->albumTable;
    }

    public function indexAction()
    {
        $entityManager = $this
                ->getServiceLocator()
                ->get('Doctrine\ORM\EntityManager');

        $repository = $entityManager->getRepository('Genre');
        $genre = new Genre();
        $genre->setName('Techno');

        $entityManager->persist($genre);
        $entityManager->flush();

        return new ViewModel(array(
            'albums' => $this->getAlbumTable()->fetchAll()
        ));
    }
...

I have tried to pass Entities\Genre as well to the 
entityManager->getRepository, but to no avail.

Could anyone point me into the right direction. Thanks!

-- 
You received this message because you are subscribed to the Google Groups 
"doctrine-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/doctrine-user.
For more options, visit https://groups.google.com/d/optout.

Reply via email to