/** * Generate the URI for the provided details * * @param $type * @param $lookup * @param $domain * @param $path * @param $file * * @return null|string */ public function generateUriPath($type, $lookup, $domain, $path, $file) { $parts = []; //Include the map type $parts[] = $type; //When lookup parts are avilable, e.g. vendor/package, include them if (is_array($lookup)) { foreach ($lookup as $lookupPart) { $parts[] = $lookupPart; } } $parts[] = static::hashDomain($domain); //If not path is available, assume you are requesting the base path if (empty($path)) { $partHash = 'b'; } else { //Build the hashable path $partHash = $this->_mapper->hashDirectoryArray(ValueAs::arr(explode('/', $path))); } $parts[] = $partHash; $baseDir = $this->getBasePath($this->_mapper, $type, (array) $lookup); $filePath = Path::build($baseDir, $path, $file); $fileHash = $this->_dispatcher->getFileHash($filePath); if ($fileHash === null) { //File hash doesnt exist in the cache, so lets look it up $fullPath = Path::build($this->_dispatcher->getBaseDirectory(), $filePath); $fileHash = ResourceGenerator::getFileHash($fullPath); if (!$fileHash) { //If we cant get a hash of the file, its unlikely it exists return null; } //Cache the entry, to optimise should the same resource be re-requested $this->_dispatcher->addFileHashEntry($filePath, $fileHash); } $parts[] = substr($fileHash, 0, 7); //Include the file extension $parts[] = $file; return implode('/', $parts); }