M
M
Monitorkin2016-05-26 11:39:07
Yii
Monitorkin, 2016-05-26 11:39:07

How to add modules to the system on YII2 through the admin panel?

Please share your experience, I'm
interested in the technology by which it would be possible to connect different modules of this system to the system on Yii2 through the admin panel if necessary.
That is, you probably need some kind of script that would write the necessary information to the necessary files by module, or would the system itself somehow miraculously see the module that appeared and start working with it?
Thank you!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Kim, 2016-05-27
@kimono

First develop and prepare all available modules. In the main.php/main-local.php file (or in another place where the modules are supposed to be connected) enter this:

$modules = require('/path/to/modules/file.php');
// и далее
return [
  'modules' => array_merge($modules, [
    'user'  => [
      'class' => common\modules\user\Module::className(),
    ],
  ]),
];

Create a table in the database where all modules will be stored. Through CRUD, create functionality for changing module statuses. Next to the GridView, create a button, by clicking on which a file '/path/to/modules/file.php'with the following content will be generated from all active modules:
return [
            'questions'  => [
                'class' => common\modules\poll\questions\Module::className(),
            ],
            'answers'    => [
                'class' => common\modules\poll\answers\Module::className(),
            ],
            'news'       => [
                'class' => common\modules\news\Module::className(),
            ],
            'tags'       => [
                'class' => common\modules\tags\Module::className(),
            ],
            'categories' => [
                'class' => common\modules\categories\Module::className(),
            ],
            'images'     => [
                'class' => common\modules\images\Module::className(),
            ],
            'uploader'   => [
                'class' => common\modules\uploader\Module::className(),
            ],
            'content'    => [
                'class' => common\modules\content\Module::className(),
            ],
            'employees'  => [
                'class' => common\modules\employees\Module::className(),
            ],
            'comments'   => [
                'class' => common\modules\comments\Module::className(),
            ],
];

Basically, it's like everything. You can’t insure yourself against mistakes here, because one module often works with another in pairs. For example, stand-alone modules - articles, blogs, news, weather - can be connected in this way, but some Comments that are connected to other modules will probably not work without editing the code.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question