Forums

Covering OroCRM topics, including community updates and company announcements.  Subscribe

This topic contains 1 reply, has 2 voices, and was last updated by Mike Kudelya Mike Kudelya 1 year, 4 months ago.

  • Creator
    Topic
  • #21515
    adriwan_kenoby
    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
  • #21558
    Mike Kudelya
    Mike Kudelya
    Oro Core

    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)

You must be logged in to reply to this topic.

ssossossosso