-
-
Notifications
You must be signed in to change notification settings - Fork 94
Expand file tree
/
Copy pathMassInvoicesCreator.php
More file actions
45 lines (37 loc) · 1.21 KB
/
MassInvoicesCreator.php
File metadata and controls
45 lines (37 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<?php
/*
* This file is part of the Sylius package.
*
* (c) Paweł Jędrzejewski
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Sylius\InvoicingPlugin\Creator;
use Sylius\Component\Core\Model\OrderInterface;
use Sylius\InvoicingPlugin\DateTimeProvider;
use Sylius\InvoicingPlugin\Exception\InvoiceAlreadyGenerated;
final class MassInvoicesCreator implements MassInvoicesCreatorInterface
{
private InvoiceCreatorInterface $invoiceCreator;
private DateTimeProvider $dateTimeProvider;
public function __construct(
InvoiceCreatorInterface $invoiceCreator,
DateTimeProvider $dateTimeProvider
) {
$this->invoiceCreator = $invoiceCreator;
$this->dateTimeProvider = $dateTimeProvider;
}
public function __invoke(array $orders): void
{
/** @var OrderInterface $order */
foreach ($orders as $order) {
try {
$this->invoiceCreator->__invoke($order->getId(), $this->dateTimeProvider->__invoke());
} catch (InvoiceAlreadyGenerated $exception) {
continue;
}
}
}
}