Added LBC and note reference retrieval

Convert get-reference to retrieve data from database instead of files
Fixed error with saving new note
This commit is contained in:
Ryan Prather 2024-05-26 22:43:56 -04:00
parent 435402ee41
commit a20caf1fc8

View File

@ -166,6 +166,7 @@ class AjaxController extends AbstractController
}
ReferenceController::$emi = $emi;
$user = $this->getUser();
$ret = match(strtolower($data->type)) {
'bible' => ReferenceController::retrieveBible("{$data->book} {$search}"),
@ -175,7 +176,9 @@ class AjaxController extends AbstractController
'wcf' => ReferenceController::retrieveWCF($ref),
'wsc' => ReferenceController::retrieveWSC($ref),
'wlc' => ReferenceController::retrieveWLC($ref),
'creed' => ReferenceController::retrieveCreed($data->book)
'lbc' => ReferenceController::retrieveLBC($ref),
'creed' => ReferenceController::retrieveCreed($data->book),
'note' => ReferenceController::retrieveNote($user)
};
if (!is_a($ret, Reference::class)) {
@ -195,19 +198,12 @@ class AjaxController extends AbstractController
{
$res = new Response();
$data = json_decode($req->getContent());
$ret = match ($data->type) {
'creed' => '/Creeds/',
'bc' => '/Belgic/',
'hc' => '/Heidelberg/',
'cd' => '/Dort/',
'wcf' => '/Westminster/Confessions/',
'wsc' => '/Westminster/Shorter Catechism/',
'wlc' => '/Westminster/Larger Catechism/'
};
$ref = $emi->getRepository(Reference::class)->find($data->file);
$fc = file_get_contents(dirname(dirname(__DIR__))."/references{$ret}{$data->file}");
$res->setContent(json_encode(['text' => $fc]));
if (!is_a($ref, Reference::class)) {
$ref = new Reference();
}
$res->setContent(json_encode(['text' => $ref->getContent()]));
return $res;
}
@ -274,6 +270,10 @@ class AjaxController extends AbstractController
if (is_array($note) && count($note) > 0) {
/** @var Note $note */
$note = $note[0];
} else {
$note = new Note();
$newNote = true;
$note->setUser($this->getUser());
}
} else {
$note = new Note();
@ -293,6 +293,7 @@ class AjaxController extends AbstractController
->setSpeaker($speaker)
->setText($data->note)
->setPassage($data->passage)
->setRecording($data->recording)
->setRefs($refs);
$emi->persist($note);