OroCRM Forums

Covering OroCRM topics, including community updates and company announcements.

Forums Forums OroCRM OroCRM – Installation/Technical Issues or Problems Doctrine Lifecycle callbacks annotation seems to not work

This topic contains 1 reply, has 2 voices, and was last updated by  Mike Kudelya 7 years, 8 months ago.

Starting from March 1, 2020 the forum has been switched to the read-only mode. Please head to StackOverflow for support.

  • Creator
    Topic
  • #27254

    adriwan_kenoby
    Participant

    Hi,

    I’am trying to use LifeCycleCallbacks for upload file to an entity.
    I’am not sure but it seems that the callbacks methods define in entity with @PrePersist or @PreUpdate are not working.

    I supposed first that it was because my entity no necessary change and then events aren’t triggered but still not work even if I had a field updatedAt (which necessary change).

    I would like to not put all the logic in controller…

    Thanks to oroTeam

Viewing 1 replies (of 1 total)
  • Author
    Replies
  • #27255

    Mike Kudelya
    Participant

    Hi,

    I have copied your @ORM\HasLifecycleCallbacks with function and callback annotations. Callbacks are working. Two things that i want to say:
    – The callback begins to work after you run cache clear “app/console –env=dev cache:clear”
    – I read interesting paragraph:

    The PreUpdate and PostUpdate callbacks are only triggered if there is a change in one of the entity’s field that are persisted. This means that, by default, if you modify only the $file property, these events will not be triggered, as the property itself is not directly persisted via Doctrine. One solution would be to use an updated field that’s persisted to Doctrine, and to modify it manually when changing the file.

Viewing 1 replies (of 1 total)

The forum ‘OroCRM – Installation/Technical Issues or Problems’ is closed to new topics and replies.

Back to top