thebadspace/src/Controller/Routes/Front/Index.php

82 lines
2.4 KiB
PHP
Raw Normal View History

<?php
// src/Controller/DataImport.php
// Grab data from transfer app
namespace App\Controller\Routes\Front;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use App\Service\Auth;
use App\Service\Render;
use App\Service\HandleLocations;
class Index extends AbstractController
{
/**
* @Route("/", name="index")
*/
public function showIndex(Request $request, Auth $auth, Render $render, HandleLocations $locations): Response
{
$list = $locations->getActiveLocations();
if ($request->getMethod() == "GET") {
return $render->page(["count" => count($list)], "This is The Bad Space", "front/index.twig");
} else {
$results = $locations->searchLocations($request->request->get("index_search"));
return $render->page(
["count" => count($list),
"items" => $results['items'],
"terms" => $results["terms"]
],
"This is The Bad Space",
"front/index.twig"
);
};
}
/**
* @Route("/location/{uuid}", name="front-location")
*/
public function showLocations(
Request $request,
Render $render,
HandleLocations $locations,
string $uuid = "none"
): Response {
$location = $locations->getLocationbyUUID($uuid);
return $render->page(
["location" => $location[0]],
"The Bad Space | " . $location[0]->getName(),
"front/location.twig"
);
}
/**
* @Route("/about", name="about")
*/
public function showAbout(
Request $request,
Auth $auth,
Render $render,
HandleLocations $locations
): Response {
return $render->page([], "About The Bad Space", "front/about.twig");
}
/**
* @Route("/listings/page/{pageNum}", name="listings")
*/
public function showListing(
Request $request,
Auth $auth,
Render $render,
HandleLocations $locations,
string $pageNum
): Response {
$list = $locations->getLocationsPage($pageNum, "true");
return $render->page(["list" => $list, "page" => $pageNum], "About The Bad Space", "front/listing.twig");
}
}