yii2-mongodb
yii2-mongodb copied to clipboard
gii model generator
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 |
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 |