import hiltes
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
mmoeller
2023-01-30 15:36:20 +01:00
parent d420c00036
commit 3493e038e3
31 changed files with 27498 additions and 20940 deletions

View File

@@ -30,6 +30,44 @@ class StockRepository extends ServiceEntityRepository
}
}
/**
* @param Stock $entity
* @param int $id
* @return void
*/
public function update(Stock $entity, string $id): void
{
$stock = $this->getEntityManager()->getRepository(Stock::class)->find($id);
if (!$stock) {
throw $this->createNotFoundException(
'No product found for id '.$id
);
}
$stock->setStock($entity->getStock());
$this->getEntityManager()->flush();
}
/**
* @param Stock $entity
* @return void
*/
public function upsert(Stock $entity): void
{
$stock = $this->findByGtin($entity->getGtin());
if ($stock) {
// $stock->setStock($entity->getStock());
// $this->getEntityManager()->flush();
$this->update($entity,$stock[0]->getId());
}else{
$this->add($entity,true);
}
}
public function remove(Stock $entity, bool $flush = false): void
{
$this->getEntityManager()->remove($entity);
@@ -39,20 +77,23 @@ class StockRepository extends ServiceEntityRepository
}
}
// /**
// * @return Stock[] Returns an array of Stock objects
// */
// public function findByExampleField($value): array
// {
// return $this->createQueryBuilder('s')
// ->andWhere('s.exampleField = :val')
// ->setParameter('val', $value)
// ->orderBy('s.id', 'ASC')
// ->setMaxResults(10)
// ->getQuery()
// ->getResult()
// ;
// }
/**
* @return Stock[] Returns an array of Stock objects
*/
public function findByGtin($value): array
{
return $this->createQueryBuilder('s')
->andWhere('s.gtin = :val')
->setParameter('val', $value)
->orderBy('s.id', 'ASC')
->setMaxResults(1)
->getQuery()
->getResult()
;
}
// public function findOneBySomeField($value): ?Stock
// {