sjaakp / yii2-illustrated-behavior

Adds image to ActiveRecord
http://www.sjaakpriester.nl/software/illustrated
MIT License
43 stars 17 forks source link

How to override randomName function #24

Open moh-mousa opened 6 years ago

moh-mousa commented 6 years ago

Could you please help me with overriding protected randomName function I'm unable to override it.

alex210 commented 6 years ago
[
                "class" => Illustrated::className(),
                "attributes" => [
                    "img" => [
                        'class' => backend\components\behaviors\illustrated\Illustration::className(),
                        'aspectRatio' => 1.7777778,
                        'cropSize' => 900,
                        'sizeSteps' => 2,
                    ],
                ],
                'directory' => '@frontend/web/uploads/recipe/',
                'baseUrl' => '@uploads/recipe',
            ],
moh-mousa commented 6 years ago

No I mean this function https://github.com/sjaakp/yii2-illustrated-behavior/blob/262c271bdb4fcb0ee9715f16e6b08fcd51351f54/Illustration.php#L315

alex210 commented 6 years ago
  1. Need to create behavior, which will extends class yii2-illustrated-behavior/Illustration.php. There override randomName function. For example your behavior may be in backend\components\behaviors\illustrated\Illustration.php
  2. To include your behavior in model: [
             "class" => Illustrated::className(),
                "attributes" => [
                    "img" => [
                        'class' => backend\components\behaviors\illustrated\Illustration::className(), // this
                        'aspectRatio' => 1.7777778,
                        'cropSize' => 900,
                        'sizeSteps' => 2,
                    ],
                ],
                'directory' => '@frontend/web/uploads/recipe/',
                'baseUrl' => '@uploads/recipe',
            ],