Try repositoryClass instead of RepositoryClass.

- Jon

On Tue, Mar 29, 2011 at 8:44 AM, cdecarlo <[email protected]> wrote:

> Hi,
>
> To be honest I'm not sure if the problem is with me and my
> understanding of preferred directory structure or the code but here is
> the problem I was recently faced with.
>
> I'm using yml to map my entities and I am planning on having Entity
> Repositories for most of my entities. The docs don't really touch on
> how to define the RepositoryClass in the yml mapping so I took a
> couple stabs at it and failed miserably. The exception being thrown
> was:
>
> Repository $metadata->customRepositoryClassName and bundle don't have
> a common namespace, generation failed because the target  directory
> cannot be detected.
>
> This exception is thrown if the customRespositoryClassName isn't a
> part of the bundle namespace (returned by Symfony\Component\HttpKernel
> \Bundle\Bundle#getNamespace). So in my efforts to get this to work
> without modifying the command I prepended the bundle namespace to the
> definition of the RepositoryClass in the yml file.
>
> eg.
>
> # src/Acme/DemoBundle/Resources/config/doctrine/metadata/orm/
> Acme.DemoBundle.Entity.Post.dcm.yml
> Acme\DemoBundle\Entity\Post:
>  type: entity
>  table: posts
>  RepositoryClass: AcmeDemoBundle\Entity\PostRepository
>
> This 'worked' but as a result a new directory called AcmeDemoBundle
> was created in the /src directory and the path to the
> PostRepository.php class was /src/AcmeDemoBundle/Entity/
> PostRepository.php.  At this point I'm convinced that there is a
> problem with the doctrine:generate:repositories command, so I changed
> the if clause which was triggering the exception from:
>
>                    if (strpos($metadata->customRepositoryClassName,
> $foundBundle->getNamespace()) === false) {
>
> to:
>
>                    if (strpos(str_replace("\\","",$metadata-
> >customRepositoryClassName), $foundBundle->getNamespace()) === false)
> {
>
> and the yml RepositoryClass definition to:
>
> # src/Acme/DemoBundle/Resources/config/doctrine/metadata/orm/
> Acme.DemoBundle.Entity.Post.dcm.yml
> Acme\DemoBundle\Entity\Post:
>  type: entity
>  table: posts
>  RepositoryClass: Acme\DemoBundle\Entity\PostRepository
>
> This time when I ran the command it generated the repository class in /
> src/Acme/DemoBundle/Entity which I think is the original intention.
>
> Am I correct in thinking this is a little bug or am I just not
> understanding somehting?
>
> Thanks,
>
> Colin
>
>
>
> --
> If you want to report a vulnerability issue on symfony, please send it to
> security at symfony-project.com
>
> You received this message because you are subscribed to the Google
> Groups "symfony developers" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group at
> http://groups.google.com/group/symfony-devs?hl=en
>



-- 
Connect with me on *http://twitter.com/jwage* <http://twitter.com/jwage>
 and http://about.me/jwage to keep in touch.

-- 
If you want to report a vulnerability issue on symfony, please send it to 
security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "symfony developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/symfony-devs?hl=en

Reply via email to