Conditions | 2 |
Paths | 1 |
Total Lines | 25 |
Code Lines | 14 |
Lines | 0 |
Ratio | 0 % |
Tests | 9 |
CRAP Score | 2.2559 |
Changes | 0 |
1 | <?php |
||
16 | 1 | public static function build(): array |
|
17 | { |
||
18 | 1 | return [ |
|
19 | 1 | 'name' => 'exportAccountingReport', |
|
20 | 1 | 'type' => Type::nonNull(Type::string()), |
|
21 | 1 | 'description' => 'Prepare an accounting report and return the URL to download it', |
|
22 | 1 | 'args' => [ |
|
23 | 1 | 'date' => _types()->get('Date'), |
|
24 | 1 | ], |
|
25 | 1 | 'resolve' => function ($root, array $args, SessionInterface $session): string { |
|
26 | global $container; |
||
27 | |||
28 | /** @var AccountingReport $exporter */ |
||
29 | $exporter = $container->get(AccountingReport::class); |
||
30 | |||
31 | if ($args['date']) { |
||
32 | $exporter->setDate($args['date']); |
||
33 | } |
||
34 | |||
35 | // Select root accounts |
||
36 | /** @var AccountRepository $accountRepository */ |
||
37 | $accountRepository = _em()->getRepository(Account::class); |
||
38 | $rootAccountsQuery = $accountRepository->getRootAccountsQuery(); |
||
39 | |||
40 | return $exporter->export($rootAccountsQuery->getResult()); |
||
|
|||
41 | 1 | }, |
|
45 |