1 | <?php |
||
2 | /** |
||
3 | * DeleteController.php |
||
4 | * Copyright (c) 2018 [email protected] |
||
5 | * |
||
6 | * This file is part of Firefly III. |
||
7 | * |
||
8 | * Firefly III is free software: you can redistribute it and/or modify |
||
9 | * it under the terms of the GNU General Public License as published by |
||
10 | * the Free Software Foundation, either version 3 of the License, or |
||
11 | * (at your option) any later version. |
||
12 | * |
||
13 | * Firefly III 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 General Public License for more details. |
||
17 | * |
||
18 | * You should have received a copy of the GNU General Public License |
||
19 | * along with Firefly III. If not, see <http://www.gnu.org/licenses/>. |
||
20 | */ |
||
21 | |||
22 | declare(strict_types=1); |
||
23 | |||
24 | namespace FireflyIII\Http\Controllers\Account; |
||
25 | |||
26 | |||
27 | use FireflyIII\Http\Controllers\Controller; |
||
28 | use FireflyIII\Models\Account; |
||
29 | use FireflyIII\Repositories\Account\AccountRepositoryInterface; |
||
30 | use Illuminate\Http\Request; |
||
31 | |||
32 | /** |
||
33 | * Class DeleteController |
||
34 | */ |
||
35 | class DeleteController extends Controller |
||
36 | { |
||
37 | /** @var AccountRepositoryInterface The account repository */ |
||
38 | private $repository; |
||
39 | |||
40 | /** |
||
41 | * DeleteController constructor. |
||
42 | * @codeCoverageIgnore |
||
43 | */ |
||
44 | public function __construct() |
||
45 | { |
||
46 | parent::__construct(); |
||
47 | |||
48 | // translations: |
||
49 | $this->middleware( |
||
50 | function ($request, $next) { |
||
51 | app('view')->share('mainTitleIcon', 'fa-credit-card'); |
||
52 | app('view')->share('title', (string)trans('firefly.accounts')); |
||
53 | |||
54 | $this->repository = app(AccountRepositoryInterface::class); |
||
55 | |||
56 | return $next($request); |
||
57 | } |
||
58 | ); |
||
59 | } |
||
60 | |||
61 | /** |
||
62 | * Delete account screen. |
||
63 | * |
||
64 | * @param Account $account |
||
65 | * |
||
66 | * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View |
||
67 | */ |
||
68 | public function delete(Account $account) |
||
69 | { |
||
70 | $typeName = config(sprintf('firefly.shortNamesByFullName.%s', $account->accountType->type)); |
||
71 | $subTitle = (string)trans(sprintf('firefly.delete_%s_account', $typeName), ['name' => $account->name]); |
||
72 | $accountList = app('expandedform')->makeSelectListWithEmpty($this->repository->getAccountsByType([$account->accountType->type])); |
||
0 ignored issues
–
show
|
|||
73 | $objectType = $typeName; |
||
74 | unset($accountList[$account->id]); |
||
75 | |||
76 | // put previous url in session |
||
77 | $this->rememberPreviousUri('accounts.delete.uri'); |
||
78 | |||
79 | return view('accounts.delete', compact('account', 'subTitle', 'accountList', 'objectType')); |
||
80 | } |
||
81 | |||
82 | /** |
||
83 | * Delete the account. |
||
84 | * |
||
85 | * @param Request $request |
||
86 | * @param Account $account |
||
87 | * |
||
88 | * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector |
||
89 | */ |
||
90 | public function destroy(Request $request, Account $account) |
||
91 | { |
||
92 | $type = $account->accountType->type; |
||
93 | $typeName = config(sprintf('firefly.shortNamesByFullName.%s', $type)); |
||
94 | $name = $account->name; |
||
95 | $moveTo = $this->repository->findNull((int)$request->get('move_account_before_delete')); |
||
96 | |||
97 | $this->repository->destroy($account, $moveTo); |
||
98 | |||
99 | $request->session()->flash('success', (string)trans(sprintf('firefly.%s_deleted', $typeName), ['name' => $name])); |
||
100 | app('preferences')->mark(); |
||
101 | |||
102 | return redirect($this->getPreviousUri('accounts.delete.uri')); |
||
103 | } |
||
104 | |||
105 | } |
||
106 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.