Codxplore.com

Latest news:

Quran ul karim is a free Quran application for android. This application is advertisement free application for android smartphone. Download from https://play.google.com/store/apps/details?id=com.akramhossain.quranulkarim&hl=en

Yii2 - Get Current Action ID in main.php


 Yii2 - Get Current Action ID in main.php

Yii2 web application project, sometimes we need to current controller ID, action ID.

Specially when we need role based access control, we need to check the controller ID as well as action ID.

Using Yii2 view context api we can get these data.

for example if we need controller ID we can use below code

$controller = $this->context->action->controller->id;

if we need action ID only we can use as follows

$method = $this->context->action->id;

To know more about Yii2 view context api, please refer this link https://www.yiiframework.com/doc/api/2.0/yii-base-view#$context-detail

Tags : PHP, Yii2,

Views : 2303

Recent Posts

    loading

Popular Tags

    loading

Subscribe Us


Follow Us