Skip to content
New issue

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

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Console] doctrine:generate:entities when entity is in subfolder #3019

Closed
emilbayes opened this issue Jan 3, 2012 · 7 comments
Closed

[Console] doctrine:generate:entities when entity is in subfolder #3019

emilbayes opened this issue Jan 3, 2012 · 7 comments

Comments

@emilbayes
Copy link

I have an enitity folder that looks similar to this:

Entity/
    Subject.php
    Performance/
        Paper.php

The subject has an association like this:

    /**
     * @ORM\OneToMany(targetEntity="Performance/Paper", mappedBy="subject")
     */
    private $papers;

Likewise on the paper side:

    /**
     * @ORM\ManyToOne(targetEntity="Subject", inversedBy="papers")
     */
    private $subject;

When running doctrine:generate:entities it will generate a function like this:

    /**
     * Add papers
     *
     * @param Acme\PaperBundle\Entity\Performance/Paper $papers
     */
    public function addPerformance/PaperOne(\Tixz\IB\QuizBundle\Entity\Performance/PaperOne $papers)
    {
        $this->papers[] = $papers;
    }

Where the function name contains an illegal character and the last slashes should have been backslashes.

I hope this bug report has enough information to replicate the bug.

@emilbayes
Copy link
Author

Same error with function names and type casting in parameters when you try and use the "bundle shortcut":

AcmeBundle:Subject

@emilbayes
Copy link
Author

Not sure if this bug is appropiate here or belongs in Doctrine, but you can reference Paper as a targetEntity from Subject as this: AcmeBundle:Performance\Paper, but you can't reference Subject from Paper as AcmeBundle:Subject

@stof
Copy link
Member

stof commented Jan 3, 2012

@TiXz it is not a bug. AcmeBundle: is registered as an alias for the AcmeBundle\Entity namespace so if you have a subnamespace, you need to use it in the short notation.

and your mapping for the relation is wrong. First, the namespace separator is \, not /. And second, the targetEntity property must be a FQCN (or the aliased notation) when the class is not in the same namespace than the current one.

@emilbayes
Copy link
Author

Yes alright, I got the /and \ mixed up in the first comment. And I should have used either FQCN or the alias notation. But the console bug still stands, and trying to reference the root entity namespace from a subnamespace doesn't work (don't know if it is supposed to work) so I had to use FQCN.

@stof
Copy link
Member

stof commented Jan 3, 2012

using the short class name allows to reference a class in the same namespace, not a class in the MyBundle\Entity namespace (which has no special meaning as far as Doctrine ORM is concerned). For different namespaces, you need to use the FQCN

@vicb
Copy link
Contributor

vicb commented Mar 8, 2012

Should this be closed ?

@stof
Copy link
Member

stof commented Apr 4, 2012

yeah. It was a misuse of the shortcuts in the Doctrine mapping

@stof stof closed this as completed Apr 4, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants