diff --git a/.idea/sonarlint/issuestore/0/3/03141036569b5869397180192f8b98c1360e1556 b/.idea/sonarlint/issuestore/0/3/03141036569b5869397180192f8b98c1360e1556 new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/.idea/sonarlint/issuestore/5/8/58d82e459ad700473925afc6a4d3ceb1cbdfdf19 b/.idea/sonarlint/issuestore/5/8/58d82e459ad700473925afc6a4d3ceb1cbdfdf19 new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/.idea/sonarlint/issuestore/b/5/b5aea0f996f6645c77ef6ac38e15316374d0fba2 b/.idea/sonarlint/issuestore/b/5/b5aea0f996f6645c77ef6ac38e15316374d0fba2 new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/.idea/sonarlint/issuestore/index.pb b/.idea/sonarlint/issuestore/index.pb index 75525eea3e78241804013b290d483acee3848202..bc34c281a508ff2504699fb4ee0b93fc0e72d98b 100644 --- a/.idea/sonarlint/issuestore/index.pb +++ b/.idea/sonarlint/issuestore/index.pb @@ -2,4 +2,10 @@ Q !src/Controller/HomeController.php,a\d\ad8b439416d1e02614f47c5b471c7c4e587dca82 H -templates/home.html.twig,3\8\38ac5fc300d52f94b369e87fbb1937abe29f831f \ No newline at end of file +templates/home.html.twig,3\8\38ac5fc300d52f94b369e87fbb1937abe29f831f +V +&assets/controllers/hello_controller.js,b\5\b5aea0f996f6645c77ef6ac38e15316374d0fba2 +C +assets/bootstrap.js,0\3\03141036569b5869397180192f8b98c1360e1556 +E +assets/styles/app.css,5\8\58d82e459ad700473925afc6a4d3ceb1cbdfdf19 \ No newline at end of file diff --git a/.idea/sonarlint/securityhotspotstore/0/3/03141036569b5869397180192f8b98c1360e1556 b/.idea/sonarlint/securityhotspotstore/0/3/03141036569b5869397180192f8b98c1360e1556 new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/.idea/sonarlint/securityhotspotstore/5/8/58d82e459ad700473925afc6a4d3ceb1cbdfdf19 b/.idea/sonarlint/securityhotspotstore/5/8/58d82e459ad700473925afc6a4d3ceb1cbdfdf19 new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/.idea/sonarlint/securityhotspotstore/b/5/b5aea0f996f6645c77ef6ac38e15316374d0fba2 b/.idea/sonarlint/securityhotspotstore/b/5/b5aea0f996f6645c77ef6ac38e15316374d0fba2 new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/.idea/sonarlint/securityhotspotstore/index.pb b/.idea/sonarlint/securityhotspotstore/index.pb index 75525eea3e78241804013b290d483acee3848202..bc34c281a508ff2504699fb4ee0b93fc0e72d98b 100644 --- a/.idea/sonarlint/securityhotspotstore/index.pb +++ b/.idea/sonarlint/securityhotspotstore/index.pb @@ -2,4 +2,10 @@ Q !src/Controller/HomeController.php,a\d\ad8b439416d1e02614f47c5b471c7c4e587dca82 H -templates/home.html.twig,3\8\38ac5fc300d52f94b369e87fbb1937abe29f831f \ No newline at end of file +templates/home.html.twig,3\8\38ac5fc300d52f94b369e87fbb1937abe29f831f +V +&assets/controllers/hello_controller.js,b\5\b5aea0f996f6645c77ef6ac38e15316374d0fba2 +C +assets/bootstrap.js,0\3\03141036569b5869397180192f8b98c1360e1556 +E +assets/styles/app.css,5\8\58d82e459ad700473925afc6a4d3ceb1cbdfdf19 \ No newline at end of file diff --git a/src/Controller/HomeController.php b/src/Controller/HomeController.php index ce5e43e9d94c60bbf5f8e35fab910dfcba1f0890..c0b1db0ccaad12b9675d4b3571f1fc95f910924d 100644 --- a/src/Controller/HomeController.php +++ b/src/Controller/HomeController.php @@ -2,52 +2,24 @@ namespace App\Controller; +use DateTimeImmutable; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\Attribute\Route; class HomeController extends AbstractController { - private function prepareMenu(array $aMenu): array { - $result = []; - foreach ($aMenu as $arr) { - if ($arr['depth'] === 0) { - $result[] = array( - 'name' => $arr['name'], - 'depth' => $arr['depth'], - 'submenu' => [] - ); - continue; - } - $result[array_key_last($result)]['submenu'][] = array( - 'name' => $arr['name'], - 'depth' => $arr['depth'], - ); - } - return $result; + private function howDaysToNy(DateTimeImmutable $date): int { + $endYear = date("Y-12-31", date_timestamp_get($date)); + $dateInterval = date_diff(new DateTimeImmutable($endYear), $date); + return $dateInterval->format("%a") + 1; } - #[Route('/', name: 'home')] public function home(): Response { - $aMenu = [ - ['name' => 'Смартфоны и гаджеты','depth' => 0,], - ['name' => 'Смартфоны, мобильные телефоны','depth' => 1,], - ['name' => 'Планшеты','depth' => 1,], - ['name' => 'Ðаушники и гарнитуры','depth' => 1,], - ['name' => 'Компьютеры и ноутбуки','depth' => 0,], - ['name' => 'Ðоутбуки и акÑеÑÑуары','depth' => 1,], - ['name' => 'Компьютеры и мониторы','depth' => 1,], - ['name' => 'Компьютерные комплектующие','depth' => 1,], - ['name' => 'Техника Ð´Ð»Ñ Ð´Ð¾Ð¼Ð°','depth' => 0,], - ['name' => 'Техника Ð´Ð»Ñ ÑƒÐ±Ð¾Ñ€ÐºÐ¸','depth' => 1,], - ['name' => 'Товары Ð´Ð»Ñ ÑƒÑ…Ð¾Ð´Ð° за одеждой','depth' => 1,], - ['name' => 'ÐкÑеÑÑуары Ð´Ð»Ñ Ñ‚ÐµÑ…Ð½Ð¸ÐºÐ¸','depth' => 1,], - ['name' => 'Товары Ð´Ð»Ñ Ð´Ð¾Ð¼Ð° и кухни','depth' => 0,], - ['name' => 'ПоÑуда','depth' => 1,], - ]; + $count = $this->howDaysToNy(new DateTimeImmutable()); - return $this->render('home.html.twig', ['menu' => $this->prepareMenu($aMenu)]); + return $this->render('home.html.twig', ['count' => $count]); } } diff --git a/templates/home.html.twig b/templates/home.html.twig index 9baaf00b56202c0678d0032d0311ab647a9fe3a5..6ce69c6ff8ec4817cb0d43c5b94b8741627c4edc 100644 --- a/templates/home.html.twig +++ b/templates/home.html.twig @@ -1,12 +1,3 @@ {% block body %} - <ul> - {% for value in menu %} - {% if value.depth == 0 %} - <h2>{{ value.name }}</h2> - {% for val in value.submenu %} - <li>{{ val.name }}</li> - {% endfor %} - {% endif %} - {% endfor %} - </ul> + <h1>Кол-во дней до ÐГ: {{ count }}</h1> {% endblock %} \ No newline at end of file