Vishal Petkar
Vishal Petkar

Reputation: 379

Customize Yii2 plugin without touching core vendor folder

Hi I am using Yii2 plugin for login and user management: https://github.com/webvimark/user-management

I want to customize view files of this plugin. How can I do this without touching to core file in vendor folder?

Upvotes: 4

Views: 517

Answers (2)

rob006
rob006

Reputation: 22174

You can use theming to override some view files. In your config:

'components' => [
    // ...
    'view' => [
        'theme' => [
            'pathMap' => [
                '@vendor/webvimark/module-user-management/views' => '@app/views/user-management',
            ],
        ],
    ],
],

Then put your views into @app/views/user-management directory.


But if extension is not maintained anymore you may consider forking extension, do changes in fork and use it as a dependency.

Upvotes: 1

ِAmin
ِAmin

Reputation: 184

Extent the component/module and the class in your project

Create User Config Class extends from the UserConfig.

class YourClass-UserConfig extends webvimark\modules\UserManagement\components\UserConfig
{
/* Custom As you want  */
}

and UserManagementModule

class YourClass-UserManagementModule extends webvimark\modules\UserManagement\UserManagementModule
{ 
/* Custom As you want */
}

and in config add your component

components'=>[
    'user' => [
        'class' => 'YourPackage\YourClass-UserConfig',
    ],
],

'modules'=>[
    'user-management' => [
        'class' => 'YourPackage\YourClass-UserManagementModule',

In your class custom as you want.

Upvotes: 0

Related Questions