Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generated base model class overwrites parent behaviors #201

Open
leovujanic opened this issue May 18, 2017 · 1 comment
Open

Generated base model class overwrites parent behaviors #201

leovujanic opened this issue May 18, 2017 · 1 comment

Comments

@leovujanic
Copy link

Behaviors method in the generated base model class doesn't call parent method, and there is an option to use different Base Class than e.g. yii\db\ActiveRecord. So, if you extend a class that has some of the behaviors already defined they will be overwritten. I believe that behaviors defined in generated base class should be merged with those defined in the parent class.

@leovujanic
Copy link
Author

I would like to have the option to include parent rules and parent behaviours if choose so in generator.

Current state is

public function behaviors()
    {
        return [
            [
                'class' => TimestampBehavior::className(),
            ],
        ];
    }

What I would like to have is

public function behaviors()
    {
        return ArrayHelper::merge(
            parent::behaviors(),
            [
                [
                    'class' => TimestampBehavior::className(),
                ],
        ]);
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants