/**
  * {@inheritdoc}
  */
 public function getAllModules(FeaturesBundleInterface $bundle = NULL)
 {
     // ModuleHandler::getModuleDirectories() returns data only for installed
     // modules. system_rebuild_module_data() includes only the site's install
     // profile directory, while we may need to include a custom profile.
     // @see _system_rebuild_module_data().
     $listing = new ExtensionDiscovery(\Drupal::root());
     $profile_directories = [];
     // Register the install profile.
     $installed_profile = drupal_get_profile();
     if ($installed_profile) {
         $profile_directories[] = drupal_get_path('profile', $installed_profile);
     }
     if (isset($bundle) && $bundle->isProfile()) {
         $profile_directory = 'profiles/' . $bundle->getProfileName();
         if ($bundle->getProfileName() != $installed_profile && is_dir($profile_directory)) {
             $profile_directories[] = $profile_directory;
         }
     }
     $listing->setProfileDirectories($profile_directories);
     // Find modules.
     $modules = $listing->scan('module');
     // Find installation profiles.
     $profiles = $listing->scan('profile');
     foreach ($profiles as $key => $profile) {
         $modules[$key] = $profile;
     }
     $return = array();
     // Detect modules by namespace.
     // If namespace is provided but is empty, then match all modules.
     foreach ($modules as $module_name => $extension) {
         if ($this->isFeatureModule($extension) && (!isset($bundle) || $bundle->isDefault() || $bundle->inBundle($module_name))) {
             $return[$module_name] = $extension;
         }
     }
     return $return;
 }