分类service子服务缺少必填参数

bug问题 · chenchaojie · 于 6年前 发布 · 2903 次阅读

vendor/fancyecommerce/fecshop/services/category/Image.php:72

	/**
     * 通过产品图片的相对路径得到产品图片的绝对路径.
     */
    protected function actionGetDir() //缺少str
    {
        return Yii::$service->image->GetImgDir($this->imageFloder.$str, 'common');
    }
	
共收到 4 条回复 技术分享
Fecmall#16年前 0 个赞

这个参数有的,需要设置,你可以参看一下图片帮助文档:http://www.fecshop.com/doc/fecshop-guide/instructions/cn-1.0/guide-fecshop_product_image.html

chenchaojie#26年前 0 个赞

Yii::$service->category->image->getDir($str)会报错,你可以试试

Fecmall#36年前 0 个赞

@chenchaojie [[[#2楼](#comment2)](#comment2)](#comment2)

https://github.com/fecshop/yii2_fecshop/blob/master/services/category/Image.php

protected function actionGetDir()
{
return Yii::$service->image->GetImgDir($this->imageFloder.$str, 'common');
}

需要改成

    protected function actionGetDir()
    {
        return Yii::$service->image->GetImgDir($this->imageFloder, 'common');
    }

这个不可以传递$str,如果想要更改,可以在配置中更改参数 imageFloder 的方式,来自定义分类图片路径。

类中的public 变量,都可以在配置中设置,设置后,在service初始化的时候会注入到service 对象中

稍等,我在细看一下代码

请给予一下,这个函数调用的上下文,在哪里调用?

Fecmall#46年前 0 个赞

需要改成

/**
     * 通过分类图片的相对路径得到分类图片的绝对路径.
     */
    protected function actionGetDir($str)
    {
        return Yii::$service->image->GetImgDir($this->imageFloder.$str, 'common');
    }

这个分类service的图片方法,应该是写了,没有被调用过,因此功能也没有报错,问题没有显露出来,需要在函数中加入$str 参数

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