当前位置: 首页>>代码示例>>PHP>>正文


PHP Action::exportKey方法代码示例

本文整理汇总了PHP中yii\base\Action::exportKey方法的典型用法代码示例。如果您正苦于以下问题:PHP Action::exportKey方法的具体用法?PHP Action::exportKey怎么用?PHP Action::exportKey使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在yii\base\Action的用法示例。


在下文中一共展示了Action::exportKey方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getMenuCurrent

 /**
  * @param \yii\base\Action $action
  * @param ActiveRecord $model
  * @param bool $horizontal
  * @param array $privs
  * @param array $defaultActions
  * @param array $confirms
  * @return array
  */
 public function getMenuCurrent(\yii\base\Action $action, $model, $horizontal, $privs, $defaultActions, $confirms)
 {
     $menu = [];
     $id = null;
     if (!$model->isNewRecord) {
         $id = $action instanceof Action ? $action->exportKey($model->getPrimaryKey(true)) : implode(';', $model->getPrimaryKey(true));
     }
     if ($privs['read'] && $defaultActions['history'] && (!$model->isNewRecord || $action->id === 'update') && $model->getBehavior('trackable') !== null) {
         $menu['history'] = ['label' => Yii::t('app', 'History of changes'), 'icon' => 'list-alt', 'url' => array_merge(['history', 'id' => $id], $this->getUrlParams('history', $id))];
     }
     if (!$horizontal && $model->isNewRecord) {
         return $menu;
     }
     if ($privs['update'] && ($horizontal || $action->id !== 'update')) {
         $menu['update'] = ['label' => Yii::t('app', 'Update'), 'icon' => 'pencil', 'url' => array_merge(['update', 'id' => $id], $this->getUrlParams('update', $id)), 'active' => $action->id === 'update' && !$model->isNewRecord];
     }
     if ($privs['read'] && $defaultActions['view'] && ($horizontal || $action->id !== 'view')) {
         $menu['view'] = ['label' => Yii::t('app', 'View'), 'icon' => 'eye-open', 'url' => array_merge(['view', 'id' => $id], $this->getUrlParams('view', $id)), 'linkOptions' => $action->id === 'view' ? [] : ['data-confirm' => $confirms['leave']], 'active' => $action->id === 'view'];
     }
     if ($privs['read'] && $defaultActions['print'] && ($horizontal || $action->id !== 'print')) {
         $menu['print'] = ['label' => Yii::t('app', 'Print'), 'icon' => 'print', 'url' => array_merge(['print', 'id' => $id, '_format' => 'pdf'], $this->getUrlParams('print', $id)), 'linkOptions' => $action->id === 'print' ? [] : ['data-confirm' => $confirms['leave']], 'active' => $action->id === 'print'];
     }
     if ($privs['delete']) {
         $menu['delete'] = ['label' => Yii::t('app', 'Delete'), 'icon' => 'trash', 'url' => array_merge(['delete', 'id' => $id], $this->getUrlParams('delete', $id)), 'linkOptions' => ['data-confirm' => $confirms['delete'], 'data-method' => 'post']];
     }
     if ($privs['toggle']) {
         $enabled = !$model->isNewRecord && $model->getIsEnabled();
         $menu['toggle'] = ['label' => $enabled ? Yii::t('app', 'Disable') : Yii::t('app', 'Enable'), 'icon' => $enabled ? 'ban' : 'reply', 'url' => array_merge(['toggle', 'id' => $id], $this->getUrlParams('toggle', $id)), 'linkOptions' => $enabled ? ['data-confirm' => $confirms['disable']] : []];
     }
     if (!$model->isNewRecord && class_exists('netis\\fsm\\components\\StateAction') && $model instanceof \netis\fsm\components\IStateful && $privs['state']) {
         $controllerActions = $this->owner->actions();
         $action = null;
         if (isset($controllerActions['state'])) {
             $action = Yii::createObject($controllerActions['state'], ['state', $this->owner]);
         }
         if ($action === null || !$action instanceof StateActionInterface) {
             $action = Yii::createObject(\netis\fsm\components\StateAction::className(), ['state', $this->owner]);
         }
         $transitions = $model->getTransitionsGroupedByTarget();
         $stateAttribute = $model->getStateAttributeName();
         $stateMenu = $action->getContextMenuItem('state', $transitions, $model, $model->{$stateAttribute}, [$this->owner, 'hasAccess'], $this->useDropDownMenuForTransitions);
         //if label is set then it's drop down menu
         //todo set active item for buttons
         if (isset($stateMenu['label']) && $action->id === 'state') {
             $stateMenu['active'] = true;
         }
         $menu = array_merge($menu, $stateMenu);
     }
     foreach ($menu as $key => $item) {
         if ($model->isNewRecord) {
             $menu[$key]['disabled'] = true;
         }
     }
     return $menu;
 }
开发者ID:netis-pl,项目名称:yii2-crud,代码行数:64,代码来源:ActiveNavigation.php


注:本文中的yii\base\Action::exportKey方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。