ensure() public static method
Resolves the specified reference into the actual object and makes sure it is of the specified type. The reference may be specified as a string or an Instance object. If the former, it will be treated as a component ID, a class/interface name or an alias, depending on the container type. If you do not specify a container, the method will first try Yii::$app followed by Yii::$container. For example, use yii\db\Connection;
// returns Yii::$app->db
$db = Instan