Yes, it work . Thank you.
Is it possible to block the loading of fields_import.yaml for users without the role of developer, so that there is no point 3 in the form of import, which will be empty
it turned out to be more convenient to specify the configuration in the controller
public $importExportConfig = 'config_import_export_selected_only.yaml';
public function __construct()
{
if (BackendAuth::userHasAccess('konvertagency.landing.access_import_export')) {
$this->importExportConfig = 'config_import_export_all.yaml';
}
parent::__construct();
BackendMenu::setContext('KonvertAgency.Landing', 'main-menu-item', 'pages');
}
ah ok, you have a different configurations depending of the role (which you manage by a permission) but you still want them to be able to access the controller - where I thought you didnāt want them to get access at all !
Now, to add to your solution, if the controller is in another plugin but you still want to manage the configuration files (yaml) based on a role or permission, you can do this in your Plugin.php :
public function boot() {
\App::before(function() {
$this->extendControllerABC();
}
}
public function extendControllerABC() {
\AuthorA\PluginA\Controllers\ABC::extend(function($controller) {
if (!$controller instanceof \AuthorA\PluginA\Controllers\ABC) {
return;
}
$user = \BackendAuth::getUser();
$roleCode = ($user && $user->role) ? $user->role->code : null;
$controller->formConfig = '$/authorB/pluginB/controllers/abc/config_form.yaml';
$controller->listConfig = '$/authorB/pluginB/controllers/abc/config_list.yaml';
$controller->importExportConfig = '$/authorB/pluginB/controllers/abc/config_import_export.yaml';
if ($roleCode && $roleCode == 'admin') /* or (BackendAuth::userHasAccess('konvertagency.landing.access_import_export')) */ {
$controller->formConfig = '$/authorB/pluginB/controllers/abc/config_form_admin.yaml';
$controller->listConfig = '$/authorB/pluginB/controllers/abc/config_list_admin.yaml';
$controller->importExportConfig = '$/authorB/pluginB/controllers/abc/config_import_export_admin.yaml';
}
}
}
No, I want all users to access the controller, but with different options. This is an import/export of records of a model that has a NestedTree, so the content manager can import records, but without the id, parent_id, nest_left, nest_right, nest_depth fields, and the developer can import records without restrictions and this will require an auto-increment reset. But I āwrote your solution in a notebookā and someday I will use it.