src/Middleware/RememberFileUploads.php
private function rememberFilesFactory($files, $prefix = '')
    {
        $result = [];

        foreach ($files as $key => $file) {
            $cacheKey = $prefix . (empty($prefix) ? '' : '.') . $key;
            if (is_string($file)){
                if (! $this->cache->has('_remembered_files.'.$cacheKey)){
                    continue;
                }
                /** @noinspection Annotator */
                $cached = $this->cache->get('_remembered_files.'.$cacheKey);
                if ($cached instanceof RememberedFile){
                    $result[$key] = $cached;
                }
                unset($cached);
                continue;
            }
            if (is_array($file)) {
                $result[$key] = $this->rememberFilesFactory($file, $cacheKey);
            } else {
                $storagePathName = $this->storagePath . DIRECTORY_SEPARATOR . $file->getFilename();
                copy($file->getPathname(), $storagePathName);
                $rememberedFile = new RememberedFile($storagePathName, $file);
                $this->cache->put('_remembered_files.'.$cacheKey, $rememberedFile, $this->cacheTimeout);
                $result[$key] = $rememberedFile;
            }
        }

        return $result;
    }
private function rememberFilesFactory($files, $prefix = '')
    {
        $result = [];

        foreach ($files as $key => $file) {
            $cacheKey = $prefix . (empty($prefix) ? '' : '.') . $key;
            if (is_string($file)){
                if (! $this->cache->has('_remembered_files.'.$cacheKey)){
                    continue;
                }
                /** @noinspection Annotator */
                $cached = $this->cache->get('_remembered_files.'.$cacheKey);
                if ($cached instanceof RememberedFile){
                    $result[$key] = $cached;
                }
                unset($cached);
                continue;
            }
            if (is_array($file)) {
                $result[$key] = $this->rememberFilesFactory($file, $cacheKey);
            } else {
                $storagePathName = $this->storagePath . DIRECTORY_SEPARATOR . $file->getFilename();
                copy($file->getPathname(), $storagePathName);
                $rememberedFile = new RememberedFile($storagePathName, $file);
                $this->cache->put('_remembered_files.'.$cacheKey, $rememberedFile, $this->cacheTimeout);
                $result[$key] = $rememberedFile;
            }
        }

        return $result;
    }
private function rememberFilesFactory ( $ files , $ prefix = '' ) { $ result = [ ] ; foreach ( $ files as $ key => $ file ) { $ cacheKey = $ prefix . ( empty ( $ prefix ) ? '' : '.' ) . $ key ; if ( is_string ( $ file ) ) { if ( ! $ this -> cache -> has ( '_remembered_files.' . $ cacheKey ) ) { continue ; } /** @noinspection Annotator */ $ cached = $ this -> cache -> get ( '_remembered_files.' . $ cacheKey ) ; if ( $ cached instanceof RememberedFile ) { $ result [ $ key ] = $ cached ; } unset ( $ cached ) ; continue ; } if ( is_array ( $ file ) ) { $ result [ $ key ] = $ this -> rememberFilesFactory ( $ file , $ cacheKey ) ; } else { $ storagePathName = $ this -> storagePath . DIRECTORY_SEPARATOR . $ file -> getFilename ( ) ; copy ( $ file -> getPathname ( ) , $ storagePathName ) ; $ rememberedFile = new RememberedFile ( $ storagePathName , $ file ) ; $ this -> cache -> put ( '_remembered_files.' . $ cacheKey , $ rememberedFile , $ this -> cacheTimeout ) ; $ result [ $ key ] = $ rememberedFile ; } } return $ result ; }
Recursive factory method to create RememberedFile from UploadedFile.

@param array|UploadedFile[] $files
@param string $prefix
@return array|RememberedFile[]
Recursive factory method to create RememberedFile from UploadedFile .