Yii2. Override module class

1.6k Views Asked by At

Is it possible to override module Module.php class to add some additional configs? I've extended some views and controllers and want to add a few additional configs for them.

enter image description here

1

There are 1 best solutions below

2
ScaisEdge On BEST ANSWER

you could create your own module in a separated vendor dir and extend the module you preferer

the sample in your image is already an ovveride (is an extension od BaseModule in this case) that redefine some function, add new param .. and os you

namespace dektrium\user;

use yii\base\Module as BaseModule;

class Module extends BaseModule
{

so in eg: myvendorname you could define a new Module.php

with

namespace myvendorname\user;

use dektrium\user\Module as MyBaseModule;

class Module extends MyBaseModule
{

  // redefine your params and functions  

  // add your new params and function

You can take a look a this for a brief guide and suggestion

http://www.yiiframework.com/doc-2.0/guide-structure-modules.html

http://www.yiiframework.com/doc-2.0/yii-base-module.html