. */ declare(strict_types=1); namespace FireflyIII\Support\Binder; use FireflyIII\Enums\TransactionTypeEnum; use FireflyIII\Helpers\Collector\GroupCollectorInterface; use Illuminate\Routing\Route; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; /** * Class JournalList. */ class JournalList implements BinderInterface { /** * @throws NotFoundHttpException */ public static function routeBinder(string $value, Route $route): array { if (auth()->check()) { $list = self::parseList($value); // get the journals by using the collector. /** @var GroupCollectorInterface $collector */ $collector = app(GroupCollectorInterface::class); $collector->setTypes([TransactionTypeEnum::WITHDRAWAL->value, TransactionTypeEnum::DEPOSIT->value, TransactionTypeEnum::TRANSFER->value, TransactionTypeEnum::RECONCILIATION->value]); $collector->withCategoryInformation()->withBudgetInformation()->withTagInformation()->withAccountInformation(); $collector->setJournalIds($list); $result = $collector->getExtractedJournals(); if (0 === count($result)) { throw new NotFoundHttpException(); } return $result; } throw new NotFoundHttpException(); } protected static function parseList(string $value): array { $list = array_unique(array_map('\intval', explode(',', $value))); if (0 === count($list)) { // @phpstan-ignore-line throw new NotFoundHttpException(); } return $list; } }