Categories
CMS Drupal Mastering Development

Getting site ID from module (vs theme)

I have the following code in my custom theme that works well and allows me to test against the multisite_id in my twig files: function mytheme_preprocess_page(&$variables) { $site_path = \Drupal::service(‘site.path’); $site_path = explode(‘/’, $site_path); $site_name = $site_path[1]; $variables[‘multisite_id’] = $site_name; } I need the same functionality inside a module. I can’t seem to access the […]