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
b6294936
Commit
b6294936
authored
11 months ago
by
Адлан Шамавов
Browse files
Options
Downloads
Plain Diff
Merge branch 'PTPS_Controller_6' into PTPS_Controller_7
parents
512b4a2c
ecb2ff0f
No related branches found
No related tags found
1 merge request
!7
Ptps controller 7
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/Action/Functions.php
+9
-10
9 additions, 10 deletions
src/Action/Functions.php
src/Controller/HomeController.php
+21
-5
21 additions, 5 deletions
src/Controller/HomeController.php
src/Validation/ArrayValidation.php
+26
-0
26 additions, 0 deletions
src/Validation/ArrayValidation.php
with
56 additions
and
15 deletions
src/Action/Functions.php
+
9
−
10
View file @
b6294936
...
@@ -17,6 +17,7 @@ class Functions
...
@@ -17,6 +17,7 @@ class Functions
* @param array $array
* @param array $array
* @return array
* @return array
*/
*/
public
function
sortPrice
(
array
$array
):
array
public
function
sortPrice
(
array
$array
):
array
{
{
$prices
=
array_column
(
$array
,
'price'
);
$prices
=
array_column
(
$array
,
'price'
);
...
@@ -70,13 +71,13 @@ class Functions
...
@@ -70,13 +71,13 @@ class Functions
}
}
/**
/**
* Выходной массив:
* Выходной массив:
* Array (
* Array (
* [0] => Array([0] => laravel, [1] => php)
* [0] => Array([0] => laravel, [1] => php)
* [1] => Array([0] => codeigniter, [1] => php)
* [1] => Array([0] => codeigniter, [1] => php)
* [3] => Array([0] => c++, [1] => java))
* [3] => Array([0] => c++, [1] => java))
* )
* )
*/
*/
/**
/**
* Сгруппировать подразедлы в верхние разделы меню
* Сгруппировать подразедлы в верхние разделы меню
...
@@ -157,7 +158,6 @@ class Functions
...
@@ -157,7 +158,6 @@ class Functions
return
(
int
)
$dateInterval
->
format
(
"%a"
)
+
1
;
return
(
int
)
$dateInterval
->
format
(
"%a"
)
+
1
;
}
}
/**
/**
* Вернет все пятницы 13 в году
* Вернет все пятницы 13 в году
* @param int $year год, в котором необходимо произвести расчет
* @param int $year год, в котором необходимо произвести расчет
...
@@ -187,5 +187,4 @@ class Functions
...
@@ -187,5 +187,4 @@ class Functions
$dateInterval
=
date_diff
(
$dateStart
,
$dateEnd
);
$dateInterval
=
date_diff
(
$dateStart
,
$dateEnd
);
return
(
int
)
$dateInterval
->
format
(
"%a"
)
;
return
(
int
)
$dateInterval
->
format
(
"%a"
)
;
}
}
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
src/Controller/HomeController.php
+
21
−
5
View file @
b6294936
...
@@ -2,20 +2,36 @@
...
@@ -2,20 +2,36 @@
namespace
App\Controller
;
namespace
App\Controller
;
use
App\Action\Functions
;
use
DateInterval
;
use
App\Validation\DateValidation
;
use
DatePeriod
;
use
DateTime
;
use
DateTimeImmutable
;
use
DateTimeImmutable
;
use
Symfony\Bundle\FrameworkBundle\Controller\AbstractController
;
use
Symfony\Bundle\FrameworkBundle\Controller\AbstractController
;
use
Symfony\Component\HttpFoundation\Response
;
use
Symfony\Component\HttpFoundation\Response
;
use
Symfony\Component\HttpFoundation\Request
;
use
Symfony\Component\Routing\Attribute\Route
;
use
Symfony\Component\Routing\Attribute\Route
;
class
HomeController
extends
AbstractController
class
HomeController
extends
AbstractController
{
{
private
Functions
$functions
;
private
function
countFriday13
(
int
$year
):
iterable
{
$stardDate
=
new
DateTime
(
"
{
$year
}
-01-01 Friday"
);
$year
+=
1
;
$endDate
=
new
DateTime
(
"
{
$year
}
-01-01"
);
$interval
=
new
DateInterval
(
'P7D'
);
foreach
(
new
DatePeriod
(
$stardDate
,
$interval
,
$endDate
)
as
$day
)
{
yield
new
DateTimeImmutable
(
$day
->
format
(
"Y-m-d"
));
}
}
public
function
__construct
(
Functions
$functions
)
#[Route('/{year}', name: 'home')]
public
function
home
(
int
$year
):
Response
{
{
$this
->
functions
=
$functions
;
$fridays
=
array
();
foreach
(
$this
->
countFriday13
(
$year
)
as
$date
)
{
$fridays
[]
=
$date
->
format
(
"Y-m-d l"
);
}
return
$this
->
render
(
'home.html.twig'
,
[
'fridays'
=>
$fridays
]);
}
}
#
[
Route
(
'/{startDate}/{endDate}'
,
name
:
'home'
)]
// 01-01-2024
#
[
Route
(
'/{startDate}/{endDate}'
,
name
:
'home'
)]
// 01-01-2024
...
...
This diff is collapsed.
Click to expand it.
src/Validation/ArrayValidation.php
0 → 100644
+
26
−
0
View file @
b6294936
<?php
namespace
App\Validation
;
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
validateFunc2
(
array
$array
):
bool
{
$ids
=
array_column
(
$array
,
'id'
);
$ages
=
array_column
(
$array
,
'age'
);
return
ctype_digit
(
implode
(
''
,
$ids
))
&&
ctype_digit
(
implode
(
''
,
$ages
));
}
public
static
function
validateFunc4
(
array
$array
):
bool
{
$depths
=
array_column
(
$array
,
'depth'
);
return
ctype_digit
(
implode
(
''
,
$depths
));
}
}
\ No newline at end of file
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