예제 #1
0
 /**
  * @param \yii\base\Action $action
  * @param ActiveRecord $model
  * @return array
  */
 public function getBreadcrumbs(\yii\base\Action $action, $model)
 {
     $breadcrumbs = [];
     $id = null;
     if ($model !== null && !$model->isNewRecord) {
         $id = $action instanceof Action ? $action->exportKey($model->getPrimaryKey(true)) : implode(';', $model->getPrimaryKey(true));
     }
     if ($action->id == 'index') {
         $breadcrumbs[] = $model->getCrudLabel('index');
     }
     if ($action->id == 'update') {
         $breadcrumbs[] = ['label' => $model->getCrudLabel('index'), 'url' => $this->getIndexRoute($action)];
         if (!$model->isNewRecord) {
             $breadcrumbs[] = ['label' => $model->__toString(), 'url' => ['view', 'id' => $id]];
             $breadcrumbs[] = Yii::t('app', 'Update');
         } else {
             $breadcrumbs[] = $model->getCrudLabel('create');
         }
     }
     if ($action->id == 'view' || $action->id == 'print') {
         $breadcrumbs[] = ['label' => $model->getCrudLabel('index'), 'url' => $this->getIndexRoute($action)];
         $breadcrumbs[] = $model->__toString();
     }
     return $breadcrumbs;
 }