getRouteName() ?? ''; // Rotas administrativas e de edição nunca recebem o tema do microsite. $excluded = [ 'site_users_microsite.settings', 'site_users_microsite.user_config', 'site_users_microsite.my_config', ]; if (in_array($route_name, $excluded, TRUE)) { return FALSE; } foreach (['entity.user.edit_', 'entity.user.cancel', 'user.admin'] as $prefix) { if (str_starts_with($route_name, $prefix)) { return FALSE; } } // Rota canônica e rotas próprias do microsite. if ($route_name === 'entity.user.canonical') { return TRUE; } if (str_starts_with($route_name, 'site_users_microsite.')) { return TRUE; } // Qualquer rota com parâmetro 'user' (entidade) sob /user/{user}/. $user = $route_match->getParameter('user'); if ($user instanceof UserInterface) { $route = $route_match->getRouteObject(); $path = $route ? $route->getPath() : ''; if (str_starts_with($path, '/user/{user}/')) { return TRUE; } } // Nós cujo alias começa com /user/{uid}/ (ex.: structural_pages, blog). if ($route_name === 'entity.node.canonical') { $node = $route_match->getParameter('node'); if ($node) { $nid = is_object($node) ? $node->id() : $node; $alias = $this->aliasManager->getAliasByPath('/node/' . $nid); if (preg_match('#^/user/\d+/#', $alias)) { return TRUE; } } } // Qualquer rota cujo path atual (já processado) seja /user/{uid}/... // Cobre Views e outras rotas que não expõem parâmetro 'user' na rota. if (preg_match('#^/user/\d+/#', $this->currentPath->getPath())) { return TRUE; } return FALSE; } /** * {@inheritdoc} */ public function determineActiveTheme(RouteMatchInterface $route_match): ?string { return 'site_users_microsite_theme'; } }