Doctrine MongoDB ODM
  1. Doctrine MongoDB ODM
  2. MODM-27

It would be great to have a way to use different collection classes with referencing/embedding

    Details

    • Type: Improvement Improvement
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Won't Fix
    • Affects Version/s: 1.0.0ALPHA1
    • Fix Version/s: None
    • Component/s: Hydration
    • Labels:
      None

      Description

      Currently ODM creates an instance of ArrayCollection for every referenced/embedded collection.

      It would be great, if there was a way to specify which collection class should be actually used. Imagine simple use-case: one have created class TagsCollection extends ArrayCollection with __toString method, which automatically transforms collection of tags to comma-separated tags string.

      Would it be possible to have e.g. @EmbedMany(collection="TagsCollection") ?

        Activity

        Hide
        Jonathan H. Wage added a comment -

        Is it not just as simple for you to do this yourself instead of cluttering the Doctrine codebase? Simply wrap your collection with your own class. Use another class to do what you want, passing the collection to it.

        Show
        Jonathan H. Wage added a comment - Is it not just as simple for you to do this yourself instead of cluttering the Doctrine codebase? Simply wrap your collection with your own class. Use another class to do what you want, passing the collection to it.
        Hide
        Jonathan H. Wage added a comment -

        Also, doing this I think would not be a good idea as it's not really related to object domain persistence. I think you should do this in your own project by wrapping collections or having a convenience/helper method you can pass a collection of tags to, to get the comma separated tags string. I also think this is not a part of your domain model, it is more a part of your view layer.

        Show
        Jonathan H. Wage added a comment - Also, doing this I think would not be a good idea as it's not really related to object domain persistence. I think you should do this in your own project by wrapping collections or having a convenience/helper method you can pass a collection of tags to, to get the comma separated tags string. I also think this is not a part of your domain model, it is more a part of your view layer.
        Hide
        Vladimir Razuvaev added a comment -

        Well, that was just a simple example, I am pretty sure there might be other use-cases (related to domain model). Anyway if that is not an easy change, I'll use ArrayCollection here. Thanks for clarifications.

        Show
        Vladimir Razuvaev added a comment - Well, that was just a simple example, I am pretty sure there might be other use-cases (related to domain model). Anyway if that is not an easy change, I'll use ArrayCollection here. Thanks for clarifications.

          People

          • Assignee:
            Jonathan H. Wage
            Reporter:
            Vladimir Razuvaev
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: