コード例 #1
1
 private function getTmpFilePath($alias, $resourceFile)
 {
     list($module, $path) = PathResolver::instance()->moduleNameAndPath($alias);
     $modulePath = Modules::instance()->pathOf($module);
     $dirAndFile = str_replace($modulePath, '', $resourceFile->getPath());
     $dir = str_replace($resourceFile->getFileName(), '', $dirAndFile);
     $baseName = $resourceFile->getFileNameWithoutExtension();
     $extension = $resourceFile->getExtension();
     $fileHash = HashGenerator::instance()->hash($resourceFile->getMTime(), 7);
     $hashedFileName = $baseName . '_' . $fileHash . '.' . $extension;
     return self::$TMP_DIR . '/' . $module . '/' . $dir . '/' . $hashedFileName;
 }
コード例 #2
0
 public function getResourceUrl($alias)
 {
     list($moduleName, $path) = PathResolver::instance()->moduleNameAndPath($alias);
     $modulePath = Modules::instance()->pathOf($moduleName);
     $resourceFile = new File($modulePath . '/' . self::RESOURCE_DIRNAME . '/' . $path);
     if (!$resourceFile->exists()) {
         $this->throwResourceNotFoundException($resourcePath);
     }
     $resourceLocation = $this->copyToResources($resourceFile, $resourcePath)[1];
     return UrlManager::instance()->geBaseUrl() . '/' . $resourceLocation;
 }