Search code examples
symfonyxenforo

Xenforo - Argument 1 passed to XF\Repository\UserAlert::alertFromUser() must be an instance of XF\Entity\User


While trying to send alert to a user getting this error.

Argument 1 passed to XF\Repository\UserAlert::alertFromUser() must be an instance of XF\Entity\User

$user comes from self made entity result.

$alertRepo = \XF::app()->repository('XF:UserAlert');
   $alertRepo->alert($user,
   $visitor['user_id'],$visitor['username'],
   'thread',$torrent->Thread->thread_id,
   "reseed",$extra);

any help on this will be great.


Solution

  • Solved i just had to give proper parameters

    passing $user->User solved my issue

    $alertRepo = \XF::app()->repository('XF:UserAlert');
       $alertRepo->alert($user->User,
       $visitor['user_id'],$visitor['username'],
       'thread',$torrent->Thread->thread_id,
       "reseed",$extra);