Initial Build
This commit is contained in:
parent
71cd3acccd
commit
6c0d9a3f98
140 changed files with 9802 additions and 2403 deletions
47
src/Controller/FrontEnd/CategoryController.php
Normal file
47
src/Controller/FrontEnd/CategoryController.php
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
<?php
|
||||
|
||||
namespace App\Controller\FrontEnd;
|
||||
|
||||
use App\Entity\Category;
|
||||
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Routing\Attribute\Route;
|
||||
|
||||
final class CategoryController extends AbstractController
|
||||
{
|
||||
#[Route('/categories', name: 'front_end_category_list', priority: 1)]
|
||||
public function index(EntityManagerInterface $entityManager): Response
|
||||
{
|
||||
$categories = $entityManager->getRepository(Category::class)->findAll();
|
||||
|
||||
$categoriesDisplay = [];
|
||||
|
||||
foreach ($categories as $index => $category) {
|
||||
$categoriesDisplay[] = [
|
||||
'title' => $category->getTitle(),
|
||||
'urlSafeTitle' => strtolower(str_replace(' ', '-', $category->getTitle())),
|
||||
'count' => $category->getCount(),
|
||||
];
|
||||
}
|
||||
|
||||
return $this->render('front/category/index.html.twig', [
|
||||
'categories' => $categoriesDisplay
|
||||
]);
|
||||
}
|
||||
|
||||
#[Route('/categories/{categoryTitle}', name: 'front_end_category_detail')]
|
||||
public function detail(EntityManagerInterface $entityManager, string $categoryTitle): Response
|
||||
{
|
||||
$formattedTitle = ucwords(str_replace('-', ' ', $categoryTitle));
|
||||
$category = $entityManager->getRepository(Category::class)->findOneBy(['title' => $formattedTitle]);
|
||||
return $this->render('front/category/detail.html.twig', [
|
||||
'title' => $category->getTitle(),
|
||||
'posts' => $category->getPosts(),
|
||||
'photos' => $category->getPhotos(),
|
||||
'count' => $category->getCount()
|
||||
]);
|
||||
}
|
||||
}
|
||||
25
src/Controller/FrontEnd/FrontController.php
Normal file
25
src/Controller/FrontEnd/FrontController.php
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
<?php
|
||||
|
||||
namespace App\Controller\FrontEnd;
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Routing\Attribute\Route;
|
||||
|
||||
final class FrontController extends AbstractController
|
||||
{
|
||||
/**TODO Update so this is it's own type so i don't have to hardcode anything */
|
||||
#[Route('/', name: 'front_end_home')]
|
||||
public function index(): Response
|
||||
{
|
||||
return $this->render('front/home/index.html.twig', [
|
||||
|
||||
]);
|
||||
}
|
||||
|
||||
#[Route('/secret/styleguide', name: 'front_end_styleguide')]
|
||||
public function styleGuide(): Response
|
||||
{
|
||||
return $this->render('front/styleguide/styleguide.html.twig',[]);
|
||||
}
|
||||
}
|
||||
24
src/Controller/FrontEnd/PageController.php
Normal file
24
src/Controller/FrontEnd/PageController.php
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
<?php
|
||||
|
||||
namespace App\Controller\FrontEnd;
|
||||
|
||||
use App\Entity\Page;
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Routing\Attribute\Route;
|
||||
|
||||
final class PageController extends AbstractController
|
||||
{
|
||||
#[Route('/{url:page}', name: 'front_end_page')]
|
||||
public function index(Page $page): Response
|
||||
{
|
||||
if ($page->isPublished()) {
|
||||
return $this->render('front/page/index.html.twig', [
|
||||
'page' => $page
|
||||
]);
|
||||
}
|
||||
|
||||
return new Response('<h1>Page not found</h1>');
|
||||
}
|
||||
}
|
||||
69
src/Controller/FrontEnd/PhotosController.php
Normal file
69
src/Controller/FrontEnd/PhotosController.php
Normal file
|
|
@ -0,0 +1,69 @@
|
|||
<?php
|
||||
|
||||
namespace App\Controller\FrontEnd;
|
||||
|
||||
use App\Entity\Photos;
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Routing\Attribute\Route;
|
||||
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
|
||||
final class PhotosController extends AbstractController
|
||||
{
|
||||
#[Route('/photos', name: 'front_end_photos_list', priority: 1)]
|
||||
public function index(EntityManagerInterface $entityManager): Response
|
||||
{
|
||||
$photos = $entityManager->getRepository(Photos::class)->findAllOrderByLatest();
|
||||
|
||||
$albums = [];
|
||||
|
||||
foreach ($photos as $index => $photo) {
|
||||
$albums[] = [
|
||||
'title' => $photo->getTitle(),
|
||||
'date' => $photo->getDate(),
|
||||
'category' => $photo->getCategory()->getTitle(),
|
||||
'thumbnail' => 'photos/' . strtolower(str_replace(' ', '_', $photo->getTitle())) . '/' . $photo->getThumbnail(),
|
||||
'url' => $photo->getUrl(),
|
||||
];
|
||||
}
|
||||
|
||||
return $this->render('front/photos/index.html.twig', [
|
||||
'photos' => $albums
|
||||
]);
|
||||
}
|
||||
|
||||
#[Route('/photos/{url:photos}', name: 'front_end_photos_detail')]
|
||||
public function detail(Photos $photos): Response
|
||||
{
|
||||
$album = [];
|
||||
$uploads = $photos->getUploads();
|
||||
|
||||
$album = [
|
||||
'title' => $photos->getTitle(),
|
||||
'category' => $photos->getCategory()->getTitle(),
|
||||
'urlSafeCategory' => $photos->getCategory()->getUrlSafeTitle(),
|
||||
'text' => $photos->getText(),
|
||||
'date' => $photos->getDate()
|
||||
];
|
||||
|
||||
foreach ($uploads as $index => $upload) {
|
||||
$filePath = 'photos/' . strtolower(str_replace(' ', '_', $album['title'])) . '/' . $upload->getFile();
|
||||
|
||||
$album['uploads'][] = [
|
||||
'file' => $filePath,
|
||||
'alt' => $upload->getAltText(),
|
||||
'equipment' => $upload->getEquipment(),
|
||||
'caption' => $upload->getCaption(),
|
||||
'location' => $upload->getLocation(),
|
||||
'date' => $upload->getDate()
|
||||
];
|
||||
}
|
||||
|
||||
return $this->render('front/photos/detail.html.twig', [
|
||||
'photos' => $album
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
50
src/Controller/FrontEnd/PostController.php
Normal file
50
src/Controller/FrontEnd/PostController.php
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
<?php
|
||||
|
||||
namespace App\Controller\FrontEnd;
|
||||
|
||||
use App\Entity\Post;
|
||||
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Routing\Attribute\Route;
|
||||
|
||||
final class PostController extends AbstractController
|
||||
{
|
||||
/**TODO Update so this is it's own type so i don't have to hardcode anything */
|
||||
#[Route('/words', name: 'front_end_post_list', priority: 1)]
|
||||
public function index(EntityManagerInterface $entityManager): Response
|
||||
{
|
||||
$posts = $entityManager->getRepository(Post::class)->findAllOrderByLatest();
|
||||
|
||||
$formattedPosts = [];
|
||||
|
||||
foreach ($posts as $index => $post) {
|
||||
$formattedPosts [] = [
|
||||
'title' => $post->getTitle(),
|
||||
'category' => $post->getCategory()->getTitle(),
|
||||
'urlSafeCategory' => $post->getCategory()->getUrlSafeTitle(),
|
||||
'date' => $post->getDate(),
|
||||
'url' => $post->getUrl()
|
||||
];
|
||||
}
|
||||
|
||||
return $this->render('front/post/index.html.twig', [
|
||||
'posts' => $formattedPosts
|
||||
]);
|
||||
}
|
||||
|
||||
#[Route('/words/{url:post}', name: 'front_end_post_detail')]
|
||||
public function post(Post $post): Response
|
||||
{
|
||||
if ($post->isPublished()) {
|
||||
return $this->render('front/post/detail.html.twig', [
|
||||
'post' => $post,
|
||||
'urlSafeCategory' => $post->getCategory()->getUrlSafeTitle()
|
||||
]);
|
||||
}
|
||||
|
||||
return new Response('<h1>Page not found</h1>');
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue