original_string: private function getMainWithHashedPaths(string $realPath): string
    {
      $main_js_file = self::getMainJsFileName($realPath);
      // Read the main file.
      $js = file_get_contents($main_js_file);
      if ($js===false) $this->logError("Unable to read file '%s'.", $realPath);
  
      // Extract paths from main.
      preg_match('/^(.*paths:[^{]*)({[^}]*})(.*)$/sm', $js, $matches);
      if (!isset($matches[2])) $this->logError("Unable to find paths in '%s'.", $realPath);
  
      // @todo Remove from paths files already combined.
  
      // Lookup table as paths in requirejs.config, however, keys and values are flipped.
      $paths = [];
      // Replace aliases to paths with aliases to paths with hashes (i.e. paths to minimized files).
      list($base_url, $aliases) = $this->extractPaths($main_js_file);
      if (isset($base_url) && isset($paths))
      {
        foreach ($aliases as $alias => $path)
        {
          $path_with_hash = $this->getPathInResourcesWithHash($base_url, $path);
          if (isset($path_with_hash))
          {
            $paths[$this->removeJsExtension($path_with_hash)] = $alias;
          }
        }
      }
  
      // Add paths from modules that conform to ADM naming convention to paths with hashes (i.e. path to minimized files).
      foreach ($this->getResourcesInfo() as $info)
      {
        // @todo Skip *.main.js files.
  
        // Test JS file is not already in paths, e.g. 'jquery': 'jquery/jquery'.
        if (!isset($paths[$this->removeJsExtension($info['path_name_in_sources_with_hash'])]))
        {
          if (isset($info['path_name_in_sources']))
          {
            $module                 = $this->getNamespaceFromResourceFilename($info['full_path_name']);
            $path_with_hash         = $this->getNamespaceFromResourceFilename($info['full_path_name_with_hash']);
            $paths[$path_with_hash] = $module;
          }
        }
      }
  
      // Convert the paths to proper JS code.
      $matches[2] = json_encode(array_flip($paths), JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT);
      array_shift($matches);
      $js = implode('', $matches);
  
      return $js;
    }
code: private function getMainWithHashedPaths(string $realPath): string
    {
      $main_js_file = self::getMainJsFileName($realPath);
      // Read the main file.
      $js = file_get_contents($main_js_file);
      if ($js===false) $this->logError("Unable to read file '%s'.", $realPath);
  
      // Extract paths from main.
      preg_match('/^(.*paths:[^{]*)({[^}]*})(.*)$/sm', $js, $matches);
      if (!isset($matches[2])) $this->logError("Unable to find paths in '%s'.", $realPath);
  
      // @todo Remove from paths files already combined.
  
      // Lookup table as paths in requirejs.config, however, keys and values are flipped.
      $paths = [];
      // Replace aliases to paths with aliases to paths with hashes (i.e. paths to minimized files).
      list($base_url, $aliases) = $this->extractPaths($main_js_file);
      if (isset($base_url) && isset($paths))
      {
        foreach ($aliases as $alias => $path)
        {
          $path_with_hash = $this->getPathInResourcesWithHash($base_url, $path);
          if (isset($path_with_hash))
          {
            $paths[$this->removeJsExtension($path_with_hash)] = $alias;
          }
        }
      }
  
      // Add paths from modules that conform to ADM naming convention to paths with hashes (i.e. path to minimized files).
      foreach ($this->getResourcesInfo() as $info)
      {
        // @todo Skip *.main.js files.
  
        // Test JS file is not already in paths, e.g. 'jquery': 'jquery/jquery'.
        if (!isset($paths[$this->removeJsExtension($info['path_name_in_sources_with_hash'])]))
        {
          if (isset($info['path_name_in_sources']))
          {
            $module                 = $this->getNamespaceFromResourceFilename($info['full_path_name']);
            $path_with_hash         = $this->getNamespaceFromResourceFilename($info['full_path_name_with_hash']);
            $paths[$path_with_hash] = $module;
          }
        }
      }
  
      // Convert the paths to proper JS code.
      $matches[2] = json_encode(array_flip($paths), JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT);
      array_shift($matches);
      $js = implode('', $matches);
  
      return $js;
    }
code_tokens: private function getMainWithHashedPaths ( string $ realPath ) : string { $ main_js_file = self :: getMainJsFileName ( $ realPath ) ; // Read the main file. $ js = file_get_contents ( $ main_js_file ) ; if ( $ js === false ) $ this -> logError ( "Unable to read file '%s'." , $ realPath ) ; // Extract paths from main. preg_match ( '/^(.*paths:[^{]*)({[^}]*})(.*)$/sm' , $ js , $ matches ) ; if ( ! isset ( $ matches [ 2 ] ) ) $ this -> logError ( "Unable to find paths in '%s'." , $ realPath ) ; // @todo Remove from paths files already combined. // Lookup table as paths in requirejs.config, however, keys and values are flipped. $ paths = [ ] ; // Replace aliases to paths with aliases to paths with hashes (i.e. paths to minimized files). list ( $ base_url , $ aliases ) = $ this -> extractPaths ( $ main_js_file ) ; if ( isset ( $ base_url ) && isset ( $ paths ) ) { foreach ( $ aliases as $ alias => $ path ) { $ path_with_hash = $ this -> getPathInResourcesWithHash ( $ base_url , $ path ) ; if ( isset ( $ path_with_hash ) ) { $ paths [ $ this -> removeJsExtension ( $ path_with_hash ) ] = $ alias ; } } } // Add paths from modules that conform to ADM naming convention to paths with hashes (i.e. path to minimized files). foreach ( $ this -> getResourcesInfo ( ) as $ info ) { // @todo Skip *.main.js files. // Test JS file is not already in paths, e.g. 'jquery': 'jquery/jquery'. if ( ! isset ( $ paths [ $ this -> removeJsExtension ( $ info [ 'path_name_in_sources_with_hash' ] ) ] ) ) { if ( isset ( $ info [ 'path_name_in_sources' ] ) ) { $ module = $ this -> getNamespaceFromResourceFilename ( $ info [ 'full_path_name' ] ) ; $ path_with_hash = $ this -> getNamespaceFromResourceFilename ( $ info [ 'full_path_name_with_hash' ] ) ; $ paths [ $ path_with_hash ] = $ module ; } } } // Convert the paths to proper JS code. $ matches [ 2 ] = json_encode ( array_flip ( $ paths ) , JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT ) ; array_shift ( $ matches ) ; $ js = implode ( '' , $ matches ) ; return $ js ; }
docstring: Rewrites paths in requirejs.config. Adds path names from namespaces and aliases to filenames with hashes.
  
  @param string $realPath The filename of the main.js file.
  
  @return string
docstring_tokens: Rewrites paths in requirejs . config . Adds path names from namespaces and aliases to filenames with hashes .