Doctrine 2 - ORM
  1. Doctrine 2 - ORM
  2. DDC-2606

orm:generate-proxies should generate type mappedSuperclass

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Minor Minor
    • Resolution: Unresolved
    • Affects Version/s: 2.3.4
    • Fix Version/s: None
    • Component/s: ORM
    • Security Level: All
    • Labels:
      None

      Description

      By using the concept of mapperSuperClasses and entity classes to enable inheritance features, the proxy classes are being auto generated as expected. If i switch to production mode and try to generate all classes manually by calling the orm:generate-proxies command, the mappedSuperClasses wont be auto generated, since this type is explicitely excluded in the skipClass method.

      In my opinion it is viable that the user can access either the mappedSuperClass (e.g. during a dql statement) directly or the entity class. Therefore i propose to change the skipClass method (AbstractProxyFactory.php) as shown below.

      protected function skipClass(ClassMetadata $metadata)

      { /* @var $metadata \Doctrine\ORM\Mapping\ClassMetadataInfo */ return $metadata->getReflectionClass()->isAbstract(); }

      If this is not as intended, this should be at least made configureable during the orm:generate-proxies command call.

        Activity

        Hide
        Marco Pivetta added a comment -

        Mapped superclasses don't need to be proxied, since the ORM won't ever have references to objects being an exact instance of a mapped superclass (not any of its subclasses). I guess they should be disabled for development mode too instead

        Show
        Marco Pivetta added a comment - Mapped superclasses don't need to be proxied, since the ORM won't ever have references to objects being an exact instance of a mapped superclass (not any of its subclasses). I guess they should be disabled for development mode too instead
        Hide
        Thomas Hava added a comment - - edited

        The ORM has references if the developer decides to use this class directly (isn't this viable?). Another example where i ran into this issue is in combination with relations and dql queries. If there's a relation e.g. book authors and their books (One-to-many).

        *) Entities:
        Author
        EntityAuthor
        Book
        EntityBook

        If i want to select a list of books and their authors i would use this dql statement:
        SELECT b FROM EntityBook b JOIN b.author a

        After querying the data i could do something like
        foreach ($books as $book)

        { echo $book->getAuthor()->getName(); }

        The "getAuthor()" method call does simply return the mapped super class "Author" instead of "EntityAuthor", which leads to the proxy class requirement!

        Show
        Thomas Hava added a comment - - edited The ORM has references if the developer decides to use this class directly (isn't this viable?). Another example where i ran into this issue is in combination with relations and dql queries. If there's a relation e.g. book authors and their books (One-to-many). *) Entities: Author EntityAuthor Book EntityBook If i want to select a list of books and their authors i would use this dql statement: SELECT b FROM EntityBook b JOIN b.author a After querying the data i could do something like foreach ($books as $book) { echo $book->getAuthor()->getName(); } The "getAuthor()" method call does simply return the mapped super class "Author" instead of "EntityAuthor", which leads to the proxy class requirement!

          People

          • Assignee:
            Benjamin Eberlei
            Reporter:
            Thomas Hava
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated: