LPH
Well-known member
The following code has worked for quite some time, but I've moved it to its own class and am now getting the statement:
Expected parameter of type 'void|\XF\Entity\User', '\XF\Mvc\Entity\Entity' provided
The author is pulled using find.
Is that the issue? And is there a better way to pull the author?
Update: Added a comment to the $author in order to remove the message
But is that appropriate?
Expected parameter of type 'void|\XF\Entity\User', '\XF\Mvc\Entity\Entity' provided
PHP:
/**
* @param $post
*
* @return void
*/
public function setAlert($post){
$author = XF::app()->find('XF:User', $post->post_author);
// Get thread ID from WordPress post meta in order to get first post id
$thread_ID = get_post_meta( $post->ID, 'thread_id', true );
$thread = XF::app()->find( 'XF:Thread', $thread_ID );
$alertUsers = XF::app()->finder('XF:User')->fetch();
foreach ( $alertUsers AS $alertUser ) {
/** @var UserAlert $alertRepo */
$alertRepo = XF::app()->repository('XF:UserAlert');
$alertRepo->alertFromUser($alertUser, $author, 'post', $thread['first_post_id'], 'insert');
}
}
The author is pulled using find.
PHP:
$author = XF::app()->find('XF:User', $post->post_author);
Is that the issue? And is there a better way to pull the author?
Update: Added a comment to the $author in order to remove the message
PHP:
/** @var XF\Entity\User $author */
$author = XF::app()->find('XF:User', $post->post_author);
But is that appropriate?
Last edited: