()
| 31 | const defaultLowercaseRecordIdPattern = "^[a-z0-9]+$" |
| 32 | |
| 33 | func (app *BaseApp) registerCollectionHooks() { |
| 34 | app.OnModelValidate().Bind(&hook.Handler[*ModelEvent]{ |
| 35 | Id: systemHookIdCollection, |
| 36 | Func: func(me *ModelEvent) error { |
| 37 | if ce, ok := newCollectionEventFromModelEvent(me); ok { |
| 38 | err := me.App.OnCollectionValidate().Trigger(ce, func(ce *CollectionEvent) error { |
| 39 | syncModelEventWithCollectionEvent(me, ce) |
| 40 | defer syncCollectionEventWithModelEvent(ce, me) |
| 41 | return me.Next() |
| 42 | }) |
| 43 | syncModelEventWithCollectionEvent(me, ce) |
| 44 | return err |
| 45 | } |
| 46 | |
| 47 | return me.Next() |
| 48 | }, |
| 49 | Priority: -99, |
| 50 | }) |
| 51 | |
| 52 | app.OnModelCreate().Bind(&hook.Handler[*ModelEvent]{ |
| 53 | Id: systemHookIdCollection, |
| 54 | Func: func(me *ModelEvent) error { |
| 55 | if ce, ok := newCollectionEventFromModelEvent(me); ok { |
| 56 | err := me.App.OnCollectionCreate().Trigger(ce, func(ce *CollectionEvent) error { |
| 57 | syncModelEventWithCollectionEvent(me, ce) |
| 58 | defer syncCollectionEventWithModelEvent(ce, me) |
| 59 | return me.Next() |
| 60 | }) |
| 61 | syncModelEventWithCollectionEvent(me, ce) |
| 62 | return err |
| 63 | } |
| 64 | |
| 65 | return me.Next() |
| 66 | }, |
| 67 | Priority: -99, |
| 68 | }) |
| 69 | |
| 70 | app.OnModelCreateExecute().Bind(&hook.Handler[*ModelEvent]{ |
| 71 | Id: systemHookIdCollection, |
| 72 | Func: func(me *ModelEvent) error { |
| 73 | if ce, ok := newCollectionEventFromModelEvent(me); ok { |
| 74 | err := me.App.OnCollectionCreateExecute().Trigger(ce, func(ce *CollectionEvent) error { |
| 75 | syncModelEventWithCollectionEvent(me, ce) |
| 76 | defer syncCollectionEventWithModelEvent(ce, me) |
| 77 | return me.Next() |
| 78 | }) |
| 79 | syncModelEventWithCollectionEvent(me, ce) |
| 80 | return err |
| 81 | } |
| 82 | |
| 83 | return me.Next() |
| 84 | }, |
| 85 | Priority: -99, |
| 86 | }) |
| 87 | |
| 88 | app.OnModelAfterCreateSuccess().Bind(&hook.Handler[*ModelEvent]{ |
| 89 | Id: systemHookIdCollection, |
| 90 | Func: func(me *ModelEvent) error { |
no test coverage detected