mirror of
https://koodu.h-i.works/projects/thebadspace
synced 2025-06-25 16:04:37 -05:00
Turned on Index search
Activated the full text search on the index pages as well as plugging in a tempalte to show location information. Still needs to be styled but it's all wired up. Also cleaned some typos in the About description. One day I'll be able to spell. One day.
This commit is contained in:
@ -11,6 +11,7 @@ use Exception;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Symfony\Component\HttpFoundation\RequestStack;
|
||||
use Symfony\Component\Uid\Uuid;
|
||||
use Doctrine\DBAL\Connection;
|
||||
use App\Entity\Location;
|
||||
use League\Csv\Reader;
|
||||
|
||||
@ -25,16 +26,59 @@ class HandleLocations
|
||||
{
|
||||
private $session;
|
||||
private $entityManager;
|
||||
private $conn;
|
||||
private $limit = 4;
|
||||
|
||||
public function __construct(
|
||||
Connection $connection,
|
||||
EntityManagerInterface $entityManager,
|
||||
RequestStack $requestStack
|
||||
) {
|
||||
$this->connection = $connection;
|
||||
$this->entityManager = $entityManager;
|
||||
$this->session = $requestStack->getSession();
|
||||
}
|
||||
|
||||
public function searchLocations(string $terms)
|
||||
{
|
||||
$errorMessage = null;
|
||||
$response = null;
|
||||
//$utils = new StringTools();
|
||||
//$term = $utils->removeCommonWords($terms);
|
||||
$terms = str_replace(",", "", $terms);
|
||||
$terms = str_replace(" ", "|", $terms);
|
||||
|
||||
try {
|
||||
$search = $this->connection->fetchAllAssociative("SELECT * FROM searchlocations('$terms')");
|
||||
} catch (PDOException $error) {
|
||||
$errorMessage = $error->getMessage();
|
||||
} catch (DBALException $error) {
|
||||
$errorMessage = $error->getMessage();
|
||||
} catch (ORMException $error) {
|
||||
$errorMessage = $error->getMessage();
|
||||
} catch (Exception $error) {
|
||||
$errorMessage = $error->getMessage();
|
||||
} catch (SyntaxErrorException $error) {
|
||||
$errorMessage = $error->getMessage();
|
||||
}
|
||||
|
||||
if ($errorMessage != null) {
|
||||
$response = [
|
||||
"status" => false,
|
||||
"message" => $errorMessage,
|
||||
];
|
||||
} else {
|
||||
$response = [
|
||||
"status" => true,
|
||||
"message" => "Good Reqeust",
|
||||
"items" => $search,
|
||||
"terms" => $terms,
|
||||
];
|
||||
}
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
public function getActiveLocations()
|
||||
{
|
||||
$listings = $this->entityManager->getRepository(Location::class);
|
||||
|
Reference in New Issue
Block a user