Skip to content

Commit

Permalink
Fix bugs with creating new items and updating pages
Browse files Browse the repository at this point in the history
  • Loading branch information
djmarland committed Jan 2, 2021
1 parent 920aca7 commit 948bf69
Show file tree
Hide file tree
Showing 15 changed files with 134 additions and 14 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
4 changes: 3 additions & 1 deletion app/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
79 changes: 78 additions & 1 deletion app/composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions app/config/bundles.php
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand Down
6 changes: 6 additions & 0 deletions app/config/packages/dev/web_profiler.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
web_profiler:
toolbar: true
intercept_redirects: false

framework:
profiler: { only_exceptions: false }
6 changes: 6 additions & 0 deletions app/config/packages/test/web_profiler.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
web_profiler:
toolbar: false
intercept_redirects: false

framework:
profiler: { collect: false }
7 changes: 7 additions & 0 deletions app/config/routes/dev/web_profiler.yaml
Original file line number Diff line number Diff line change
@@ -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
3 changes: 2 additions & 1 deletion app/src/Controller/Admin/PageAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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',
Expand Down
2 changes: 1 addition & 1 deletion app/src/Controller/Admin/PagesAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion app/src/Controller/Admin/PeopleAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -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')) {
Expand Down
2 changes: 1 addition & 1 deletion app/src/Controller/Admin/ShowsAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -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')) {
Expand Down
6 changes: 3 additions & 3 deletions app/src/Service/PageService.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -155,6 +155,6 @@ public function newPage(string $title)
$this->entityManager->persist($page);
$this->entityManager->flush();

return $page->pkid;
return $page->id;
}
}
4 changes: 2 additions & 2 deletions app/src/Service/PeopleService.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions app/src/Service/ProgrammesService.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
Expand Down
20 changes: 20 additions & 0 deletions app/symfony.lock
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,9 @@
"phar-io/version": {
"version": "1.0.1"
},
"php": {
"version": "7.1"
},
"phpdocumentor/reflection-common": {
"version": "1.0.1"
},
Expand Down Expand Up @@ -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"
},
Expand Down Expand Up @@ -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"
},
Expand Down

0 comments on commit 948bf69

Please sign in to comment.