Announcement

Collapse
No announcement yet.

beforeRelate record hook options

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • beforeRelate record hook options

    Hi there,

    I'm currently refactoring my old Espo code in order to match the good standards and get rid of my deprecated code.
    I'm transforming my old "beforeRelate" functions (inside my Repositories) into record hooks (https://docs.espocrm.com/development...kclassnamelist).

    But, I did find there was no
    PHP Code:
    $options 
    parameter inside the
    PHP Code:
    public function process(Entity $entitystring $linkEntity $foreignEntity): void
    function inside the
    PHP Code:
    application/Espo/Core/Record/Hook/LinkHook.php 
    interface.

    How should I proceed in order to give optionnal parameters to my beforeRelate hooks ?

    Regards,
    Firyo.

  • #2
    Hello, It's a different hook. You need this: https://docs.espocrm.com/development/hooks/#interfaces

    But there's no beforeRelate, only after.

    Comment


    • #3
      Hi Yuri,

      In my case I was using the
      PHP Code:
      $options 
      to do a check (and wheter or not) and throw an exception.
      So I guess the afterRelate hook won't be suited for this.

      Regards,
      Firyo.

      Comment


      • #4
        For throwing exceptions the Record BeforeRelate hook usually suits better. The fact that there's no BeforeRelate hook. Maybe worth reconsidering your approach.

        Comment


        • #5
          Originally posted by yuri View Post
          Hello, It's a different hook. You need this: https://docs.espocrm.com/development/hooks/#interfaces

          But there's no beforeRelate, only after.
          Would it be possible to add beforeRelate? Or should I use beforeUpdateHookClassNameList?

          Comment


          • #6
            Hi bandtank,

            I think you could still use beforeLinkHookClassNameList to do the job if you want to check before a link is linked to an entity.

            I have used it in the paste and worked nicely.

            Thanks
            Rabii
            Web Dev

            Comment

            Working...
            X