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

Softdeleteable ODM isn't going to work #231

Open
dgruseck opened this issue Feb 22, 2014 · 2 comments
Open

Softdeleteable ODM isn't going to work #231

dgruseck opened this issue Feb 22, 2014 · 2 comments

Comments

@dgruseck
Copy link

Hi,

I'm trying to configure the softdeletable feature for my odm document.

My configuration looks like this:

config.yml

doctrine_mongodb:
    connections:
        default:
            ...
    document_managers:
        default:
            filters:
                softdeleteable:
                        class: Gedmo\SoftDeleteable\Filter\ODM\SoftDeleteableFilter
                        enabled: true

stof_doctrine_extensions:
    orm:
        default: 
            timestampable: true
            sluggable: true
    mongodb:
        default: 
            timestampable: true
            #Without this I get a "Listener “SoftDeleteableListener” was not added to the EventManager" error (Not in ORM)
            softdeleteable: true

service.yml

    gedmo.listener.softdeleteable:
        class: Gedmo\SoftDeleteable\SoftDeleteableListener
        tags:
            - { name: doctrine.odm.mongodb.default_event_subscriber }
            - { name: doctrine.event_subscriber, connection: default }
        calls:
            - [ setAnnotationReader, [ @annotation_reader ] ]

Document

/**
 * @MongoDB\Document(db="test", collection="pictures")
 * @Gedmo\SoftDeleteable(fieldName="deletedAt", timeAware=false)
 */
class Picture
{
    ...
    /**
     * @MongoDB\Date
     */
    protected $deletedAt;

    ...

    /**
     * Set deletedAt
     *
     * @param date $deletedAt
     * @return self
     */
    public function setDeletedAt($deletedAt)
    {
        $this->deletedAt = $deletedAt;
        return $this;
    }

    /**
     * Get deletedAt
     *
     * @return date $deletedAt
     */
    public function getDeletedAt()
    {
        return $this->deletedAt;
    }
}

If I remove the config for softdeletable fetching and removing is working properly.

But with the softdeleteable feature on I can't fetch any pictures and if I try to remove one I get following error:
No mapping found for field 'deletedAt' in class 'Tes\StoreBundle\Document\Picture'.

Am I doing somethin wrong?

Thanks,
David

@stof
Copy link
Owner

stof commented Mar 5, 2014

why are you trying to register the listener yourself ? It is what the bundle is doing.

Anyway, doctrine.odm.mongodb.default_event_subscriber is the wrong tag name for the ODM, so your own service is not registered as a listener for the ODM

@dgruseck
Copy link
Author

dgruseck commented Mar 7, 2014

Thanks,

is it the correct behavior that deletedAt is set but all select statements returns the deleted document?
Because the DoctrineExtensions list the softdeleatable feature only works for orm.

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

2 participants