0
我有控制器:RolePermissionController.php我想從這個控制器獲取所有的動作,這裏是我的控制器。我怎麼能得到這個?任何幫助將非常感激。如何從yii中的控制器獲取所有動作?
<?php
class RolepermissionController extends GxController {
public function actionView($id) {
$this->render('view', array(
'model' => $this->loadModel($id, 'Rolepermission'),
));
}
public function actionCreate() {
$model = new Rolepermission;
if (isset($_POST['Rolepermission'])) {
$model->setAttributes($_POST['Rolepermission']);
if ($model->save()) {
if (Yii::app()->getRequest()->getIsAjaxRequest())
Yii::app()->end();
else
$this->redirect(array('view', 'id' => $model->RoleID));
}
}
$appControllerPath = Yii::getPathOfAlias('application.controllers');
if(is_dir($appControllerPath))
$fileLists = CFileHelper::findFiles($appControllerPath);
foreach($fileLists as $controllerPath)
{
$controllerName = substr($controllerPath, strrpos($controllerPath, DIRECTORY_SEPARATOR)+1,-4);
}
$this->render('create', array('model' => $model));
}
public function actionUpdate($id) {
$model = $this->loadModel($id, 'Rolepermission');
if (isset($_POST['Rolepermission'])) {
$model->setAttributes($_POST['Rolepermission']);
if ($model->save()) {
$this->redirect(array('view', 'id' => $model->RoleID));
}
}
$this->render('update', array(
'model' => $model,
));
}
public function actionDelete($id) {
if (Yii::app()->getRequest()->getIsPostRequest()) {
$this->loadModel($id, 'Rolepermission')->delete();
if (!Yii::app()->getRequest()->getIsAjaxRequest())
$this->redirect(array('admin'));
} else
throw new CHttpException(400, Yii::t('app', 'Your request is invalid.'));
}
public function actionIndex() {
$dataProvider = new CActiveDataProvider('Rolepermission');
$this->render('index', array(
'dataProvider' => $dataProvider,
));
}
public function actionAdmin() {
$model = new Rolepermission('search');
$model->unsetAttributes();
if (isset($_GET['Rolepermission']))
$model->setAttributes($_GET['Rolepermission']);
$this->render('admin', array(
'model' => $model,
));
}
}
是這個鏈接有用嗎? – 2015-03-31 05:46:20
是的,非常感謝,你救了我的一天。 – Nikul 2015-03-31 05:56:08