' . t('Site Tools provides reusable utilities for other modules, including a share links block.') . '

'; } return NULL; } /** * Implements hook_theme(). */ function site_tools_theme(): array { return [ 'site_tools_share_links' => [ 'variables' => [ 'links' => [], 'attributes' => [], ], 'template' => 'site-tools-share-links', ], ]; } /** * Invoca hook_site_tools_share_links() para coletar links de compartilhamento. * * @return array * Array de links de compartilhamento fornecidos por outros módulos. * Cada link deve ter as chaves: * - 'content': Render array ou markup do link. * - 'weight': (opcional) Peso para ordenação. * - 'provider': (opcional) Nome do módulo que fornece o link. */ function site_tools_collect_share_links(): array { $links = \Drupal::moduleHandler()->invokeAll('site_tools_share_links'); \Drupal::moduleHandler()->alter('site_tools_share_links', $links); // Ordena por peso. uasort($links, function ($a, $b) { $weight_a = $a['weight'] ?? 0; $weight_b = $b['weight'] ?? 0; return $weight_a <=> $weight_b; }); return $links; }