import hiltes

This commit is contained in:
mmoeller
2023-02-06 10:11:39 +01:00
parent 991dd95e9d
commit 0c04e6da7c
24 changed files with 100882 additions and 563 deletions

View File

@@ -0,0 +1,66 @@
<?php
namespace App\Repository;
use App\Entity\Order;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;
/**
* @extends ServiceEntityRepository<Order>
*
* @method Order|null find($id, $lockMode = null, $lockVersion = null)
* @method Order|null findOneBy(array $criteria, array $orderBy = null)
* @method Order[] findAll()
* @method Order[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
*/
class OrderRepository extends ServiceEntityRepository
{
public function __construct(ManagerRegistry $registry)
{
parent::__construct($registry, Order::class);
}
public function save(Order $entity, bool $flush = false): void
{
$this->getEntityManager()->persist($entity);
if ($flush) {
$this->getEntityManager()->flush();
}
}
public function remove(Order $entity, bool $flush = false): void
{
$this->getEntityManager()->remove($entity);
if ($flush) {
$this->getEntityManager()->flush();
}
}
// /**
// * @return Order[] Returns an array of Order objects
// */
// public function findByExampleField($value): array
// {
// return $this->createQueryBuilder('o')
// ->andWhere('o.exampleField = :val')
// ->setParameter('val', $value)
// ->orderBy('o.id', 'ASC')
// ->setMaxResults(10)
// ->getQuery()
// ->getResult()
// ;
// }
// public function findOneBySomeField($value): ?Order
// {
// return $this->createQueryBuilder('o')
// ->andWhere('o.exampleField = :val')
// ->setParameter('val', $value)
// ->getQuery()
// ->getOneOrNullResult()
// ;
// }
}

View File

@@ -0,0 +1,69 @@
<?php
namespace App\Repository;
use App\Entity\Product;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;
/**
* @extends ServiceEntityRepository<Product>
*
* @method Product|null find($id, $lockMode = null, $lockVersion = null)
* @method Product|null findOneBy(array $criteria, array $orderBy = null)
* @method Product[] findAll()
* @method Product[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
*/
class ProductRepository extends ServiceEntityRepository
{
public function __construct(ManagerRegistry $registry)
{
parent::__construct($registry, Product::class);
}
public function save(Product $entity, bool $flush = false): void
{
$entity->setUpdateTime(new \DateTime());
$this->getEntityManager()->persist($entity);
if ($flush) {
$this->getEntityManager()->flush();
}
}
public function remove(Product $entity, bool $flush = false): void
{
$this->getEntityManager()->remove($entity);
if ($flush) {
$this->getEntityManager()->flush();
}
}
// /**
// * @return Product[] Returns an array of Product objects
// */
// public function findByExampleField($value): array
// {
// return $this->createQueryBuilder('p')
// ->andWhere('p.exampleField = :val')
// ->setParameter('val', $value)
// ->orderBy('p.id', 'ASC')
// ->setMaxResults(10)
// ->getQuery()
// ->getResult()
// ;
// }
// public function findOneBySomeField($value): ?Product
// {
// return $this->createQueryBuilder('p')
// ->andWhere('p.exampleField = :val')
// ->setParameter('val', $value)
// ->getQuery()
// ->getOneOrNullResult()
// ;
// }
}

View File

@@ -0,0 +1,66 @@
<?php
namespace App\Repository;
use App\Entity\Settings;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;
/**
* @extends ServiceEntityRepository<Settings>
*
* @method Settings|null find($id, $lockMode = null, $lockVersion = null)
* @method Settings|null findOneBy(array $criteria, array $orderBy = null)
* @method Settings[] findAll()
* @method Settings[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
*/
class SettingsRepository extends ServiceEntityRepository
{
public function __construct(ManagerRegistry $registry)
{
parent::__construct($registry, Settings::class);
}
public function save(Settings $entity, bool $flush = false): void
{
$this->getEntityManager()->persist($entity);
if ($flush) {
$this->getEntityManager()->flush();
}
}
public function remove(Settings $entity, bool $flush = false): void
{
$this->getEntityManager()->remove($entity);
if ($flush) {
$this->getEntityManager()->flush();
}
}
// /**
// * @return Settings[] Returns an array of Settings 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()
// ;
// }
// public function findOneBySomeField($value): ?Settings
// {
// return $this->createQueryBuilder('s')
// ->andWhere('s.exampleField = :val')
// ->setParameter('val', $value)
// ->getQuery()
// ->getOneOrNullResult()
// ;
// }
}

View File

@@ -3,7 +3,6 @@
namespace App\Repository;
use App\Entity\Stock;
use App\Entity\Warehouse;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;
@@ -22,7 +21,7 @@ class StockRepository extends ServiceEntityRepository
parent::__construct($registry, Stock::class);
}
public function add(Stock $entity, bool $flush = false): void
public function save(Stock $entity, bool $flush = false): void
{
$this->getEntityManager()->persist($entity);
@@ -31,57 +30,6 @@ 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());
$stock->setUpdateTime(new \DateTime('now'));
$this->getEntityManager()->flush();
}
/**
* @param Stock $entity
* @return void
*/
public function upsert(Stock $stock): void
{
//$stock = $this->findByGtin($entity->getGtin());
// $warehouse = $this->getEntityManager()->find(Warehouse::class, $stock->getWarehouseId());
// $stock->setWarehouse($warehouse);
//
// $this->getEntityManager()->persist($stock);
//
// $this->getEntityManager()->flush();
$s = $this->findOneBy([
'gtin' => $stock->getGtin(),
//'warehouse_id' => $stock->getWarehouseId()
]);
if ($s) {
// $stock->setStock($entity->getStock());
// $this->getEntityManager()->flush();
$this->update($stock,$s->getId());
}else{
$this->add($stock,true);
}
}
public function remove(Stock $entity, bool $flush = false): void
{
$this->getEntityManager()->remove($entity);
@@ -91,23 +39,20 @@ class StockRepository extends ServiceEntityRepository
}
}
/**
* @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()
;
}
// /**
// * @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()
// ;
// }
// public function findOneBySomeField($value): ?Stock
// {

View File

@@ -21,15 +21,13 @@ class WarehouseRepository extends ServiceEntityRepository
parent::__construct($registry, Warehouse::class);
}
public function add(Warehouse $entity, bool $flush = false): ?int
public function save(Warehouse $entity, bool $flush = false): void
{
$this->getEntityManager()->persist($entity);
if ($flush) {
$this->getEntityManager()->flush();
}
return $entity->getId();
}
public function remove(Warehouse $entity, bool $flush = false): void