allow custom export repositories (#2182)
This commit is contained in:
@@ -14,20 +14,20 @@ class ExportQuery extends TimesheetQuery
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $type;
|
||||
private $renderer;
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
private $markAsExported = false;
|
||||
|
||||
public function getType(): ?string
|
||||
public function getRenderer(): ?string
|
||||
{
|
||||
return $this->type;
|
||||
return $this->renderer;
|
||||
}
|
||||
|
||||
public function setType(string $type): ExportQuery
|
||||
public function setRenderer(string $renderer): ExportQuery
|
||||
{
|
||||
$this->type = $type;
|
||||
$this->renderer = $renderer;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
@@ -36,16 +36,22 @@ final class TimesheetInvoiceItemRepository implements InvoiceItemRepositoryInter
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Timesheet[] $invoiceItems
|
||||
* @param InvoiceItemInterface[] $invoiceItems
|
||||
*/
|
||||
public function setExported(array $invoiceItems)
|
||||
{
|
||||
$timesheets = [];
|
||||
|
||||
foreach ($invoiceItems as $item) {
|
||||
if (!$item instanceof Timesheet) {
|
||||
throw new \InvalidArgumentException('TimesheetInvoiceItemRepository only supports Timesheet entities');
|
||||
if ($item instanceof Timesheet) {
|
||||
$timesheets[] = $item;
|
||||
}
|
||||
}
|
||||
|
||||
$this->repository->setExported($invoiceItems);
|
||||
if (empty($timesheets)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->repository->setExported($timesheets);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -957,17 +957,21 @@ class TimesheetRepository extends EntityRepository
|
||||
$em = $this->getEntityManager();
|
||||
$em->beginTransaction();
|
||||
|
||||
$qb = $em->createQueryBuilder();
|
||||
$qb
|
||||
->update(Timesheet::class, 't')
|
||||
->set('t.exported', ':exported')
|
||||
->where($qb->expr()->in('t.id', ':ids'))
|
||||
->setParameter('exported', true, PDO::PARAM_BOOL)
|
||||
->setParameter('ids', $timesheets)
|
||||
->getQuery()
|
||||
->execute();
|
||||
try {
|
||||
$qb = $em->createQueryBuilder();
|
||||
$qb
|
||||
->update(Timesheet::class, 't')
|
||||
->set('t.exported', ':exported')
|
||||
->where($qb->expr()->in('t.id', ':ids'))
|
||||
->setParameter('exported', true, PDO::PARAM_BOOL)
|
||||
->setParameter('ids', $timesheets)
|
||||
->getQuery()
|
||||
->execute();
|
||||
|
||||
$em->commit();
|
||||
$em->commit();
|
||||
} catch (\Exception $ex) {
|
||||
$em->rollback();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user