From 948bf6939a125cbc9b6c899248b3f98a4a32341b Mon Sep 17 00:00:00 2001 From: David Marland Date: Sat, 2 Jan 2021 16:11:10 +0000 Subject: [PATCH] Fix bugs with creating new items and updating pages --- Dockerfile | 2 +- app/composer.json | 4 +- app/composer.lock | 79 +++++++++++++++++++++- app/config/bundles.php | 1 + app/config/packages/dev/web_profiler.yaml | 6 ++ app/config/packages/test/web_profiler.yaml | 6 ++ app/config/routes/dev/web_profiler.yaml | 7 ++ app/src/Controller/Admin/PageAction.php | 3 +- app/src/Controller/Admin/PagesAction.php | 2 +- app/src/Controller/Admin/PeopleAction.php | 2 +- app/src/Controller/Admin/ShowsAction.php | 2 +- app/src/Service/PageService.php | 6 +- app/src/Service/PeopleService.php | 4 +- app/src/Service/ProgrammesService.php | 4 +- app/symfony.lock | 20 ++++++ 15 files changed, 134 insertions(+), 14 deletions(-) create mode 100644 app/config/packages/dev/web_profiler.yaml create mode 100644 app/config/packages/test/web_profiler.yaml create mode 100644 app/config/routes/dev/web_profiler.yaml diff --git a/Dockerfile b/Dockerfile index a44f337..b082a7f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -36,7 +36,7 @@ RUN docker-php-ext-configure opcache \ && docker-php-ext-configure zip \ && docker-php-ext-configure xml \ && docker-php-ext-configure intl \ - && docker-php-source delete \\ + && docker-php-source delete \ && docker-php-ext-install \ opcache \ calendar \ diff --git a/app/composer.json b/app/composer.json index 437e3cd..ba3dd84 100644 --- a/app/composer.json +++ b/app/composer.json @@ -25,7 +25,9 @@ "phpunit/phpunit": "^7.0", "roave/security-advisories": "dev-master", "squizlabs/php_codesniffer": "^3.2", - "symfony/debug": "^4.0" + "symfony/debug": "^4.0", + "symfony/stopwatch": "^4.4", + "symfony/web-profiler-bundle": "^4.4" }, "config": { "preferred-install": { diff --git a/app/composer.lock b/app/composer.lock index fc265b3..bbbf78a 100644 --- a/app/composer.lock +++ b/app/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "c9b2faf747121d23abf3a39282e94d25", + "content-hash": "befb1ab42b2a607d89ced42a07526dea", "packages": [ { "name": "composer/package-versions-deprecated", @@ -682,6 +682,7 @@ "cache", "caching" ], + "abandoned": true, "time": "2019-11-29T11:22:01+00:00" }, { @@ -1397,6 +1398,7 @@ "reflection", "static" ], + "abandoned": "roave/better-reflection", "time": "2020-03-27T11:06:43+00:00" }, { @@ -8717,6 +8719,81 @@ ], "time": "2020-08-10T04:50:15+00:00" }, + { + "name": "symfony/web-profiler-bundle", + "version": "v4.4.18", + "source": { + "type": "git", + "url": "https://github.com/symfony/web-profiler-bundle.git", + "reference": "d419cd0b14f15f44bb50b77e2f209a8c63249baa" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/web-profiler-bundle/zipball/d419cd0b14f15f44bb50b77e2f209a8c63249baa", + "reference": "d419cd0b14f15f44bb50b77e2f209a8c63249baa", + "shasum": "" + }, + "require": { + "php": ">=7.1.3", + "symfony/config": "^4.2|^5.0", + "symfony/framework-bundle": "^4.4|^5.0", + "symfony/http-kernel": "^4.4", + "symfony/routing": "^4.3|^5.0", + "symfony/twig-bundle": "^4.2|^5.0", + "twig/twig": "^1.41|^2.10|^3.0" + }, + "conflict": { + "symfony/form": "<4.3", + "symfony/messenger": "<4.2" + }, + "require-dev": { + "symfony/browser-kit": "^4.3|^5.0", + "symfony/console": "^4.3|^5.0", + "symfony/css-selector": "^3.4|^4.0|^5.0", + "symfony/dependency-injection": "^3.4|^4.0|^5.0", + "symfony/stopwatch": "^3.4|^4.0|^5.0" + }, + "type": "symfony-bundle", + "autoload": { + "psr-4": { + "Symfony\\Bundle\\WebProfilerBundle\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony WebProfilerBundle", + "homepage": "https://symfony.com", + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2020-12-08T16:59:59+00:00" + }, { "name": "theseer/fdomdocument", "version": "1.6.6", diff --git a/app/config/bundles.php b/app/config/bundles.php index 17ea616..3b0e9b9 100644 --- a/app/config/bundles.php +++ b/app/config/bundles.php @@ -2,6 +2,7 @@ return [ Symfony\Bundle\FrameworkBundle\FrameworkBundle::class => ['all' => true], + Symfony\Bundle\WebProfilerBundle\WebProfilerBundle::class => ['dev' => true, 'test' => true], Symfony\Bundle\TwigBundle\TwigBundle::class => ['all' => true], Symfony\Bundle\MonologBundle\MonologBundle::class => ['all' => true], Doctrine\Bundle\DoctrineCacheBundle\DoctrineCacheBundle::class => ['all' => true], diff --git a/app/config/packages/dev/web_profiler.yaml b/app/config/packages/dev/web_profiler.yaml new file mode 100644 index 0000000..e92166a --- /dev/null +++ b/app/config/packages/dev/web_profiler.yaml @@ -0,0 +1,6 @@ +web_profiler: + toolbar: true + intercept_redirects: false + +framework: + profiler: { only_exceptions: false } diff --git a/app/config/packages/test/web_profiler.yaml b/app/config/packages/test/web_profiler.yaml new file mode 100644 index 0000000..03752de --- /dev/null +++ b/app/config/packages/test/web_profiler.yaml @@ -0,0 +1,6 @@ +web_profiler: + toolbar: false + intercept_redirects: false + +framework: + profiler: { collect: false } diff --git a/app/config/routes/dev/web_profiler.yaml b/app/config/routes/dev/web_profiler.yaml new file mode 100644 index 0000000..c82beff --- /dev/null +++ b/app/config/routes/dev/web_profiler.yaml @@ -0,0 +1,7 @@ +web_profiler_wdt: + resource: '@WebProfilerBundle/Resources/config/routing/wdt.xml' + prefix: /_wdt + +web_profiler_profiler: + resource: '@WebProfilerBundle/Resources/config/routing/profiler.xml' + prefix: /_profiler diff --git a/app/src/Controller/Admin/PageAction.php b/app/src/Controller/Admin/PageAction.php index d7dd9fd..727c600 100644 --- a/app/src/Controller/Admin/PageAction.php +++ b/app/src/Controller/Admin/PageAction.php @@ -3,6 +3,7 @@ namespace App\Controller\Admin; +use App\Controller\Home\HomeAction; use App\Controller\Page\OutsideBroadcastsAction; use App\Controller\Page\PeopleAction; use App\Controller\Page\RequestsAction; @@ -22,7 +23,7 @@ class PageAction extends AbstractAdminController { private const RESERVED_URLS = [ - \App\Controller\Home\HomeAction::SPECIAL_PAGE_URL => 'Home', + HomeAction::SPECIAL_PAGE_URL => 'Home', AbstractSchedulesAction::SPECIAL_PAGE_URL => 'Programme Listings', RequestsAction::SPECIAL_PAGE_URL => 'Requests', SportsAction::SPECIAL_PAGE_URL => 'Sports', diff --git a/app/src/Controller/Admin/PagesAction.php b/app/src/Controller/Admin/PagesAction.php index 1fd9a25..f856c87 100644 --- a/app/src/Controller/Admin/PagesAction.php +++ b/app/src/Controller/Admin/PagesAction.php @@ -34,7 +34,7 @@ public function __invoke( } elseif ($request->get('new-page-title')) { $title = $request->get('new-page-title'); $pageId = $pageService->newPage($title); - return $this->redirect('/admin/pages/' . $pageId); + return $this->redirect('/admin/pages/' . $pageId->toString()); } elseif ($request->get('new-category-title')) { $title = $request->get('new-category-title'); $pageService->newPageCategory($title); diff --git a/app/src/Controller/Admin/PeopleAction.php b/app/src/Controller/Admin/PeopleAction.php index 3f4b6f5..33ad85c 100644 --- a/app/src/Controller/Admin/PeopleAction.php +++ b/app/src/Controller/Admin/PeopleAction.php @@ -26,7 +26,7 @@ public function __invoke( if ($request->get('new-person-name')) { $name = $request->get('new-person-name'); $personId = $peopleService->newPerson($name); - return $this->redirect('/admin/people/' . $personId); + return $this->redirect('/admin/people/' . $personId->toString()); } if ($request->get('delete-person')) { diff --git a/app/src/Controller/Admin/ShowsAction.php b/app/src/Controller/Admin/ShowsAction.php index 919f360..57ccc00 100644 --- a/app/src/Controller/Admin/ShowsAction.php +++ b/app/src/Controller/Admin/ShowsAction.php @@ -27,7 +27,7 @@ public function __invoke( if ($request->get('new-show-name')) { $name = $request->get('new-show-name'); $showId = $programmesService->newProgramme($name); - return $this->redirect('/admin/shows/' . $showId); + return $this->redirect('/admin/shows/' . $showId->toString()); } if ($request->get('delete-show')) { diff --git a/app/src/Service/PageService.php b/app/src/Service/PageService.php index 36b29c2..56ab516 100644 --- a/app/src/Service/PageService.php +++ b/app/src/Service/PageService.php @@ -125,7 +125,7 @@ public function updatePage( $entity->title = $title; $entity->urlPath = $url; $entity->htmlContent = $htmlContent; - $entity->order = $navPosition; + $entity->order = $navPosition ?? 0; $entity->category = $category; $this->entityManager->persist($entity); @@ -140,7 +140,7 @@ public function findAllUncategorised() ); } - public function newPage(string $title) + public function newPage(string $title): UuidInterface { $url = str_replace(' ', '-', strtolower($title)); $url = preg_replace('/[^a-z0-9-]/s', '', $url); @@ -155,6 +155,6 @@ public function newPage(string $title) $this->entityManager->persist($page); $this->entityManager->flush(); - return $page->pkid; + return $page->id; } } diff --git a/app/src/Service/PeopleService.php b/app/src/Service/PeopleService.php index c627159..c16ad5a 100644 --- a/app/src/Service/PeopleService.php +++ b/app/src/Service/PeopleService.php @@ -54,14 +54,14 @@ public function findForProgramme(Programme $programme): array ); } - public function newPerson(string $name): int + public function newPerson(string $name): UuidInterface { $page = new DbPerson($name); $this->entityManager->persist($page); $this->entityManager->flush(); - return $page->pkid; + return $page->id; } public function deletePerson(UuidInterface $programmeId): void diff --git a/app/src/Service/ProgrammesService.php b/app/src/Service/ProgrammesService.php index 49a71b5..7af5f2c 100644 --- a/app/src/Service/ProgrammesService.php +++ b/app/src/Service/ProgrammesService.php @@ -86,7 +86,7 @@ public function getAllByPeople(?Programme $exclude = null): array return $groupedResults; } - public function newProgramme(string $name, int $type = Programme::PROGRAMME_TYPE_REGULAR): int + public function newProgramme(string $name, int $type = Programme::PROGRAMME_TYPE_REGULAR): UuidInterface { $page = new DbProgramme( $name, @@ -96,7 +96,7 @@ public function newProgramme(string $name, int $type = Programme::PROGRAMME_TYPE $this->entityManager->persist($page); $this->entityManager->flush(); - return $page->pkid; + return $page->id; } public function deleteProgramme(UuidInterface $programmeId): void diff --git a/app/symfony.lock b/app/symfony.lock index 81d5f23..e6b2418 100644 --- a/app/symfony.lock +++ b/app/symfony.lock @@ -134,6 +134,9 @@ "phar-io/version": { "version": "1.0.1" }, + "php": { + "version": "7.1" + }, "phpdocumentor/reflection-common": { "version": "1.0.1" }, @@ -368,6 +371,9 @@ "symfony/polyfill-php80": { "version": "v1.18.1" }, + "symfony/profiler-pack": { + "version": "v1.0.5" + }, "symfony/property-access": { "version": "v4.1.0" }, @@ -437,6 +443,20 @@ "symfony/var-exporter": { "version": "v4.4.4" }, + "symfony/web-profiler-bundle": { + "version": "3.3", + "recipe": { + "repo": "github.com/symfony/recipes", + "branch": "master", + "version": "3.3", + "ref": "6bdfa1a95f6b2e677ab985cd1af2eae35d62e0f6" + }, + "files": [ + "config/packages/dev/web_profiler.yaml", + "config/packages/test/web_profiler.yaml", + "config/routes/dev/web_profiler.yaml" + ] + }, "symfony/yaml": { "version": "v4.0.8" },