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
ca5ff1b7
Commit
ca5ff1b7
authored
11 months ago
by
Адлан Шамавов
Browse files
Options
Downloads
Plain Diff
Merge branch 'PTPS_Controller_1' into PTPS_Controller_2
parents
b02ed450
498dda71
No related branches found
No related tags found
1 merge request
!3
Ptps controller 3
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/Action/Functions.php
+1
-1
1 addition, 1 deletion
src/Action/Functions.php
src/Controller/HomeController.php
+12
-1
12 additions, 1 deletion
src/Controller/HomeController.php
src/Validation/ArrayValidation.php
+7
-4
7 additions, 4 deletions
src/Validation/ArrayValidation.php
with
20 additions
and
6 deletions
src/Action/Functions.php
+
1
−
1
View file @
ca5ff1b7
...
...
@@ -52,4 +52,4 @@ class Functions
}
return
null
;
}
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
src/Controller/HomeController.php
+
12
−
1
View file @
ca5ff1b7
...
...
@@ -4,9 +4,9 @@ namespace App\Controller;
use
App\Action\Functions
;
use
App\Validation\ArrayValidation
;
use
Symfony\Component\HttpFoundation\Request
;
use
Symfony\Bundle\FrameworkBundle\Controller\AbstractController
;
use
Symfony\Component\HttpFoundation\Response
;
use
Symfony\Component\HttpFoundation\Request
;
use
Symfony\Component\Routing\Attribute\Route
;
class
HomeController
extends
AbstractController
...
...
@@ -18,6 +18,17 @@ class HomeController extends AbstractController
$this
->
functions
=
$functions
;
}
#[Route('/func1', name: 'home', methods: ['POST'])]
public
function
func1
(
Request
$request
):
Response
{
$array
=
$request
->
get
(
'arr'
);
if
(
!
ArrayValidation
::
validateFunc1
(
$array
))
{
return
new
Response
(
"Invalid array"
);
}
$array
=
$this
->
functions
->
sortPrice
(
$array
);
return
$this
->
json
(
$array
);
}
#[Route('/', name: 'home', methods: ['POST'])]
public
function
home
(
Request
$request
):
Response
{
...
...
This diff is collapsed.
Click to expand it.
src/Validation/ArrayValidation.php
+
7
−
4
View file @
ca5ff1b7
...
...
@@ -2,12 +2,15 @@
namespace
App\Validation
;
use
Symfony\Component\Validator\Validation
;
use
Symfony\Component\Validator\Constraints
as
Assert
;
use
Symfony\Component\Validator\ConstraintViolationListInterface
;
class
ArrayValidation
{
public
static
function
validateFunc1
(
array
$array
):
bool
{
$prices
=
array_column
(
$array
,
'price'
);
$counts
=
array_column
(
$array
,
'count'
);
return
ctype_digit
(
implode
(
''
,
$prices
))
&&
ctype_digit
(
implode
(
''
,
$counts
));
}
public
static
function
validate
(
array
$array
):
ConstraintViolationListInterface
{
$validator
=
Validation
::
createValidator
();
...
...
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