lexik / LexikWorkflowBundle

Simple workflow bundle for Symfony2
MIT License
126 stars 29 forks source link

Model state expiration? #9

Closed archie18 closed 10 years ago

archie18 commented 10 years ago

Is it possible to define an expiration date for a certain object state? To keep with the example of the documentation, let's assume I wish to delete all Post objects whose model state have been Post::STATUS_DRAFT for more than 30 days.

I could easily do this manually by calling a Symfony2 console command from a daily cronjob. But how would I properly do this within the workflow framework?

cedric-g commented 10 years ago

Hi :) sorry for the late reply, so in the current version of the bundle there is no way to define any date until the model object is valid. So I think the easiest way to do it is to use a Symfony command as you did.

archie18 commented 10 years ago

Hi and thank you for replying. I came up with the idea to define a state Post::STATUS_EXPIRED and to register a validator that performs a date comparison and creates a violation if the expiration date is not yet reached. In theory this should work. But I noticed that for each validation violation an entry is created in the lexik_workflow_model_state table. These entries could easily produce a lot of unnecessary data. Is there any way to prevent logging of failed violations?

cedric-g commented 10 years ago

No, we log all violations, but it could be an idea to improve the bundle.

archie18 commented 10 years ago

Will close this for now.