Check if two ActiveRecords are related

Hello, forum!

I have made a module that takes the user model class as a parameter, along the lines of "userModel" => "app\models\User.php". I then need to check if a certain model is related to the user model.

Is there any way to check if two models are related without knowing their relation name?

Also, is there a way to get all of an ActiveRecord’s relation names ?

I have implemented my own simple method that’s similar to getAttributeLabels, but maybe I’m missing something.

I have searched through the documentation and there seems to be no method for either of those.

Thank you.