mirror of
https://gitlab.unicamp.br/infimecc_drupal11_modules/site_users.git
synced 2026-05-03 14:10:41 -03:00
Corrige detecção do tema microsite e adiciona padrão Pathauto para usuários
- MicrositeThemeNegotiator: substitui verificação por regex no alias (que quebrava com aliases não-numéricos como /user/brunof) por verificação direta do nome da rota - Adiciona config/optional/pathauto.pattern.user_site_mapping.yml para criar automaticamente o padrão de alias user/[user:name] na instalação do módulo, quando o Pathauto estiver habilitado Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
14
config/optional/pathauto.pattern.user_site_mapping.yml
Normal file
14
config/optional/pathauto.pattern.user_site_mapping.yml
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
langcode: pt-br
|
||||||
|
status: true
|
||||||
|
dependencies:
|
||||||
|
module:
|
||||||
|
- pathauto
|
||||||
|
- user
|
||||||
|
id: user_site_mapping
|
||||||
|
label: 'User site mapping'
|
||||||
|
type: 'canonical_entities:user'
|
||||||
|
pattern: 'user/[user:name]'
|
||||||
|
selection_criteria: { }
|
||||||
|
selection_logic: and
|
||||||
|
weight: 0
|
||||||
|
relationships: { }
|
||||||
@@ -15,15 +15,16 @@ class MicrositeThemeNegotiator implements ThemeNegotiatorInterface {
|
|||||||
*/
|
*/
|
||||||
public function applies(RouteMatchInterface $route_match): bool {
|
public function applies(RouteMatchInterface $route_match): bool {
|
||||||
$route_name = $route_match->getRouteName();
|
$route_name = $route_match->getRouteName();
|
||||||
$excluded = ['site_users_microsite.settings'];
|
|
||||||
|
|
||||||
if (in_array($route_name, $excluded)) {
|
if ($route_name === 'site_users_microsite.settings') {
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
$current_path = \Drupal::service('path.current')->getPath();
|
if ($route_name === 'entity.user.canonical') {
|
||||||
$alias = \Drupal::service('path_alias.manager')->getAliasByPath($current_path);
|
return TRUE;
|
||||||
return (bool) preg_match('#^/user/\d+(/|$)#', $alias);
|
}
|
||||||
|
|
||||||
|
return str_starts_with($route_name, 'site_users_microsite.');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user