重写fecshop\models\mysqldb\Customer无效

bug问题 · alibo1016 · 于 5年前 发布 · 1532 次阅读

@appserver/config/YiiRewriteMap.php

<?php

return [
    /**
     * \fecshop\models\mongodb\Category 为原来的类
     * \appfront\local\local_models\mongodb\Category 为重写后的类
     * 重写后的类可以集成原来的类。
     */
    //'\fecshop\models\mongodb\Category'  => '\appfront\local\local_models\mongodb\Category',
    '\fecshop\models\mysqldb\customer\CustomerLogin' => '\appserver\local\local_models\mysqldb\customer\CustomerLogin',//这个重写有效
	'\fecshop\models\mongodb\Category' => '\appserver\local\local_models\mongodb\Category',//重写有效
    '\fecshop\models\mysqldb\Customer' => '\appserver\local\local_models\mysqldb\Customer'//重写无效
];

@appserver/local/local_models/mysqldb/Customer.php

<?php
namespace appserver\local\local_models\mysqldb;
use Yii;
class Customer extends \fecshop\models\mysqldb\Customer
{
    /**
     * 生成access_token
     */
    public function generateAccessToken()
    {
        echo 'here';die;
        $this->access_token = Yii::$app->security->generateRandomString();
    }
}
共收到 2 条回复 问题提问
alibo1016#25年前 1 个赞

谢谢,已经找到问题,整个请求周期里少重写了一个方法,旧的方法用的use fecshop\models\mysqldb\Customer 这个命名空间,所以还是跑到旧的Customer里去了。

添加回复 (需要登录)
需要 登录 后方可回复, 如果你还没有账号请点击这里 注册
Your Site Analytics