Loading src/Controller/ReadFileLineByLineController.php +8 −6 Original line number Diff line number Diff line Loading @@ -4,6 +4,7 @@ namespace App\Controller; use App\Actions\ReadFileLineByLineAction; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\Attribute\Route; Loading @@ -15,20 +16,21 @@ class ReadFileLineByLineController extends AbstractController * * @param string $filePath путь до файла * @return Response */ #[Route('/readbyline/{filePath}', name: 'app_read_file_line_by_line')] #[Route('/readbyline', name: 'app_read_file_line_by_line', methods: ['POST'])] public function index( string $filePath, Request $request, ReadFileLineByLineAction $action ) : Response { $file = ""; $file = $request->files->get('File'); $content = ""; try{ foreach ($action->act($filePath) as $line) { $file .= $line; foreach ($action->act($file->getRealPath()) as $line) { $content .= $line; } } catch (\Exception $exception) { return new Response($exception->getMessage(), Response::HTTP_NOT_FOUND); } return new Response($file, Response::HTTP_OK); return new Response($content); } } Loading
src/Controller/ReadFileLineByLineController.php +8 −6 Original line number Diff line number Diff line Loading @@ -4,6 +4,7 @@ namespace App\Controller; use App\Actions\ReadFileLineByLineAction; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\Attribute\Route; Loading @@ -15,20 +16,21 @@ class ReadFileLineByLineController extends AbstractController * * @param string $filePath путь до файла * @return Response */ #[Route('/readbyline/{filePath}', name: 'app_read_file_line_by_line')] #[Route('/readbyline', name: 'app_read_file_line_by_line', methods: ['POST'])] public function index( string $filePath, Request $request, ReadFileLineByLineAction $action ) : Response { $file = ""; $file = $request->files->get('File'); $content = ""; try{ foreach ($action->act($filePath) as $line) { $file .= $line; foreach ($action->act($file->getRealPath()) as $line) { $content .= $line; } } catch (\Exception $exception) { return new Response($exception->getMessage(), Response::HTTP_NOT_FOUND); } return new Response($file, Response::HTTP_OK); return new Response($content); } }