mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2026-01-20 17:19:34 +00:00
replaced unnecessary double quotes
This commit is contained in:
parent
358b66e62d
commit
ed1076fa5a
1 changed files with 10 additions and 10 deletions
|
|
@ -75,31 +75,31 @@ class InfoProviderController extends AbstractController
|
|||
private function matchResultsToKnownParts(array $partsList): array
|
||||
{
|
||||
//we need a manufacturer object to look for a manufacturer
|
||||
$manufacturerQb = $this->em->getRepository(Manufacturer::class)->createQueryBuilder("manufacturer");
|
||||
$manufacturerQb->where($manufacturerQb->expr()->like("LOWER(manufacturer.name)", "LOWER(:manufacturer_name)"));
|
||||
$manufacturerQb = $this->em->getRepository(Manufacturer::class)->createQueryBuilder('manufacturer');
|
||||
$manufacturerQb->where($manufacturerQb->expr()->like('LOWER(manufacturer.name)', 'LOWER(:manufacturer_name)'));
|
||||
|
||||
|
||||
//check if both manufacturer and Manufacturer part namber matches. If so, it must be the same part
|
||||
//use LOWER to make the search independent of case
|
||||
$mpnQb = $this->em->getRepository(Part::class)->createQueryBuilder("part");
|
||||
$mpnQb->where($mpnQb->expr()->like("LOWER(part.manufacturer_product_number)", "LOWER(:mpn)"));
|
||||
$mpnQb->andWhere($mpnQb->expr()->eq("part.manufacturer", ":manufacturer"));
|
||||
$mpnQb = $this->em->getRepository(Part::class)->createQueryBuilder('part');
|
||||
$mpnQb->where($mpnQb->expr()->like('LOWER(part.manufacturer_product_number)', 'LOWER(:mpn)'));
|
||||
$mpnQb->andWhere($mpnQb->expr()->eq('part.manufacturer', ':manufacturer'));
|
||||
|
||||
foreach ($partsList as $index => $part) {
|
||||
$manufacturerQb->setParameter("manufacturer_name", $part["dto"]->manufacturer);
|
||||
$manufacturerQb->setParameter('manufacturer_name', $part['dto']->manufacturer);
|
||||
$manufacturers = $manufacturerQb->getQuery()->getResult();
|
||||
if(!$manufacturers) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$mpnQb->setParameter("manufacturer", $manufacturers);
|
||||
$mpnQb->setParameter("mpn", $part["dto"]->mpn);
|
||||
$mpnQb->setParameter('manufacturer', $manufacturers);
|
||||
$mpnQb->setParameter('mpn', $part['dto']->mpn);
|
||||
$localParts = $mpnQb->getQuery()->getResult();
|
||||
if(!$localParts) {
|
||||
continue;
|
||||
}
|
||||
//We only use the first matching part. If a user already has duplicate parts they will get a random one
|
||||
$partsList[$index]["localPart"] = $localParts[0];
|
||||
$partsList[$index]['localPart'] = $localParts[0];
|
||||
}
|
||||
return $partsList;
|
||||
}
|
||||
|
|
@ -136,7 +136,7 @@ class InfoProviderController extends AbstractController
|
|||
// modify the array to an array of arrays that has a field for a matching local Part
|
||||
// the advantage to use that format even when we don't look for local parts is that we
|
||||
// always work with the same interface
|
||||
$results = array_map(function ($result) {return ["dto" => $result,"localPart" => null];}, $results);
|
||||
$results = array_map(function ($result) {return ['dto' => $result, 'localPart' => null];}, $results);
|
||||
if(!$update_target) {
|
||||
$results = $this->matchResultsToKnownParts($results);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue