47 lines
1.9 KiB
PHP
47 lines
1.9 KiB
PHP
<?php
|
|
|
|
namespace App\Signature;
|
|
|
|
/**
|
|
* Variables disponibles dans les templates et correspondance avec les attributs Entra.
|
|
* La clé est celle utilisée dans le template ({{telephone}}) et dans les surcharges agent.
|
|
*/
|
|
final class VariableMap
|
|
{
|
|
public const FIELDS = [
|
|
'prenom' => ['column' => 'given_name', 'label' => 'Prénom'],
|
|
'nom' => ['column' => 'surname', 'label' => 'Nom'],
|
|
'nom_complet' => ['column' => 'display_name', 'label' => 'Nom complet'],
|
|
'fonction' => ['column' => 'job_title', 'label' => 'Fonction'],
|
|
'service' => ['column' => 'department', 'label' => 'Service'],
|
|
'organisation' => ['column' => 'company_name', 'label' => 'Organisation'],
|
|
'bureau' => ['column' => 'office_location', 'label' => 'Bureau / site'],
|
|
'telephone' => ['column' => 'business_phone', 'label' => 'Téléphone fixe'],
|
|
'mobile' => ['column' => 'mobile_phone', 'label' => 'Téléphone mobile'],
|
|
'email' => ['column' => 'mail', 'label' => 'Adresse e-mail'],
|
|
'adresse' => ['column' => 'street_address', 'label' => 'Adresse'],
|
|
'code_postal' => ['column' => 'postal_code', 'label' => 'Code postal'],
|
|
'ville' => ['column' => 'city', 'label' => 'Ville'],
|
|
];
|
|
|
|
/**
|
|
* @param array<string, mixed> $user attributs de directory_users
|
|
* @param array<string, string|null> $overrides surcharges agent autorisées (clé de variable => valeur)
|
|
* @return array<string, string|null>
|
|
*/
|
|
public static function build(array $user, array $overrides = []): array
|
|
{
|
|
$vars = [];
|
|
foreach (self::FIELDS as $key => $def) {
|
|
$vars[$key] = $user[$def['column']] ?? null;
|
|
}
|
|
foreach ($overrides as $key => $value) {
|
|
if (array_key_exists($key, self::FIELDS)) {
|
|
$vars[$key] = $value;
|
|
}
|
|
}
|
|
|
|
return $vars;
|
|
}
|
|
}
|