yiisoft / yii2-mongodb

Yii 2 MongoDB extension
http://www.yiiframework.com
BSD 3-Clause "New" or "Revised" License
325 stars 191 forks source link

gii model generator #261

Open finnan444 opened 6 years ago

finnan444 commented 6 years ago

What steps will reproduce the problem?

try to generate model via console, for example: php yii gii/mongoDbModel --db="hobTestMongo" --collectionName="updates" --modelClass="DlcUpdates" --color=1 --ns="app\modules\appAdmin\models\mongo" --attributeList="data,minVersion,maxVersion,platform"

What's expected?

As I i explicitly specified modelClass as DLCUpdates, it ignores it

What do you get instead?

The following files will be generated: modules/appAdmin/models/mongo/Updates.php

Additional info

I suppose the reason is core code: $className = $this->generateClassName($collectionName); plus i didn't find usages of this method: public function validateModelClass()

Q A
Yii version 2.0.15.1
Yii MongoDB version 2.1.7
MongoDB server version 3.2.12
PHP version 7.2
Operating system Ubuntu
h0rseduck commented 5 years ago

de7468ec65

Solution: yii\mongodb\gii\model\Generator:158 $className = $this->generateClassName($collectionName); replace $className = $this->modelClass ?: $this->generateClassName($collectionName);

Q A
Yii version 2.0.15.1
Yii MongoDB version 2.1.7
MongoDB server version 3.6
PHP version 7.1
Operating system Windows