@@ -18,6 +18,13 @@ class RouterFactory
1818{
1919 use Nette \StaticClass;
2020
21+ private static $ strictMode = false ;
22+
23+ public static function setStrictMode (bool $ strict = true ): void
24+ {
25+ self ::$ strictMode = $ strict ;
26+ }
27+
2128 /**
2229 * Create router with all routes for V1 module.
2330 * @return Router
@@ -177,26 +184,28 @@ private static function createExercisesRoutes(string $prefix): RouteList
177184 // special download route for file link by its key
178185 $ router [] = new GetRoute ("$ prefix/<id>/file-download/<linkKey> " , "UploadedFiles:downloadExerciseFileLinkByKey " );
179186
180- // deprecated routes for supplementary-files (replaced with `files`)
181- $ router [] = new GetRoute ("$ prefix/<id>/supplementary-files " , "ExerciseFiles:getExerciseFiles " );
182- $ router [] = new PostRoute ("$ prefix/<id>/supplementary-files " , "ExerciseFiles:uploadExerciseFiles " );
183- $ router [] = new DeleteRoute (
184- "$ prefix/<id>/supplementary-files/<fileId> " ,
185- "ExerciseFiles:deleteExerciseFile "
186- );
187- $ router [] = new GetRoute (
188- "$ prefix/<id>/supplementary-files/download-archive " ,
189- "ExerciseFiles:downloadExerciseFilesArchive "
190- );
191-
192- // deprecated (will be removed with AttachmentFile entity, unified with exercise-files)
193- $ router [] = new GetRoute ("$ prefix/<id>/attachment-files " , "ExerciseFiles:getAttachmentFiles " );
194- $ router [] = new PostRoute ("$ prefix/<id>/attachment-files " , "ExerciseFiles:uploadAttachmentFiles " );
195- $ router [] = new DeleteRoute ("$ prefix/<id>/attachment-files/<fileId> " , "ExerciseFiles:deleteAttachmentFile " );
196- $ router [] = new GetRoute (
197- "$ prefix/<id>/attachment-files/download-archive " ,
198- "ExerciseFiles:downloadAttachmentFilesArchive "
199- );
187+ if (!self ::$ strictMode ) {
188+ // deprecated routes for supplementary-files (replaced with `files`)
189+ $ router [] = new GetRoute ("$ prefix/<id>/supplementary-files " , "ExerciseFiles:getExerciseFiles " );
190+ $ router [] = new PostRoute ("$ prefix/<id>/supplementary-files " , "ExerciseFiles:uploadExerciseFiles " );
191+ $ router [] = new DeleteRoute (
192+ "$ prefix/<id>/supplementary-files/<fileId> " ,
193+ "ExerciseFiles:deleteExerciseFile "
194+ );
195+ $ router [] = new GetRoute (
196+ "$ prefix/<id>/supplementary-files/download-archive " ,
197+ "ExerciseFiles:downloadExerciseFilesArchive "
198+ );
199+
200+ // deprecated (will be removed with AttachmentFile entity, unified with exercise-files)
201+ $ router [] = new GetRoute ("$ prefix/<id>/attachment-files " , "ExerciseFiles:getAttachmentFiles " );
202+ $ router [] = new PostRoute ("$ prefix/<id>/attachment-files " , "ExerciseFiles:uploadAttachmentFiles " );
203+ $ router [] = new DeleteRoute ("$ prefix/<id>/attachment-files/<fileId> " , "ExerciseFiles:deleteAttachmentFile " );
204+ $ router [] = new GetRoute (
205+ "$ prefix/<id>/attachment-files/download-archive " ,
206+ "ExerciseFiles:downloadAttachmentFilesArchive "
207+ );
208+ }
200209
201210 $ router [] = new GetRoute ("$ prefix/<id>/tests " , "ExercisesConfig:getTests " );
202211 $ router [] = new PostRoute ("$ prefix/<id>/tests " , "ExercisesConfig:setTests " );
@@ -483,8 +492,10 @@ private static function createUploadedFilesRoutes(string $prefix): RouteList
483492 $ router [] = new GetRoute ("$ prefix/<id>/content " , "UploadedFiles:content " );
484493 $ router [] = new GetRoute ("$ prefix/<id>/digest " , "UploadedFiles:digest " );
485494
486- // deprecated (should be handled by generic download)
487- $ router [] = new GetRoute ("$ prefix/supplementary-file/<id>/download " , "UploadedFiles:downloadExerciseFile " );
495+ if (!self ::$ strictMode ) {
496+ // deprecated (should be handled by generic download)
497+ $ router [] = new GetRoute ("$ prefix/supplementary-file/<id>/download " , "UploadedFiles:downloadExerciseFile " );
498+ }
488499 return $ router ;
489500 }
490501
@@ -600,10 +611,12 @@ private static function createPipelinesRoutes(string $prefix): RouteList
600611 $ router [] = new DeleteRoute ("$ prefix/<id>/exercise-files/<fileId> " , "Pipelines:deleteExerciseFile " );
601612 $ router [] = new GetRoute ("$ prefix/<id>/exercises " , "Pipelines:getPipelineExercises " );
602613
603- // deprecated routes for supplementary files
604- $ router [] = new GetRoute ("$ prefix/<id>/supplementary-files " , "Pipelines:getExerciseFiles " );
605- $ router [] = new PostRoute ("$ prefix/<id>/supplementary-files " , "Pipelines:uploadExerciseFiles " );
606- $ router [] = new DeleteRoute ("$ prefix/<id>/supplementary-files/<fileId> " , "Pipelines:deleteExerciseFile " );
614+ if (!self ::$ strictMode ) {
615+ // deprecated routes for supplementary files
616+ $ router [] = new GetRoute ("$ prefix/<id>/supplementary-files " , "Pipelines:getExerciseFiles " );
617+ $ router [] = new PostRoute ("$ prefix/<id>/supplementary-files " , "Pipelines:uploadExerciseFiles " );
618+ $ router [] = new DeleteRoute ("$ prefix/<id>/supplementary-files/<fileId> " , "Pipelines:deleteExerciseFile " );
619+ }
607620 return $ router ;
608621 }
609622
@@ -674,8 +687,10 @@ private static function createWorkerFilesRoutes(string $prefix): RouteList
674687 $ router [] = new GetRoute ("$ prefix/exercise-file/<hash> " , "WorkerFiles:downloadExerciseFile " );
675688 $ router [] = new PutRoute ("$ prefix/result/<type>/<id> " , "WorkerFiles:uploadResultsFile " );
676689
677- // deprecated route for supplementary files
678- $ router [] = new GetRoute ("$ prefix/supplementary-file/<hash> " , "WorkerFiles:downloadExerciseFile " );
690+ if (!self ::$ strictMode ) {
691+ // deprecated route for supplementary files
692+ $ router [] = new GetRoute ("$ prefix/supplementary-file/<hash> " , "WorkerFiles:downloadExerciseFile " );
693+ }
679694 return $ router ;
680695 }
681696
0 commit comments