mirror of
https://gitlab.unicamp.br/infimecc_drupal11_modules/base_site_config.git
synced 2026-03-12 02:38:33 -03:00
Inclui o campo mathSciNetId no ldap_user.settings e update hook 10001 para aplicar o mapeamento em instalações existentes. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
59 lines
1.7 KiB
Plaintext
59 lines
1.7 KiB
Plaintext
<?php
|
|
|
|
/**
|
|
* @file
|
|
* Install, update and uninstall functions for the Base Site Config module.
|
|
*/
|
|
|
|
/**
|
|
* Implements hook_install().
|
|
*
|
|
* Aplica programaticamente as configurações dos módulos LDAP que já existem
|
|
* na configuração ativa após a instalação das dependências, evitando o erro
|
|
* de conflito ao importar via config/install.
|
|
*/
|
|
function base_site_config_install() {
|
|
$module_path = \Drupal::service('extension.list.module')->getPath('base_site_config');
|
|
$source = new \Drupal\Core\Config\FileStorage($module_path . '/config/optional');
|
|
|
|
$configs = [
|
|
'authorization.settings',
|
|
'ldap_servers.settings',
|
|
'ldap_authentication.settings',
|
|
'ldap_user.settings',
|
|
];
|
|
|
|
foreach ($configs as $config_name) {
|
|
$data = $source->read($config_name);
|
|
if ($data !== FALSE) {
|
|
\Drupal::configFactory()->getEditable($config_name)->setData($data)->save();
|
|
}
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Adds field_user_mathscinetid LDAP sync mapping.
|
|
*/
|
|
function base_site_config_update_10001() {
|
|
$config = \Drupal::configFactory()->getEditable('ldap_user.settings');
|
|
$mappings = $config->get('ldapUserSyncMappings');
|
|
|
|
if (!isset($mappings['drupal']['field-field_user_mathscinetid'])) {
|
|
$mappings['drupal']['field-field_user_mathscinetid'] = [
|
|
'ldap_attr' => '[mathSciNetId]',
|
|
'user_attr' => '[field.field_user_mathscinetid]',
|
|
'convert' => FALSE,
|
|
'user_tokens' => '',
|
|
'config_module' => 'ldap_user',
|
|
'prov_module' => 'site_users',
|
|
'prov_events' => [
|
|
'create_drupal_user',
|
|
'sync_to_drupal_user',
|
|
],
|
|
];
|
|
$config->set('ldapUserSyncMappings', $mappings)->save();
|
|
}
|
|
|
|
return t('LDAP sync mapping for field_user_mathscinetid added.');
|
|
}
|