Yii2 - Get all the relations of a model

In Yii 1.x, I used to fetch all the relations of a model using below code

foreach(Images::model()->relations() as $key=>$value){

// Code to do something


How do i replicate this action in Yii 2?

This is interesting. I’m afraid it is not that easy in Yii2 since relation is defined by a getter method now. I could not find a quick solution.

Maybe you need to recreate the relations() method with some kind of an additional param and populate it with new data every time new relation is added?