I have a CakePHP 3.4 application, which has been developed a couple of years ago and has a few thousands users.
I am currently working on a new version of this application, and my client wants it to be visible only by a few selected users before we release it for everyone else.
Unsure about what is the right way to do so I have chosen to develop a new theme plugin, which overrides a few controllers, layouts, assets, routes etc.
Everything is working correctly, but now I need to specify which users should see the newer version. To accomplish this I've added a theme
field in my users table, and in my AppController's beforeRender method I have added this:
$theme = $this->request->session()->read("Auth.User.theme");
if ($theme !== null) {
$this->viewBuilder()->theme('Theme2');
}
To use the newer version I also need to load the new theme in my bootstrap.php
:
Plugin::load('Theme2', ['bootstrap' => false, 'routes' => true, 'autoload' => true]);
So, if both the theme and the plugin are set, the user will see the newer version.
If neither the theme or the plugin are set, the user will see the old version.
My question is: how can I load the theme plugin only for selected users?