beforeAction() public method

public beforeAction ( $action )
Esempio n. 1
0
 public function beforeAction($action)
 {
     if (parent::beforeAction($action)) {
         $view = $action->controller->getView();
         foreach ($view->params['breadcrumbs'] as $k => $v) {
             if ($v['url'] == ['/' . ($this->defaultUrl ?: $this->uniqueId)]) {
                 unset($view->params['breadcrumbs'][$k]);
             }
         }
         if ($action->controller->id == 'user') {
             $title = "用户管理";
             $url = ['/' . ($this->defaultUrl ?: $this->uniqueId . "/user")];
         } else {
             $title = "权限管理";
             $url = ['/' . ($this->defaultUrl ?: $this->uniqueId)];
         }
         $view->params['breadcrumbs'][] = ['label' => $this->defaultUrlLabel ?: $title, 'url' => $url];
         return true;
     } else {
         return false;
     }
 }