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

Added multi app (frontend/backend) support. #309

Merged
merged 5 commits into from
Oct 4, 2017

Conversation

firefox747
Copy link
Contributor

Since i would like this extension to work with Yii2s advanced template, i made some modifications.
Basically, if you do not configure anything, this PR still works as the original with support for the basic application template.
You can however configure multiple apps according to your individual (or default advanced) template. For this feature to work i use the Configs->advanced property.
For example, the following array in @common/config/params.php configures this extension to work with the Yii2 advanced template.

'mdm.admin.configs' => [
        'advanced' => [
            'app-backend' => [
                '@common/config/main.php',
                '@common/config/main-local.php',
                '@backend/config/main.php',
                '@backend/config/main-local.php',
            ],
            'app-frontend' => [
                '@common/config/main.php',
                '@common/config/main-local.php',
                '@frontend/config/main.php',
                '@frontend/config/main-local.php',
            ],
        ],
    ],

advanced needs to be an array. Each item consists of
key: (string) application id as defined in @{app}/config/main.php (app-backend and app-frontend in this configuration) and
value: (array) of configuration files used by the respective application. I use the Yii::getAlias() method, so using aliases works fine.

Now you can set up the module part of this extension only in the backend of your application. There you can access all application wide routes. So you are able, for example, to grant User1 access to the a specific action or controller in the frontend (@app-frontend/demo/some-action), while giving User2 access to the same action or controller in the backend (@app-backend/demo/some-action).
The advanced routes contain the application id as prefix, e.g. @app-backend/admin/* or @app-frontend/*

@firefox747 firefox747 changed the title - Added multi app (frontend/backend) support. Added multi app (frontend/backend) support. Nov 23, 2016
@mdmunir
Copy link
Contributor

mdmunir commented Nov 23, 2016

look good to me. Need to be verified

…apps (frontend/backend).

I did not notice, that $module->getUniqueId() returns an empty string when $module is the app itself. Therefore the cache could not differenciate between frontend and backend. Thus resulting in the same routes for all indicated apps.
…l = # and is used as a container for sub-items. If all the subitems are forbidden then this patch removes the parent entry as well.
@yongtiger
Copy link

yongtiger commented Feb 16, 2017

Bug report: Yii debug disappear in index.php?r=admin/route

my temp solution is add unset($config['bootstrap']); before $app = new yii\web\Application($config); in \vendor\mdmsoft\yii2-admin\models\Route.php

In other pages, simply add debug/* in config allowActions. @see Yii debug disappear
is that alright? i'm not sure.

@soap
Copy link
Contributor

soap commented Jul 14, 2017

What is the status of this pull request? I have tried this modified code with my development. It works fine except that when list routes from backend it display frontend layout?

I am trying to find what is the cause of problem and will contribute back. Any recommendations?

Thanks all developers here for great extension it made RBAC implementations a lot easier.

@soap
Copy link
Contributor

soap commented Jul 27, 2017

Ok, It works now. I change module layout config from @app/views/layouts/main.php to @backend/views/layouts/main.php.

@mdmunir mdmunir merged commit 48298cb into mdmsoft:master Oct 4, 2017
@re3lex
Copy link
Contributor

re3lex commented Oct 19, 2018

Change provided by @firefox747 is very usefull but looks like it introduced issue on Permissions UI: now all available routes are shown on Permissions list.
This is happening because filtration logic in AuthItem::search() method is filtering out routes those starts by slash symbol.
But when advanced config is enabled all routes auto generated are starting with @ symbol so filtration doesn't remove them from list of permissions.

UPD: did fix in pull request #410
Please check

@alekln
Copy link

alekln commented May 6, 2022

Problem with menu printing
1st unable to append menu item because routes @App-Backend... are not autocompleted on menu update/create this is fixed under Menu,php getSavedRoutes() with if (in_array($name[0], ['/', '@']) && substr($name, -1) != '*') {
but still then added some permissions and updated menu urls according to new representation like app-backend, menu is not rendered.

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

Successfully merging this pull request may close these issues.

6 participants