1 | <?php |
||
2 | |||
3 | /** |
||
4 | * webtrees: online genealogy |
||
5 | * Copyright (C) 2023 webtrees development team |
||
6 | * This program is free software: you can redistribute it and/or modify |
||
7 | * it under the terms of the GNU General Public License as published by |
||
8 | * the Free Software Foundation, either version 3 of the License, or |
||
9 | * (at your option) any later version. |
||
10 | * This program is distributed in the hope that it will be useful, |
||
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||
13 | * GNU General Public License for more details. |
||
14 | * You should have received a copy of the GNU General Public License |
||
15 | * along with this program. If not, see <https://www.gnu.org/licenses/>. |
||
16 | */ |
||
17 | |||
18 | declare(strict_types=1); |
||
19 | |||
20 | namespace Fisharebest\Webtrees\Cli\Commands; |
||
21 | |||
22 | use Fisharebest\Webtrees\Contracts\TreeInterface; |
||
0 ignored issues
–
show
|
|||
23 | use Fisharebest\Webtrees\DB; |
||
24 | use Fisharebest\Webtrees\Services\TreeService; |
||
25 | use Symfony\Component\Console\Command\Command; |
||
26 | use Symfony\Component\Console\Input\InputInterface; |
||
27 | use Symfony\Component\Console\Input\InputOption; |
||
28 | use Symfony\Component\Console\Output\OutputInterface; |
||
29 | use Symfony\Component\Console\Style\SymfonyStyle; |
||
30 | |||
31 | use function bin2hex; |
||
32 | use function random_bytes; |
||
33 | |||
34 | class TreeCreate extends Command |
||
35 | { |
||
36 | public function __construct(private readonly TreeService $tree_service) |
||
37 | { |
||
38 | parent::__construct(); |
||
39 | } |
||
40 | |||
41 | protected function configure(): void |
||
42 | { |
||
43 | $this |
||
44 | ->setName(name: 'tree-create') |
||
45 | ->setDescription(description: 'Create a new tree') |
||
46 | ->addOption(name: 'name', shortcut: null, mode: InputOption::VALUE_REQUIRED, description: 'The name of the new tree') |
||
47 | ->addOption(name: 'title', shortcut: null, mode: InputOption::VALUE_REQUIRED, description: 'The title of the new tree'); |
||
48 | } |
||
49 | |||
50 | protected function execute(InputInterface $input, OutputInterface $output): int |
||
51 | { |
||
52 | $io = new SymfonyStyle(input: $input, output: $output); |
||
53 | |||
54 | $name = $input->getOption(name: 'name'); |
||
55 | $title = $input->getOption(name: 'title'); |
||
56 | |||
57 | $missing = false; |
||
58 | |||
59 | if ($name === null) { |
||
60 | $io->error(message: 'Missing required option: --name'); |
||
61 | $missing = true; |
||
62 | } |
||
63 | |||
64 | if ($title === null) { |
||
65 | $io->error(message: 'Missing required option: --title'); |
||
66 | $missing = true; |
||
67 | } |
||
68 | |||
69 | if ($missing) { |
||
70 | return Command::INVALID; |
||
71 | } |
||
72 | |||
73 | $tree = $this->tree_service->all()[$name] ?? null; |
||
74 | |||
75 | if ($tree !== null) { |
||
76 | $io->error(message: 'A tree with the name "' . $name . '" already exists.'); |
||
77 | |||
78 | return Command::FAILURE; |
||
79 | } |
||
80 | |||
81 | $tree = $this->tree_service->create(name: $name, title: $title); |
||
0 ignored issues
–
show
|
|||
82 | |||
83 | DB::exec(sql: 'COMMIT'); |
||
84 | |||
85 | return Command::SUCCESS; |
||
86 | } |
||
87 | } |
||
88 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths