add methods to retrieve new references

This commit is contained in:
Ryan Prather 2024-05-29 00:35:42 -04:00
parent 53e5c48aa9
commit ea60cf2622

View File

@ -146,6 +146,9 @@ class ReferenceController extends AbstractController
public static function retrieveWSC($ref): Reference public static function retrieveWSC($ref): Reference
{ {
$r = self::$emi->getRepository(Reference::class)->findBy(['type' => $ref->getType(), 'ndx' => $ref->getNdx()]); $r = self::$emi->getRepository(Reference::class)->findBy(['type' => $ref->getType(), 'ndx' => $ref->getNdx()]);
if (!$r) {
return new Reference();
}
return $r[0]; return $r[0];
} }
@ -159,6 +162,9 @@ class ReferenceController extends AbstractController
public static function retrieveWLC($ref): Reference public static function retrieveWLC($ref): Reference
{ {
$r = self::$emi->getRepository(Reference::class)->findBy(['type' => $ref->getType(), 'ndx' => $ref->getNdx()]); $r = self::$emi->getRepository(Reference::class)->findBy(['type' => $ref->getType(), 'ndx' => $ref->getNdx()]);
if (!$r) {
return new Reference();
}
return $r[0]; return $r[0];
} }
@ -172,12 +178,54 @@ class ReferenceController extends AbstractController
public static function retrieveWCF($ref): Reference public static function retrieveWCF($ref): Reference
{ {
$r = self::$emi->getRepository(Reference::class)->findBy(['type' => $ref->getType(), 'ndx' => $ref->getNdx()]); $r = self::$emi->getRepository(Reference::class)->findBy(['type' => $ref->getType(), 'ndx' => $ref->getNdx()]);
if (!$r) {
return new Reference();
}
return $r[0]; return $r[0];
} }
public static function retrieveLBC($ref): Reference public static function retrieveLBC($ref): Reference
{ {
$r = self::$emi->getRepository(Reference::class)->findBy(['type' => 'lbc', 'ndx' => $ref->getNdx()]); $r = self::$emi->getRepository(Reference::class)->findBy(['type' => 'lbc', 'ndx' => $ref->getNdx()]);
if (!$r) {
return new Reference();
}
return $r[0];
}
public static function retrieveAGC($ref): Reference
{
$r = self::$emi->getRepository(Reference::class)->findBy(['type' => 'agc', 'ndx' => $ref->getNdx()]);
if (!$r) {
return new Reference();
}
return $r[0];
}
public static function retrieve1HC($ref): Reference
{
$r = self::$emi->getRepository(Reference::class)->findBy(['type' => '1hc', 'ndx' => $ref->getNdx()]);
if (!$r) {
return new Reference();
}
return $r[0];
}
public static function retrieve2HC($ref): Reference
{
$r = self::$emi->getRepository(Reference::class)->findBy(['type' => '2hc', 'ndx' => $ref->getNdx()]);
if (!$r) {
return new Reference();
}
return $r[0];
}
public static function retrieveSD($ref): Reference
{
$r = self::$emi->getRepository(Reference::class)->findBy(['type' => 'sd', 'ndx' => $ref->getNdx()]);
if (!$r) {
return new Reference();
}
return $r[0]; return $r[0];
} }
@ -186,4 +234,14 @@ class ReferenceController extends AbstractController
$notes = self::$emi->getRepository(Note::class)->findBy(['user' => $user], ['date' => 'DESC']); $notes = self::$emi->getRepository(Note::class)->findBy(['user' => $user], ['date' => 'DESC']);
return $notes; return $notes;
} }
#[Route('/reference/{type}', name: 'app_reference_by_type', methods: ['GET'])]
public function retrieveReferenceByType(string $type, EntityManagerInterface $emi): Response
{
$res = new Response();
$data = $emi->getRepository(Reference::class)->findByType($type);
$res->setContent(json_encode($data));
return $res;
}
} }