johnny1991

johnny1991

xxxxxxxxxxxxxxxxxxxxx

  • 财富值3285
  • 威望值580
  • 总积分9895

个人信息

  • 参照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,这个属性去掉,自定义的属性和数据库里面的字段重复了

  • 发布了源码
    最简单rbac实现方法
  • 2017-04-17 已签到
    连续签到3天,获得了15个金钱
  • 修正一下第二步
    'authManager' => [
    'class' => 'yii\rbac\DbManager',
    ],

  • 2017-04-16 已签到
    连续签到2天,获得了10个金钱
  • 2017-04-15 已签到
    连续签到1天,获得了5个金钱
  • 回复了 的回答

    第一:你要确保,backend下的cache,和frontend下的cache是访问同一个cache
    第二:你要确保当你夸模块读取的时候的,这个数据已经存在你的cache里面了
    第三,你这个叫做跨app

    不客气,原来你用的是文件缓存,推荐使用dbCache,或是redis,或是memcached

  • 第一:你要确保,backend下的cache,和frontend下的cache是访问同一个cache
    第二:你要确保当你夸模块读取的时候的,这个数据已经存在你的cache里面了
    第三,你这个叫做跨app

  • 回复了 的回答

    两个步骤:
    1。将文件夹完整拷贝到common下面
    2。这一步比较关键,涉及到了yii2的类自动加载的机制,需要符合下面的规范
    每个类都必须置于命名空间之下 (比如 foo\bar\MyClass)。
    每个类都必须保存为单独文件,且其完整路径能用以下算法取得:
    // $className 是一个开头包含反斜杠的完整类名(译注:请自行谷歌:fully qualified class name)
    $classFile = Yii::getAlias('@' . str_replace('\', '/', $className) . '.php');

    这样的写法才是符合yii自动加载的规则的

副总裁 等级规则
9895/10000
资料完整度
60/100
用户活跃度
0/100

Ta的关注

19

Ta的粉丝

26

Ta的访客

81