Access controller inside layout file

Hi, how can I access the current controller information inside the layout file?

In Yii 1, $this was the current controller, example:


$this->id

But in Yii 2 $this is \yii\web\View …

How can I access to the current controller so I can check conditions regarding the current controller ID?

Thank you

Answer:


$this->context

Gets the current controller in the layout file, and also in any view file.