Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
iqdevTranningProgram
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
Адлан Шамавов
iqdevTranningProgram
Commits
17eb5a11
Commit
17eb5a11
authored
11 months ago
by
Адлан Шамавов
Browse files
Options
Downloads
Patches
Plain Diff
add readFileLineByLine
parent
dd80058b
No related branches found
Branches containing commit
No related tags found
1 merge request
!9
Ptps controller 9
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
.idea/sonarlint/issuestore/a/d/ad8b439416d1e02614f47c5b471c7c4e587dca82
+2
-0
2 additions, 0 deletions
...t/issuestore/a/d/ad8b439416d1e02614f47c5b471c7c4e587dca82
src/Controller/HomeController.php
+7
-7
7 additions, 7 deletions
src/Controller/HomeController.php
with
9 additions
and
7 deletions
.idea/sonarlint/issuestore/a/d/ad8b439416d1e02614f47c5b471c7c4e587dca82
+
2
−
0
View file @
17eb5a11
vphp:S121"0Add curly braces around the nested statement(s).(8Ƌ1J$562771d0-0b91-4f4c-beaf-90c25c2ac224
\ No newline at end of file
This diff is collapsed.
Click to expand it.
src/Controller/HomeController.php
+
7
−
7
View file @
17eb5a11
...
...
@@ -12,26 +12,26 @@ use Symfony\Component\Routing\Attribute\Route;
class
HomeController
extends
AbstractController
{
private
function
read
Log
File
(
string
$fileName
):
string
{
private
function
readFile
LineByLine
(
string
$fileName
):
iterable
{
$filePath
=
$this
->
getParameter
(
'kernel.project_dir'
)
.
"/public/files/"
.
$fileName
;
if
(
file_exists
(
$filePath
))
{
$text
=
""
;
$file
=
fopen
(
$filePath
,
"r"
);
while
(
!
feof
(
$file
))
{
$line
=
fgets
(
$file
);
$text
.
=
$line
;
yield
fgets
(
$file
);
}
fclose
(
$file
);
return
$text
;
}
return
"Такого файла не существует."
;
else
yield
"Такого файла не существует."
;
}
#[Route('/{fileName}', name: 'home')]
public
function
home
(
string
$fileName
):
Response
// text.txt
{
$text
=
$this
->
readLogFile
(
$fileName
);
$text
=
""
;
foreach
(
$this
->
readFileLineByLine
(
$fileName
)
as
$line
)
{
$text
.
=
$line
;
}
return
$this
->
render
(
'home.html.twig'
,
[
'text'
=>
$text
]);
}
}
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