Q. What is the primary purpose of an event handler in Yii middleware?