Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Sandbox error: generating repositories without a namespace breaks the generated file #164

Closed
agemmell opened this Issue Oct 4, 2011 · 0 comments

Comments

Projects
None yet
1 participant

agemmell commented Oct 4, 2011

If I have a Document which has an Annotation pointing to a repository class with no namespace, like this:

<?php

namespace Documents;

use Doctrine\ODM\MongoDB\Mapping\Annotations as ODM;

/** @ODM\Document(collection="users", repositoryClass="UserRepository") */
class User
{

If I then run the CLI command:

./mongodb odm:generate:repositories .

Then the file UserRepository is created in the same directory in which I ran the command above. However, the lack of a namespace for the repository class causes the code to have no stated namespace (obviously!) and the first letter of the class name is missing:

<?php

namespace ;

use Doctrine\ODM\MongoDB\DocumentRepository;

/**
 * serRepository
 *
 * This class was generated by the Doctrine ORM. Add your own custom
 * repository methods below.
 */
class serRepository extends DocumentRepository
{
}

If a namespace is required then perhaps an error should be output at the command line.
If a namespace is not required then the generated file should not contain the namespace declaration keyword and the classname should have the first letter!

I recommend the first solution (output an error).

@jwage jwage added a commit that referenced this issue Jan 4, 2014

@jwage jwage Default the custom repository class namespace to the same namespace a…
…s the document in the AnnotationDriver. Fixes #164.
8bcb29f

@jwage jwage closed this in #736 Jan 5, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment