Details

    • Type: Improvement Improvement
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Invalid
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: ORM
    • Security Level: All

      Description

      Sometimes is necessary some associations(many to many) in the mappedSuperClass. This associations should not be lost (inversedBy side and mappedBy ). The only one way to get this, was to implement an abstract class as Single Inheritance Table and then the mappedSuperClass inherit of this. But this is not optimum, because we are losing the OOP, creating classes which should not exist.

      I realized of this when i was creating my bundle to be used for some projects, but I needed each project could extends from my class and add some properties or methods according their needs.

      This is the link where you can see more details of this:

      http://stackoverflow.com/questions/16405556/mapped-super-class-symfony2-2

      Thanks for your attention.

        Activity

        Hide
        Marco Pivetta added a comment -

        Mapped superclasses cannot be referenced as they are only meant to provide some simplification by allowing inherited mappings in child classes.

        If you want to enforce some kind of association in third party libraries, you can define interfaces and reference those: then, with a listener (during the onLoadMetadata event), replace the interfaces in mappings with (configured) concrete class names.

        Show
        Marco Pivetta added a comment - Mapped superclasses cannot be referenced as they are only meant to provide some simplification by allowing inherited mappings in child classes. If you want to enforce some kind of association in third party libraries, you can define interfaces and reference those: then, with a listener (during the onLoadMetadata event), replace the interfaces in mappings with (configured) concrete class names.
        Hide
        Petter Castro added a comment -

        I did it, and everything worked perfectly. However, is there a way to dynamically change the "resolve_target_entities" inside my LoadClassMetadata or inside my php code?.
        I would like the user makes this configurations with params from my bundle. In background, my bundle will configure these params for doctrine.
        Could i do that?

        Thanks again for your attention.

        Show
        Petter Castro added a comment - I did it, and everything worked perfectly. However, is there a way to dynamically change the "resolve_target_entities" inside my LoadClassMetadata or inside my php code?. I would like the user makes this configurations with params from my bundle. In background, my bundle will configure these params for doctrine. Could i do that? Thanks again for your attention.
        Hide
        Petter Castro added a comment - - edited

        I was thinking in duplicate some code of yours. Exactly this one:

        $def = $container->findDefinition('doctrine.orm.listeners.resolve_target_entity');
        foreach ($config['resolve_target_entities'] as $name => $implementation) {
             $def->addMethodCall('addResolveTargetEntity', array(
             $name, $implementation, array()
             ));
        }
        
        Show
        Petter Castro added a comment - - edited I was thinking in duplicate some code of yours. Exactly this one: $def = $container->findDefinition('doctrine.orm.listeners.resolve_target_entity'); foreach ($config['resolve_target_entities'] as $name => $implementation) { $def->addMethodCall('addResolveTargetEntity', array( $name, $implementation, array() )); }
        Hide
        Marco Pivetta added a comment -

        That's exactly how this has to be done.

        Show
        Marco Pivetta added a comment - That's exactly how this has to be done.
        Hide
        Petter Castro added a comment -

        I did but there is a problem.... The service doctrine.orm.listeners.resolve_target_entity is not public. So i can't use it in my bundle. I wouldn't like to duplicate all code from this Service. How could I do?

        Show
        Petter Castro added a comment - I did but there is a problem.... The service doctrine.orm.listeners.resolve_target_entity is not public. So i can't use it in my bundle. I wouldn't like to duplicate all code from this Service. How could I do?
        Hide
        Marco Pivetta added a comment -

        That's an issue for the DoctrineBundle, not for the ORM.

        Show
        Marco Pivetta added a comment - That's an issue for the DoctrineBundle, not for the ORM.
        Hide
        Petter Castro added a comment -

        Ok thanks a lot for your help. I will redirect my question to them.

        Show
        Petter Castro added a comment - Ok thanks a lot for your help. I will redirect my question to them.

          People

          • Assignee:
            Marco Pivetta
            Reporter:
            Petter Castro
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: