johnny1991
参照yii\grid\GridView的这两个方法
public function renderTableBody() { $models = array_values($this->dataProvider->getModels()); $keys = $this->dataProvider->getKeys(); $rows = []; foreach ($models as $index => $model) { $key = $keys[$index]; if ($this->beforeRow !== null) { $row = call_user_func($this->beforeRow, $model, $key, $index, $this); if (!empty($row)) { $rows[] = $row; } } $rows[] = $this->renderTableRow($model, $key, $index); if ($this->afterRow !== null) { $row = call_user_func($this->afterRow, $model, $key, $index, $this); if (!empty($row)) { $rows[] = $row; } } } if (empty($rows)) { $colspan = count($this->columns); return "<tbody>\n<tr><td colspan=\"$colspan\">" . $this->renderEmpty() . "</td></tr>\n</tbody>"; } else { return "<tbody>\n" . implode("\n", $rows) . "\n</tbody>"; } } public function renderTableRow($model, $key, $index) { $cells = []; /* @var $column Column */ foreach ($this->columns as $column) { $cells[] = $column->renderDataCell($model, $key, $index); } if ($this->rowOptions instanceof Closure) { $options = call_user_func($this->rowOptions, $model, $key, $index, $this); } else { $options = $this->rowOptions; } $options['data-key'] = is_array($key) ? json_encode($key) : (string) $key; return Html::tag('tr', implode('', $cells), $options); }
吧你这个类common\models\register\LoginUser里面定义的$username,这个属性去掉,自定义的属性和数据库里面的字段重复了
- johnny1991 发布了源码最简单rbac实现方法
- johnny1991 2017-04-17 已签到连续签到3天,获得了15个金钱
- johnny1991 回复了话题 rbac最简单实现方案
修正一下第二步
'authManager' => [
'class' => 'yii\rbac\DbManager',
], - johnny1991 2017-04-16 已签到连续签到2天,获得了10个金钱
- johnny1991 2017-04-15 已签到连续签到1天,获得了5个金钱
- johnny1991 回复了 johnny1991 的回答
第一:你要确保,backend下的cache,和frontend下的cache是访问同一个cache
第二:你要确保当你夸模块读取的时候的,这个数据已经存在你的cache里面了
第三,你这个叫做跨app@akun 不客气,原来你用的是文件缓存,推荐使用dbCache,或是redis,或是memcached
- johnny1991 回答了问题 缓存 如何实现跨模块读取缓存?
第一:你要确保,backend下的cache,和frontend下的cache是访问同一个cache
第二:你要确保当你夸模块读取的时候的,这个数据已经存在你的cache里面了
第三,你这个叫做跨app - johnny1991 回复了 johnny1991 的回答
两个步骤:
1。将文件夹完整拷贝到common下面
2。这一步比较关键,涉及到了yii2的类自动加载的机制,需要符合下面的规范
每个类都必须置于命名空间之下 (比如 foo\bar\MyClass)。
每个类都必须保存为单独文件,且其完整路径能用以下算法取得:
// $className 是一个开头包含反斜杠的完整类名(译注:请自行谷歌:fully qualified class name)
$classFile = Yii::getAlias('@' . str_replace('\', '/', $className) . '.php');@johnny1991 这样的写法才是符合yii自动加载的规则的