/** * Register a file with the Asset server and get its asset id * * @param string $filename The name of the file * @param string $data The data within that file we are trying to save * * @return string 32 char MD5 hash */ public static function registerAsset($filename, $dataOrFile, $type = self::TYPE_TMP) { if (!is_string($dataOrFile) && !is_file($dataOrFile)) { throw new CoreException(__CLASS__ . '::' . __FUNCTION__ . '() will ONLY take string to save!'); } $assetId = md5($filename . '::' . microtime()); $path = self::_getSmartPath($assetId); self::_copyToAssetFolder($path, $dataOrFile); $asset = new Asset(); $asset->setFilename($filename)->setAssetId($assetId)->setMimeType(StringUtilsAbstract::getMimeType($filename))->setPath($path)->setType(trim($type))->save(); //add asset into cache $assetId = trim($asset->getAssetId()); self::$_cache[$assetId] = $asset; return self::$_cache[$assetId]; }