1 | <?php |
||
2 | /** |
||
3 | * BunqJobConfiguration.php |
||
4 | * Copyright (c) 2019 [email protected] |
||
5 | * |
||
6 | * This file is part of Firefly III (https://github.com/firefly-iii). |
||
7 | * |
||
8 | * This program is free software: you can redistribute it and/or modify |
||
9 | * it under the terms of the GNU Affero General Public License as |
||
10 | * published by the Free Software Foundation, either version 3 of the |
||
11 | * License, or (at your option) any later version. |
||
12 | * |
||
13 | * This program is distributed in the hope that it will be useful, |
||
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||
16 | * GNU Affero General Public License for more details. |
||
17 | * |
||
18 | * You should have received a copy of the GNU Affero General Public License |
||
19 | * along with this program. If not, see <https://www.gnu.org/licenses/>. |
||
20 | */ |
||
21 | |||
22 | declare(strict_types=1); |
||
23 | |||
24 | namespace FireflyIII\Import\JobConfiguration; |
||
25 | |||
26 | use FireflyIII\Exceptions\FireflyException; |
||
27 | use FireflyIII\Models\ImportJob; |
||
28 | use FireflyIII\Repositories\ImportJob\ImportJobRepositoryInterface; |
||
29 | use FireflyIII\Support\Import\JobConfiguration\Bunq\BunqJobConfigurationInterface; |
||
30 | use FireflyIII\Support\Import\JobConfiguration\Bunq\ChooseAccountsHandler; |
||
31 | use FireflyIII\Support\Import\JobConfiguration\Bunq\NewBunqJobHandler; |
||
32 | use Illuminate\Support\MessageBag; |
||
33 | use Log; |
||
34 | |||
35 | /** |
||
36 | * Class BunqJobConfiguration |
||
37 | * |
||
38 | * @deprecated |
||
39 | * @codeCoverageIgnore |
||
40 | */ |
||
41 | class BunqJobConfiguration implements JobConfigurationInterface |
||
0 ignored issues
–
show
|
|||
42 | { |
||
43 | /** @var BunqJobConfigurationInterface Bunq job interface */ |
||
44 | private $handler; |
||
45 | /** @var ImportJob The import job */ |
||
46 | private $importJob; |
||
47 | /** @var ImportJobRepositoryInterface Import job repository */ |
||
48 | private $repository; |
||
49 | |||
50 | /** |
||
51 | * Returns true when the initial configuration for this job is complete. |
||
52 | * |
||
53 | * @return bool |
||
54 | */ |
||
55 | public function configurationComplete(): bool |
||
56 | { |
||
57 | return $this->handler->configurationComplete(); |
||
58 | } |
||
59 | |||
60 | /** |
||
61 | * Store any data from the $data array into the job. Anything in the message bag will be flashed |
||
62 | * as an error to the user, regardless of its content. |
||
63 | * |
||
64 | * @param array $data |
||
65 | * |
||
66 | * @return MessageBag |
||
67 | */ |
||
68 | public function configureJob(array $data): MessageBag |
||
69 | { |
||
70 | return $this->handler->configureJob($data); |
||
71 | } |
||
72 | |||
73 | /** |
||
74 | * Return the data required for the next step in the job configuration. |
||
75 | * |
||
76 | * @return array |
||
77 | */ |
||
78 | public function getNextData(): array |
||
79 | { |
||
80 | return $this->handler->getNextData(); |
||
81 | } |
||
82 | |||
83 | /** |
||
84 | * Returns the view of the next step in the job configuration. |
||
85 | * |
||
86 | * @return string |
||
87 | */ |
||
88 | public function getNextView(): string |
||
89 | { |
||
90 | return $this->handler->getNextView(); |
||
91 | } |
||
92 | |||
93 | /** |
||
94 | * Set import job. |
||
95 | * |
||
96 | * @param ImportJob $importJob |
||
97 | * |
||
98 | * @throws FireflyException |
||
99 | */ |
||
100 | public function setImportJob(ImportJob $importJob): void |
||
101 | { |
||
102 | $this->importJob = $importJob; |
||
103 | $this->repository = app(ImportJobRepositoryInterface::class); |
||
104 | $this->repository->setUser($importJob->user); |
||
105 | $this->handler = $this->getHandler(); |
||
106 | } |
||
107 | |||
108 | /** |
||
109 | * Get correct handler. |
||
110 | * |
||
111 | * @throws FireflyException |
||
112 | * @return BunqJobConfigurationInterface |
||
113 | */ |
||
114 | private function getHandler(): BunqJobConfigurationInterface |
||
115 | { |
||
116 | Log::debug(sprintf('Now in BunqJobConfiguration::getHandler() with stage "%s"', $this->importJob->stage)); |
||
117 | $handler = null; |
||
118 | switch ($this->importJob->stage) { |
||
119 | case 'new': |
||
120 | $handler = app(NewBunqJobHandler::class); |
||
121 | $handler->setImportJob($this->importJob); |
||
122 | break; |
||
123 | case 'choose-accounts': |
||
124 | /** @var ChooseAccountsHandler $handler */ |
||
125 | $handler = app(ChooseAccountsHandler::class); |
||
126 | $handler->setImportJob($this->importJob); |
||
127 | break; |
||
128 | default: |
||
129 | // @codeCoverageIgnoreStart |
||
130 | throw new FireflyException(sprintf('Firefly III cannot create a configuration handler for stage "%s"', $this->importJob->stage)); |
||
131 | // @codeCoverageIgnoreEnd |
||
132 | } |
||
133 | |||
134 | return $handler; |
||
135 | } |
||
136 | } |
||
137 |
This interface has been deprecated. The supplier of the interface has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the interface will be removed and what other interface to use instead.