Skip to content

corrupt custom collection on persist is created #2178

Open
@g13013

Description

@g13013
Q A
Version 2.0.5
Support Question yes
Bug Report for me yes

Support Question

I have implemented a custom collection for a field that extends from ArrayCollection

class MyCollection extends ArrayCollection
{
    public function customFunction()
}

class MyDoc {
    /**
     * @ReferenceMany(
     *     collectionClass=MyCollection::class,
     *     targetDocument=Document::class,
     *     orphanRemoval=true,
     *     strategy="atomicSetArray",
     *     cascade={"persist"}
     * )
     */
    private $collection = null;
}

The save operation works without problem, however, when trying to load the saved entity, the collection field loads with ArrayCollection instead of MyCollection, this makes calls to MyCollection::customFunction fail, is this the correct behavior ?, I would expect the collectionClass to be instantiated on save as well as on data fetch

also the generated wrapper persistent class make use of \Doctrine\ODM\MongoDB\PersistentCollection\PersistentCollectionInterface which generates a notice

1x: The "Doctrine\ODM\MongoDB\PersistentCollection\PersistentCollectionInterface" interface is considered internal. It may change without further notice. You should not use it from PersistentCollections\MyCollectionPersistent`

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions