/**
  * Load the database backed configuration.
  *
  * This function does the work of loading the entire site configuration
  * from the database and returns it as a group => [key=>value] set.  The
  * configuration is retrieved from cache if it already exists there, and
  * stored into the cache after it is loaded.
  *
  * @return array
  */
 public function loadConfiguration()
 {
     /** @var ConfigLoaderRepository $repository */
     $repository = $this->loadEnvironment();
     $cache = $repository->fetchConfig();
     if (!empty($cache)) {
         return $cache;
     }
     $config = [];
     // Fetch all groups, and fetch the config for each group based on the
     // environment and website ID of the current site.
     foreach ($repository->fetchAllGroups() as $group) {
         $groupConfig = ConfigModel::fetchSettings($repository->getEnvironment(), $repository->getWebsiteId(), $group);
         $config[$group] = $groupConfig;
     }
     $repository->storeConfig($config);
     return $config;
 }