Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
iqdevTranningProj
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Александр Плохих
iqdevTranningProj
Commits
b77df9d7
Commit
b77df9d7
authored
11 months ago
by
Александр Плохих
Browse files
Options
Downloads
Patches
Plain Diff
chenge logic to get and read files
parent
106913cf
Branches
PTPS|Controller_8
Branches containing commit
No related tags found
1 merge request
!8
make controller
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/Controller/ReadLogFileController.php
+12
-10
12 additions, 10 deletions
src/Controller/ReadLogFileController.php
with
12 additions
and
10 deletions
src/Controller/ReadLogFileController.php
+
12
−
10
View file @
b77df9d7
...
...
@@ -3,6 +3,7 @@
namespace
App\Controller
;
use
App\Actions\ReadLogFileAction
;
use
Symfony\Bundle\FrameworkBundle\Controller\AbstractController
;
use
Symfony\Component\HttpFoundation\Request
;
use
Symfony\Component\HttpFoundation\Response
;
use
Symfony\Component\Routing\Attribute\Route
;
...
...
@@ -13,15 +14,16 @@ class ReadLogFileController extends AbstractController
* проверяет, что файл существует и выводит пользователю весь контент файла
* (файл можешь создать любой)
*
* @param string $filePath путь до файла
* @return Response */
#[Route('/read/{filePath}', name: 'app_read_log_file', methods: ['GET'])]
public
function
index
(
string
$filePath
,
ReadLogFileAction
$action
):
Response
* @param Request $request
* @param ReadLogFileAction $action
* @return Response
*/
#[Route('/read', name: 'app_read_log_file', methods: ['POST'])]
public
function
index
(
Request
$request
,
ReadLogFileAction
$action
):
Response
{
try
{
return
new
Response
(
$action
->
act
(
$filePath
));
}
catch
(
\Exception
$exception
)
{
return
new
Response
(
'Searching file not found :/'
,
422
);
}
$file
=
$request
->
files
->
get
(
"File"
);
return
new
Response
(
$action
->
act
(
$file
->
getPathname
()));
}
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment