@@ -33,61 +33,61 @@ |
||
33 | 33 | use Symfony\Component\Console\Output\OutputInterface; |
34 | 34 | |
35 | 35 | class MigrateCommand extends Command implements CompletionAwareInterface { |
36 | - public function __construct( |
|
37 | - private Connection $connection, |
|
38 | - ) { |
|
39 | - parent::__construct(); |
|
40 | - } |
|
36 | + public function __construct( |
|
37 | + private Connection $connection, |
|
38 | + ) { |
|
39 | + parent::__construct(); |
|
40 | + } |
|
41 | 41 | |
42 | - protected function configure() { |
|
43 | - $this |
|
44 | - ->setName('migrations:migrate') |
|
45 | - ->setDescription('Execute a migration to a specified version or the latest available version.') |
|
46 | - ->addArgument('app', InputArgument::REQUIRED, 'Name of the app this migration command shall work on') |
|
47 | - ->addArgument('version', InputArgument::OPTIONAL, 'The version number (YYYYMMDDHHMMSS) or alias (first, prev, next, latest) to migrate to.', 'latest'); |
|
42 | + protected function configure() { |
|
43 | + $this |
|
44 | + ->setName('migrations:migrate') |
|
45 | + ->setDescription('Execute a migration to a specified version or the latest available version.') |
|
46 | + ->addArgument('app', InputArgument::REQUIRED, 'Name of the app this migration command shall work on') |
|
47 | + ->addArgument('version', InputArgument::OPTIONAL, 'The version number (YYYYMMDDHHMMSS) or alias (first, prev, next, latest) to migrate to.', 'latest'); |
|
48 | 48 | |
49 | - parent::configure(); |
|
50 | - } |
|
49 | + parent::configure(); |
|
50 | + } |
|
51 | 51 | |
52 | - public function execute(InputInterface $input, OutputInterface $output): int { |
|
53 | - $appName = $input->getArgument('app'); |
|
54 | - $ms = new MigrationService($appName, $this->connection, new ConsoleOutput($output)); |
|
55 | - $version = $input->getArgument('version'); |
|
52 | + public function execute(InputInterface $input, OutputInterface $output): int { |
|
53 | + $appName = $input->getArgument('app'); |
|
54 | + $ms = new MigrationService($appName, $this->connection, new ConsoleOutput($output)); |
|
55 | + $version = $input->getArgument('version'); |
|
56 | 56 | |
57 | - $ms->migrate($version); |
|
58 | - return 0; |
|
59 | - } |
|
57 | + $ms->migrate($version); |
|
58 | + return 0; |
|
59 | + } |
|
60 | 60 | |
61 | - /** |
|
62 | - * @param string $optionName |
|
63 | - * @param CompletionContext $context |
|
64 | - * @return string[] |
|
65 | - */ |
|
66 | - public function completeOptionValues($optionName, CompletionContext $context) { |
|
67 | - return []; |
|
68 | - } |
|
61 | + /** |
|
62 | + * @param string $optionName |
|
63 | + * @param CompletionContext $context |
|
64 | + * @return string[] |
|
65 | + */ |
|
66 | + public function completeOptionValues($optionName, CompletionContext $context) { |
|
67 | + return []; |
|
68 | + } |
|
69 | 69 | |
70 | - /** |
|
71 | - * @param string $argumentName |
|
72 | - * @param CompletionContext $context |
|
73 | - * @return string[] |
|
74 | - */ |
|
75 | - public function completeArgumentValues($argumentName, CompletionContext $context) { |
|
76 | - if ($argumentName === 'app') { |
|
77 | - $allApps = \OC_App::getAllApps(); |
|
78 | - return array_diff($allApps, \OC_App::getEnabledApps(true, true)); |
|
79 | - } |
|
70 | + /** |
|
71 | + * @param string $argumentName |
|
72 | + * @param CompletionContext $context |
|
73 | + * @return string[] |
|
74 | + */ |
|
75 | + public function completeArgumentValues($argumentName, CompletionContext $context) { |
|
76 | + if ($argumentName === 'app') { |
|
77 | + $allApps = \OC_App::getAllApps(); |
|
78 | + return array_diff($allApps, \OC_App::getEnabledApps(true, true)); |
|
79 | + } |
|
80 | 80 | |
81 | - if ($argumentName === 'version') { |
|
82 | - $appName = $context->getWordAtIndex($context->getWordIndex() - 1); |
|
81 | + if ($argumentName === 'version') { |
|
82 | + $appName = $context->getWordAtIndex($context->getWordIndex() - 1); |
|
83 | 83 | |
84 | - $ms = new MigrationService($appName, $this->connection); |
|
85 | - $migrations = $ms->getAvailableVersions(); |
|
84 | + $ms = new MigrationService($appName, $this->connection); |
|
85 | + $migrations = $ms->getAvailableVersions(); |
|
86 | 86 | |
87 | - array_unshift($migrations, 'next', 'latest'); |
|
88 | - return $migrations; |
|
89 | - } |
|
87 | + array_unshift($migrations, 'next', 'latest'); |
|
88 | + return $migrations; |
|
89 | + } |
|
90 | 90 | |
91 | - return []; |
|
92 | - } |
|
91 | + return []; |
|
92 | + } |
|
93 | 93 | } |
@@ -35,78 +35,78 @@ |
||
35 | 35 | use Symfony\Component\Console\Output\OutputInterface; |
36 | 36 | |
37 | 37 | class ExecuteCommand extends Command implements CompletionAwareInterface { |
38 | - public function __construct( |
|
39 | - private Connection $connection, |
|
40 | - private IConfig $config, |
|
41 | - ) { |
|
42 | - parent::__construct(); |
|
43 | - } |
|
38 | + public function __construct( |
|
39 | + private Connection $connection, |
|
40 | + private IConfig $config, |
|
41 | + ) { |
|
42 | + parent::__construct(); |
|
43 | + } |
|
44 | 44 | |
45 | - protected function configure() { |
|
46 | - $this |
|
47 | - ->setName('migrations:execute') |
|
48 | - ->setDescription('Execute a single migration version manually.') |
|
49 | - ->addArgument('app', InputArgument::REQUIRED, 'Name of the app this migration command shall work on') |
|
50 | - ->addArgument('version', InputArgument::REQUIRED, 'The version to execute.', null); |
|
45 | + protected function configure() { |
|
46 | + $this |
|
47 | + ->setName('migrations:execute') |
|
48 | + ->setDescription('Execute a single migration version manually.') |
|
49 | + ->addArgument('app', InputArgument::REQUIRED, 'Name of the app this migration command shall work on') |
|
50 | + ->addArgument('version', InputArgument::REQUIRED, 'The version to execute.', null); |
|
51 | 51 | |
52 | - parent::configure(); |
|
53 | - } |
|
52 | + parent::configure(); |
|
53 | + } |
|
54 | 54 | |
55 | - /** |
|
56 | - * @param InputInterface $input |
|
57 | - * @param OutputInterface $output |
|
58 | - * @return int |
|
59 | - */ |
|
60 | - public function execute(InputInterface $input, OutputInterface $output): int { |
|
61 | - $appName = $input->getArgument('app'); |
|
62 | - $ms = new MigrationService($appName, $this->connection, new ConsoleOutput($output)); |
|
63 | - $version = $input->getArgument('version'); |
|
55 | + /** |
|
56 | + * @param InputInterface $input |
|
57 | + * @param OutputInterface $output |
|
58 | + * @return int |
|
59 | + */ |
|
60 | + public function execute(InputInterface $input, OutputInterface $output): int { |
|
61 | + $appName = $input->getArgument('app'); |
|
62 | + $ms = new MigrationService($appName, $this->connection, new ConsoleOutput($output)); |
|
63 | + $version = $input->getArgument('version'); |
|
64 | 64 | |
65 | - if ($this->config->getSystemValue('debug', false) === false) { |
|
66 | - $olderVersions = $ms->getMigratedVersions(); |
|
67 | - $olderVersions[] = '0'; |
|
68 | - $olderVersions[] = 'prev'; |
|
69 | - if (in_array($version, $olderVersions, true)) { |
|
70 | - $output->writeln('<error>Can not go back to previous migration without debug enabled</error>'); |
|
71 | - return 1; |
|
72 | - } |
|
73 | - } |
|
65 | + if ($this->config->getSystemValue('debug', false) === false) { |
|
66 | + $olderVersions = $ms->getMigratedVersions(); |
|
67 | + $olderVersions[] = '0'; |
|
68 | + $olderVersions[] = 'prev'; |
|
69 | + if (in_array($version, $olderVersions, true)) { |
|
70 | + $output->writeln('<error>Can not go back to previous migration without debug enabled</error>'); |
|
71 | + return 1; |
|
72 | + } |
|
73 | + } |
|
74 | 74 | |
75 | 75 | |
76 | - $ms->executeStep($version); |
|
77 | - return 0; |
|
78 | - } |
|
76 | + $ms->executeStep($version); |
|
77 | + return 0; |
|
78 | + } |
|
79 | 79 | |
80 | - /** |
|
81 | - * @param string $optionName |
|
82 | - * @param CompletionContext $context |
|
83 | - * @return string[] |
|
84 | - */ |
|
85 | - public function completeOptionValues($optionName, CompletionContext $context) { |
|
86 | - return []; |
|
87 | - } |
|
80 | + /** |
|
81 | + * @param string $optionName |
|
82 | + * @param CompletionContext $context |
|
83 | + * @return string[] |
|
84 | + */ |
|
85 | + public function completeOptionValues($optionName, CompletionContext $context) { |
|
86 | + return []; |
|
87 | + } |
|
88 | 88 | |
89 | - /** |
|
90 | - * @param string $argumentName |
|
91 | - * @param CompletionContext $context |
|
92 | - * @return string[] |
|
93 | - */ |
|
94 | - public function completeArgumentValues($argumentName, CompletionContext $context) { |
|
95 | - if ($argumentName === 'app') { |
|
96 | - $allApps = \OC_App::getAllApps(); |
|
97 | - return array_diff($allApps, \OC_App::getEnabledApps(true, true)); |
|
98 | - } |
|
89 | + /** |
|
90 | + * @param string $argumentName |
|
91 | + * @param CompletionContext $context |
|
92 | + * @return string[] |
|
93 | + */ |
|
94 | + public function completeArgumentValues($argumentName, CompletionContext $context) { |
|
95 | + if ($argumentName === 'app') { |
|
96 | + $allApps = \OC_App::getAllApps(); |
|
97 | + return array_diff($allApps, \OC_App::getEnabledApps(true, true)); |
|
98 | + } |
|
99 | 99 | |
100 | - if ($argumentName === 'version') { |
|
101 | - $appName = $context->getWordAtIndex($context->getWordIndex() - 1); |
|
100 | + if ($argumentName === 'version') { |
|
101 | + $appName = $context->getWordAtIndex($context->getWordIndex() - 1); |
|
102 | 102 | |
103 | - $ms = new MigrationService($appName, $this->connection); |
|
104 | - $migrations = $ms->getAvailableVersions(); |
|
103 | + $ms = new MigrationService($appName, $this->connection); |
|
104 | + $migrations = $ms->getAvailableVersions(); |
|
105 | 105 | |
106 | - array_unshift($migrations, 'next', 'latest'); |
|
107 | - return $migrations; |
|
108 | - } |
|
106 | + array_unshift($migrations, 'next', 'latest'); |
|
107 | + return $migrations; |
|
108 | + } |
|
109 | 109 | |
110 | - return []; |
|
111 | - } |
|
110 | + return []; |
|
111 | + } |
|
112 | 112 | } |
@@ -34,109 +34,109 @@ |
||
34 | 34 | use Symfony\Component\Console\Output\OutputInterface; |
35 | 35 | |
36 | 36 | class StatusCommand extends Command implements CompletionAwareInterface { |
37 | - public function __construct( |
|
38 | - private Connection $connection, |
|
39 | - ) { |
|
40 | - parent::__construct(); |
|
41 | - } |
|
37 | + public function __construct( |
|
38 | + private Connection $connection, |
|
39 | + ) { |
|
40 | + parent::__construct(); |
|
41 | + } |
|
42 | 42 | |
43 | - protected function configure() { |
|
44 | - $this |
|
45 | - ->setName('migrations:status') |
|
46 | - ->setDescription('View the status of a set of migrations.') |
|
47 | - ->addArgument('app', InputArgument::REQUIRED, 'Name of the app this migration command shall work on'); |
|
48 | - } |
|
43 | + protected function configure() { |
|
44 | + $this |
|
45 | + ->setName('migrations:status') |
|
46 | + ->setDescription('View the status of a set of migrations.') |
|
47 | + ->addArgument('app', InputArgument::REQUIRED, 'Name of the app this migration command shall work on'); |
|
48 | + } |
|
49 | 49 | |
50 | - public function execute(InputInterface $input, OutputInterface $output): int { |
|
51 | - $appName = $input->getArgument('app'); |
|
52 | - $ms = new MigrationService($appName, $this->connection, new ConsoleOutput($output)); |
|
50 | + public function execute(InputInterface $input, OutputInterface $output): int { |
|
51 | + $appName = $input->getArgument('app'); |
|
52 | + $ms = new MigrationService($appName, $this->connection, new ConsoleOutput($output)); |
|
53 | 53 | |
54 | - $infos = $this->getMigrationsInfos($ms); |
|
55 | - foreach ($infos as $key => $value) { |
|
56 | - if (is_array($value)) { |
|
57 | - $output->writeln(" <comment>>></comment> $key:"); |
|
58 | - foreach ($value as $subKey => $subValue) { |
|
59 | - $output->writeln(" <comment>>></comment> $subKey: " . str_repeat(' ', 46 - strlen($subKey)) . $subValue); |
|
60 | - } |
|
61 | - } else { |
|
62 | - $output->writeln(" <comment>>></comment> $key: " . str_repeat(' ', 50 - strlen($key)) . $value); |
|
63 | - } |
|
64 | - } |
|
65 | - return 0; |
|
66 | - } |
|
54 | + $infos = $this->getMigrationsInfos($ms); |
|
55 | + foreach ($infos as $key => $value) { |
|
56 | + if (is_array($value)) { |
|
57 | + $output->writeln(" <comment>>></comment> $key:"); |
|
58 | + foreach ($value as $subKey => $subValue) { |
|
59 | + $output->writeln(" <comment>>></comment> $subKey: " . str_repeat(' ', 46 - strlen($subKey)) . $subValue); |
|
60 | + } |
|
61 | + } else { |
|
62 | + $output->writeln(" <comment>>></comment> $key: " . str_repeat(' ', 50 - strlen($key)) . $value); |
|
63 | + } |
|
64 | + } |
|
65 | + return 0; |
|
66 | + } |
|
67 | 67 | |
68 | - /** |
|
69 | - * @param string $optionName |
|
70 | - * @param CompletionContext $context |
|
71 | - * @return string[] |
|
72 | - */ |
|
73 | - public function completeOptionValues($optionName, CompletionContext $context) { |
|
74 | - return []; |
|
75 | - } |
|
68 | + /** |
|
69 | + * @param string $optionName |
|
70 | + * @param CompletionContext $context |
|
71 | + * @return string[] |
|
72 | + */ |
|
73 | + public function completeOptionValues($optionName, CompletionContext $context) { |
|
74 | + return []; |
|
75 | + } |
|
76 | 76 | |
77 | - /** |
|
78 | - * @param string $argumentName |
|
79 | - * @param CompletionContext $context |
|
80 | - * @return string[] |
|
81 | - */ |
|
82 | - public function completeArgumentValues($argumentName, CompletionContext $context) { |
|
83 | - if ($argumentName === 'app') { |
|
84 | - $allApps = \OC_App::getAllApps(); |
|
85 | - return array_diff($allApps, \OC_App::getEnabledApps(true, true)); |
|
86 | - } |
|
87 | - return []; |
|
88 | - } |
|
77 | + /** |
|
78 | + * @param string $argumentName |
|
79 | + * @param CompletionContext $context |
|
80 | + * @return string[] |
|
81 | + */ |
|
82 | + public function completeArgumentValues($argumentName, CompletionContext $context) { |
|
83 | + if ($argumentName === 'app') { |
|
84 | + $allApps = \OC_App::getAllApps(); |
|
85 | + return array_diff($allApps, \OC_App::getEnabledApps(true, true)); |
|
86 | + } |
|
87 | + return []; |
|
88 | + } |
|
89 | 89 | |
90 | - /** |
|
91 | - * @param MigrationService $ms |
|
92 | - * @return array associative array of human readable info name as key and the actual information as value |
|
93 | - */ |
|
94 | - public function getMigrationsInfos(MigrationService $ms) { |
|
95 | - $executedMigrations = $ms->getMigratedVersions(); |
|
96 | - $availableMigrations = $ms->getAvailableVersions(); |
|
97 | - $executedUnavailableMigrations = array_diff($executedMigrations, array_keys($availableMigrations)); |
|
90 | + /** |
|
91 | + * @param MigrationService $ms |
|
92 | + * @return array associative array of human readable info name as key and the actual information as value |
|
93 | + */ |
|
94 | + public function getMigrationsInfos(MigrationService $ms) { |
|
95 | + $executedMigrations = $ms->getMigratedVersions(); |
|
96 | + $availableMigrations = $ms->getAvailableVersions(); |
|
97 | + $executedUnavailableMigrations = array_diff($executedMigrations, array_keys($availableMigrations)); |
|
98 | 98 | |
99 | - $numExecutedUnavailableMigrations = count($executedUnavailableMigrations); |
|
100 | - $numNewMigrations = count(array_diff(array_keys($availableMigrations), $executedMigrations)); |
|
101 | - $pending = $ms->describeMigrationStep('lastest'); |
|
99 | + $numExecutedUnavailableMigrations = count($executedUnavailableMigrations); |
|
100 | + $numNewMigrations = count(array_diff(array_keys($availableMigrations), $executedMigrations)); |
|
101 | + $pending = $ms->describeMigrationStep('lastest'); |
|
102 | 102 | |
103 | - $infos = [ |
|
104 | - 'App' => $ms->getApp(), |
|
105 | - 'Version Table Name' => $ms->getMigrationsTableName(), |
|
106 | - 'Migrations Namespace' => $ms->getMigrationsNamespace(), |
|
107 | - 'Migrations Directory' => $ms->getMigrationsDirectory(), |
|
108 | - 'Previous Version' => $this->getFormattedVersionAlias($ms, 'prev'), |
|
109 | - 'Current Version' => $this->getFormattedVersionAlias($ms, 'current'), |
|
110 | - 'Next Version' => $this->getFormattedVersionAlias($ms, 'next'), |
|
111 | - 'Latest Version' => $this->getFormattedVersionAlias($ms, 'latest'), |
|
112 | - 'Executed Migrations' => count($executedMigrations), |
|
113 | - 'Executed Unavailable Migrations' => $numExecutedUnavailableMigrations, |
|
114 | - 'Available Migrations' => count($availableMigrations), |
|
115 | - 'New Migrations' => $numNewMigrations, |
|
116 | - 'Pending Migrations' => count($pending) ? $pending : 'None' |
|
117 | - ]; |
|
103 | + $infos = [ |
|
104 | + 'App' => $ms->getApp(), |
|
105 | + 'Version Table Name' => $ms->getMigrationsTableName(), |
|
106 | + 'Migrations Namespace' => $ms->getMigrationsNamespace(), |
|
107 | + 'Migrations Directory' => $ms->getMigrationsDirectory(), |
|
108 | + 'Previous Version' => $this->getFormattedVersionAlias($ms, 'prev'), |
|
109 | + 'Current Version' => $this->getFormattedVersionAlias($ms, 'current'), |
|
110 | + 'Next Version' => $this->getFormattedVersionAlias($ms, 'next'), |
|
111 | + 'Latest Version' => $this->getFormattedVersionAlias($ms, 'latest'), |
|
112 | + 'Executed Migrations' => count($executedMigrations), |
|
113 | + 'Executed Unavailable Migrations' => $numExecutedUnavailableMigrations, |
|
114 | + 'Available Migrations' => count($availableMigrations), |
|
115 | + 'New Migrations' => $numNewMigrations, |
|
116 | + 'Pending Migrations' => count($pending) ? $pending : 'None' |
|
117 | + ]; |
|
118 | 118 | |
119 | - return $infos; |
|
120 | - } |
|
119 | + return $infos; |
|
120 | + } |
|
121 | 121 | |
122 | - /** |
|
123 | - * @param MigrationService $migrationService |
|
124 | - * @param string $alias |
|
125 | - * @return mixed|null|string |
|
126 | - */ |
|
127 | - private function getFormattedVersionAlias(MigrationService $migrationService, $alias) { |
|
128 | - $migration = $migrationService->getMigration($alias); |
|
129 | - //No version found |
|
130 | - if ($migration === null) { |
|
131 | - if ($alias === 'next') { |
|
132 | - return 'Already at latest migration step'; |
|
133 | - } |
|
122 | + /** |
|
123 | + * @param MigrationService $migrationService |
|
124 | + * @param string $alias |
|
125 | + * @return mixed|null|string |
|
126 | + */ |
|
127 | + private function getFormattedVersionAlias(MigrationService $migrationService, $alias) { |
|
128 | + $migration = $migrationService->getMigration($alias); |
|
129 | + //No version found |
|
130 | + if ($migration === null) { |
|
131 | + if ($alias === 'next') { |
|
132 | + return 'Already at latest migration step'; |
|
133 | + } |
|
134 | 134 | |
135 | - if ($alias === 'prev') { |
|
136 | - return 'Already at first migration step'; |
|
137 | - } |
|
138 | - } |
|
135 | + if ($alias === 'prev') { |
|
136 | + return 'Already at first migration step'; |
|
137 | + } |
|
138 | + } |
|
139 | 139 | |
140 | - return $migration; |
|
141 | - } |
|
140 | + return $migration; |
|
141 | + } |
|
142 | 142 | } |
@@ -33,27 +33,27 @@ |
||
33 | 33 | use Symfony\Component\Console\Output\OutputInterface; |
34 | 34 | |
35 | 35 | class UpdateTheme extends UpdateJS { |
36 | - public function __construct( |
|
37 | - IMimeTypeDetector $mimetypeDetector, |
|
38 | - protected ICacheFactory $cacheFactory, |
|
39 | - ) { |
|
40 | - parent::__construct($mimetypeDetector); |
|
41 | - } |
|
36 | + public function __construct( |
|
37 | + IMimeTypeDetector $mimetypeDetector, |
|
38 | + protected ICacheFactory $cacheFactory, |
|
39 | + ) { |
|
40 | + parent::__construct($mimetypeDetector); |
|
41 | + } |
|
42 | 42 | |
43 | - protected function configure() { |
|
44 | - $this |
|
45 | - ->setName('maintenance:theme:update') |
|
46 | - ->setDescription('Apply custom theme changes'); |
|
47 | - } |
|
43 | + protected function configure() { |
|
44 | + $this |
|
45 | + ->setName('maintenance:theme:update') |
|
46 | + ->setDescription('Apply custom theme changes'); |
|
47 | + } |
|
48 | 48 | |
49 | - protected function execute(InputInterface $input, OutputInterface $output): int { |
|
50 | - // run mimetypelist.js update since themes might change mimetype icons |
|
51 | - parent::execute($input, $output); |
|
49 | + protected function execute(InputInterface $input, OutputInterface $output): int { |
|
50 | + // run mimetypelist.js update since themes might change mimetype icons |
|
51 | + parent::execute($input, $output); |
|
52 | 52 | |
53 | - // cleanup image cache |
|
54 | - $c = $this->cacheFactory->createDistributed('imagePath'); |
|
55 | - $c->clear(''); |
|
56 | - $output->writeln('<info>Image cache cleared</info>'); |
|
57 | - return 0; |
|
58 | - } |
|
53 | + // cleanup image cache |
|
54 | + $c = $this->cacheFactory->createDistributed('imagePath'); |
|
55 | + $c->clear(''); |
|
56 | + $output->writeln('<info>Image cache cleared</info>'); |
|
57 | + return 0; |
|
58 | + } |
|
59 | 59 | } |
@@ -30,31 +30,31 @@ |
||
30 | 30 | use Symfony\Component\Console\Output\OutputInterface; |
31 | 31 | |
32 | 32 | class Delete extends Base { |
33 | - public function __construct( |
|
34 | - protected ISystemTagManager $systemTagManager, |
|
35 | - ) { |
|
36 | - parent::__construct(); |
|
37 | - } |
|
33 | + public function __construct( |
|
34 | + protected ISystemTagManager $systemTagManager, |
|
35 | + ) { |
|
36 | + parent::__construct(); |
|
37 | + } |
|
38 | 38 | |
39 | - protected function configure() { |
|
40 | - $this |
|
41 | - ->setName('tag:delete') |
|
42 | - ->setDescription('delete a tag') |
|
43 | - ->addArgument( |
|
44 | - 'id', |
|
45 | - InputOption::VALUE_REQUIRED, |
|
46 | - 'The ID of the tag that should be deleted', |
|
47 | - ); |
|
48 | - } |
|
39 | + protected function configure() { |
|
40 | + $this |
|
41 | + ->setName('tag:delete') |
|
42 | + ->setDescription('delete a tag') |
|
43 | + ->addArgument( |
|
44 | + 'id', |
|
45 | + InputOption::VALUE_REQUIRED, |
|
46 | + 'The ID of the tag that should be deleted', |
|
47 | + ); |
|
48 | + } |
|
49 | 49 | |
50 | - protected function execute(InputInterface $input, OutputInterface $output): int { |
|
51 | - try { |
|
52 | - $this->systemTagManager->deleteTags($input->getArgument('id')); |
|
53 | - $output->writeln('<info>The specified tag was deleted</info>'); |
|
54 | - return 0; |
|
55 | - } catch (TagNotFoundException $e) { |
|
56 | - $output->writeln('<error>Tag not found</error>'); |
|
57 | - return 1; |
|
58 | - } |
|
59 | - } |
|
50 | + protected function execute(InputInterface $input, OutputInterface $output): int { |
|
51 | + try { |
|
52 | + $this->systemTagManager->deleteTags($input->getArgument('id')); |
|
53 | + $output->writeln('<info>The specified tag was deleted</info>'); |
|
54 | + return 0; |
|
55 | + } catch (TagNotFoundException $e) { |
|
56 | + $output->writeln('<error>Tag not found</error>'); |
|
57 | + return 1; |
|
58 | + } |
|
59 | + } |
|
60 | 60 | } |
@@ -30,54 +30,54 @@ |
||
30 | 30 | use Symfony\Component\Console\Output\OutputInterface; |
31 | 31 | |
32 | 32 | class ListCommand extends Base { |
33 | - public function __construct( |
|
34 | - protected ISystemTagManager $systemTagManager, |
|
35 | - ) { |
|
36 | - parent::__construct(); |
|
37 | - } |
|
33 | + public function __construct( |
|
34 | + protected ISystemTagManager $systemTagManager, |
|
35 | + ) { |
|
36 | + parent::__construct(); |
|
37 | + } |
|
38 | 38 | |
39 | - protected function configure() { |
|
40 | - $this |
|
41 | - ->setName('tag:list') |
|
42 | - ->setDescription('list tags') |
|
43 | - ->addOption( |
|
44 | - 'visibilityFilter', |
|
45 | - null, |
|
46 | - InputOption::VALUE_OPTIONAL, |
|
47 | - 'filter by visibility (1,0)' |
|
48 | - ) |
|
49 | - ->addOption( |
|
50 | - 'nameSearchPattern', |
|
51 | - null, |
|
52 | - InputOption::VALUE_OPTIONAL, |
|
53 | - 'optional search pattern for the tag name (infix)' |
|
54 | - ); |
|
55 | - parent::configure(); |
|
56 | - } |
|
39 | + protected function configure() { |
|
40 | + $this |
|
41 | + ->setName('tag:list') |
|
42 | + ->setDescription('list tags') |
|
43 | + ->addOption( |
|
44 | + 'visibilityFilter', |
|
45 | + null, |
|
46 | + InputOption::VALUE_OPTIONAL, |
|
47 | + 'filter by visibility (1,0)' |
|
48 | + ) |
|
49 | + ->addOption( |
|
50 | + 'nameSearchPattern', |
|
51 | + null, |
|
52 | + InputOption::VALUE_OPTIONAL, |
|
53 | + 'optional search pattern for the tag name (infix)' |
|
54 | + ); |
|
55 | + parent::configure(); |
|
56 | + } |
|
57 | 57 | |
58 | - protected function execute(InputInterface $input, OutputInterface $output): int { |
|
59 | - $tags = $this->systemTagManager->getAllTags( |
|
60 | - $input->getOption('visibilityFilter'), |
|
61 | - $input->getOption('nameSearchPattern') |
|
62 | - ); |
|
58 | + protected function execute(InputInterface $input, OutputInterface $output): int { |
|
59 | + $tags = $this->systemTagManager->getAllTags( |
|
60 | + $input->getOption('visibilityFilter'), |
|
61 | + $input->getOption('nameSearchPattern') |
|
62 | + ); |
|
63 | 63 | |
64 | - $this->writeArrayInOutputFormat($input, $output, $this->formatTags($tags)); |
|
65 | - return 0; |
|
66 | - } |
|
64 | + $this->writeArrayInOutputFormat($input, $output, $this->formatTags($tags)); |
|
65 | + return 0; |
|
66 | + } |
|
67 | 67 | |
68 | - /** |
|
69 | - * @param ISystemtag[] $tags |
|
70 | - * @return array |
|
71 | - */ |
|
72 | - private function formatTags(array $tags): array { |
|
73 | - $result = []; |
|
68 | + /** |
|
69 | + * @param ISystemtag[] $tags |
|
70 | + * @return array |
|
71 | + */ |
|
72 | + private function formatTags(array $tags): array { |
|
73 | + $result = []; |
|
74 | 74 | |
75 | - foreach ($tags as $tag) { |
|
76 | - $result[$tag->getId()] = [ |
|
77 | - 'name' => $tag->getName(), |
|
78 | - 'access' => ISystemTag::ACCESS_LEVEL_LOOKUP[$tag->getAccessLevel()], |
|
79 | - ]; |
|
80 | - } |
|
81 | - return $result; |
|
82 | - } |
|
75 | + foreach ($tags as $tag) { |
|
76 | + $result[$tag->getId()] = [ |
|
77 | + 'name' => $tag->getName(), |
|
78 | + 'access' => ISystemTag::ACCESS_LEVEL_LOOKUP[$tag->getAccessLevel()], |
|
79 | + ]; |
|
80 | + } |
|
81 | + return $result; |
|
82 | + } |
|
83 | 83 | } |
@@ -30,27 +30,27 @@ |
||
30 | 30 | use Symfony\Component\Console\Output\OutputInterface; |
31 | 31 | |
32 | 32 | class RemoveCertificate extends Base { |
33 | - public function __construct( |
|
34 | - protected ICertificateManager $certificateManager, |
|
35 | - ) { |
|
36 | - parent::__construct(); |
|
37 | - } |
|
33 | + public function __construct( |
|
34 | + protected ICertificateManager $certificateManager, |
|
35 | + ) { |
|
36 | + parent::__construct(); |
|
37 | + } |
|
38 | 38 | |
39 | - protected function configure() { |
|
40 | - $this |
|
41 | - ->setName('security:certificates:remove') |
|
42 | - ->setDescription('remove trusted certificate') |
|
43 | - ->addArgument( |
|
44 | - 'name', |
|
45 | - InputArgument::REQUIRED, |
|
46 | - 'the file name of the certificate to remove' |
|
47 | - ); |
|
48 | - } |
|
39 | + protected function configure() { |
|
40 | + $this |
|
41 | + ->setName('security:certificates:remove') |
|
42 | + ->setDescription('remove trusted certificate') |
|
43 | + ->addArgument( |
|
44 | + 'name', |
|
45 | + InputArgument::REQUIRED, |
|
46 | + 'the file name of the certificate to remove' |
|
47 | + ); |
|
48 | + } |
|
49 | 49 | |
50 | - protected function execute(InputInterface $input, OutputInterface $output): int { |
|
51 | - $name = $input->getArgument('name'); |
|
50 | + protected function execute(InputInterface $input, OutputInterface $output): int { |
|
51 | + $name = $input->getArgument('name'); |
|
52 | 52 | |
53 | - $this->certificateManager->removeCertificate($name); |
|
54 | - return 0; |
|
55 | - } |
|
53 | + $this->certificateManager->removeCertificate($name); |
|
54 | + return 0; |
|
55 | + } |
|
56 | 56 | } |
@@ -26,56 +26,56 @@ |
||
26 | 26 | use Stecman\Component\Symfony\Console\BashCompletion\CompletionContext; |
27 | 27 | |
28 | 28 | abstract class Base extends \OC\Core\Command\Base { |
29 | - public function __construct( |
|
30 | - protected SystemConfig $systemConfig, |
|
31 | - ) { |
|
32 | - parent::__construct(); |
|
33 | - } |
|
29 | + public function __construct( |
|
30 | + protected SystemConfig $systemConfig, |
|
31 | + ) { |
|
32 | + parent::__construct(); |
|
33 | + } |
|
34 | 34 | |
35 | - /** |
|
36 | - * @param string $argumentName |
|
37 | - * @param CompletionContext $context |
|
38 | - * @return string[] |
|
39 | - */ |
|
40 | - public function completeArgumentValues($argumentName, CompletionContext $context) { |
|
41 | - if ($argumentName === 'name') { |
|
42 | - $words = $this->getPreviousNames($context, $context->getWordIndex()); |
|
43 | - if (empty($words)) { |
|
44 | - $completions = $this->systemConfig->getKeys(); |
|
45 | - } else { |
|
46 | - $key = array_shift($words); |
|
47 | - $value = $this->systemConfig->getValue($key); |
|
48 | - $completions = array_keys($value); |
|
35 | + /** |
|
36 | + * @param string $argumentName |
|
37 | + * @param CompletionContext $context |
|
38 | + * @return string[] |
|
39 | + */ |
|
40 | + public function completeArgumentValues($argumentName, CompletionContext $context) { |
|
41 | + if ($argumentName === 'name') { |
|
42 | + $words = $this->getPreviousNames($context, $context->getWordIndex()); |
|
43 | + if (empty($words)) { |
|
44 | + $completions = $this->systemConfig->getKeys(); |
|
45 | + } else { |
|
46 | + $key = array_shift($words); |
|
47 | + $value = $this->systemConfig->getValue($key); |
|
48 | + $completions = array_keys($value); |
|
49 | 49 | |
50 | - while (!empty($words) && is_array($value)) { |
|
51 | - $key = array_shift($words); |
|
52 | - if (!isset($value[$key]) || !is_array($value[$key])) { |
|
53 | - break; |
|
54 | - } |
|
50 | + while (!empty($words) && is_array($value)) { |
|
51 | + $key = array_shift($words); |
|
52 | + if (!isset($value[$key]) || !is_array($value[$key])) { |
|
53 | + break; |
|
54 | + } |
|
55 | 55 | |
56 | - $value = $value[$key]; |
|
57 | - $completions = array_keys($value); |
|
58 | - } |
|
59 | - } |
|
56 | + $value = $value[$key]; |
|
57 | + $completions = array_keys($value); |
|
58 | + } |
|
59 | + } |
|
60 | 60 | |
61 | - return $completions; |
|
62 | - } |
|
63 | - return parent::completeArgumentValues($argumentName, $context); |
|
64 | - } |
|
61 | + return $completions; |
|
62 | + } |
|
63 | + return parent::completeArgumentValues($argumentName, $context); |
|
64 | + } |
|
65 | 65 | |
66 | - /** |
|
67 | - * @param CompletionContext $context |
|
68 | - * @param int $currentIndex |
|
69 | - * @return string[] |
|
70 | - */ |
|
71 | - protected function getPreviousNames(CompletionContext $context, $currentIndex) { |
|
72 | - $word = $context->getWordAtIndex($currentIndex - 1); |
|
73 | - if ($word === $this->getName() || $currentIndex <= 0) { |
|
74 | - return []; |
|
75 | - } |
|
66 | + /** |
|
67 | + * @param CompletionContext $context |
|
68 | + * @param int $currentIndex |
|
69 | + * @return string[] |
|
70 | + */ |
|
71 | + protected function getPreviousNames(CompletionContext $context, $currentIndex) { |
|
72 | + $word = $context->getWordAtIndex($currentIndex - 1); |
|
73 | + if ($word === $this->getName() || $currentIndex <= 0) { |
|
74 | + return []; |
|
75 | + } |
|
76 | 76 | |
77 | - $words = $this->getPreviousNames($context, $currentIndex - 1); |
|
78 | - $words[] = $word; |
|
79 | - return $words; |
|
80 | - } |
|
77 | + $words = $this->getPreviousNames($context, $currentIndex - 1); |
|
78 | + $words[] = $word; |
|
79 | + return $words; |
|
80 | + } |
|
81 | 81 | } |
@@ -30,83 +30,83 @@ |
||
30 | 30 | use Symfony\Component\Console\Output\OutputInterface; |
31 | 31 | |
32 | 32 | class DeleteConfig extends Base { |
33 | - public function __construct( |
|
34 | - SystemConfig $systemConfig, |
|
35 | - ) { |
|
36 | - parent::__construct($systemConfig); |
|
37 | - } |
|
33 | + public function __construct( |
|
34 | + SystemConfig $systemConfig, |
|
35 | + ) { |
|
36 | + parent::__construct($systemConfig); |
|
37 | + } |
|
38 | 38 | |
39 | - protected function configure() { |
|
40 | - parent::configure(); |
|
39 | + protected function configure() { |
|
40 | + parent::configure(); |
|
41 | 41 | |
42 | - $this |
|
43 | - ->setName('config:system:delete') |
|
44 | - ->setDescription('Delete a system config value') |
|
45 | - ->addArgument( |
|
46 | - 'name', |
|
47 | - InputArgument::REQUIRED | InputArgument::IS_ARRAY, |
|
48 | - 'Name of the config to delete, specify multiple for array parameter' |
|
49 | - ) |
|
50 | - ->addOption( |
|
51 | - 'error-if-not-exists', |
|
52 | - null, |
|
53 | - InputOption::VALUE_NONE, |
|
54 | - 'Checks whether the config exists before deleting it' |
|
55 | - ) |
|
56 | - ; |
|
57 | - } |
|
42 | + $this |
|
43 | + ->setName('config:system:delete') |
|
44 | + ->setDescription('Delete a system config value') |
|
45 | + ->addArgument( |
|
46 | + 'name', |
|
47 | + InputArgument::REQUIRED | InputArgument::IS_ARRAY, |
|
48 | + 'Name of the config to delete, specify multiple for array parameter' |
|
49 | + ) |
|
50 | + ->addOption( |
|
51 | + 'error-if-not-exists', |
|
52 | + null, |
|
53 | + InputOption::VALUE_NONE, |
|
54 | + 'Checks whether the config exists before deleting it' |
|
55 | + ) |
|
56 | + ; |
|
57 | + } |
|
58 | 58 | |
59 | - protected function execute(InputInterface $input, OutputInterface $output): int { |
|
60 | - $configNames = $input->getArgument('name'); |
|
61 | - $configName = $configNames[0]; |
|
59 | + protected function execute(InputInterface $input, OutputInterface $output): int { |
|
60 | + $configNames = $input->getArgument('name'); |
|
61 | + $configName = $configNames[0]; |
|
62 | 62 | |
63 | - if (count($configNames) > 1) { |
|
64 | - if ($input->hasParameterOption('--error-if-not-exists') && !in_array($configName, $this->systemConfig->getKeys())) { |
|
65 | - $output->writeln('<error>System config ' . implode(' => ', $configNames) . ' could not be deleted because it did not exist</error>'); |
|
66 | - return 1; |
|
67 | - } |
|
63 | + if (count($configNames) > 1) { |
|
64 | + if ($input->hasParameterOption('--error-if-not-exists') && !in_array($configName, $this->systemConfig->getKeys())) { |
|
65 | + $output->writeln('<error>System config ' . implode(' => ', $configNames) . ' could not be deleted because it did not exist</error>'); |
|
66 | + return 1; |
|
67 | + } |
|
68 | 68 | |
69 | - $value = $this->systemConfig->getValue($configName); |
|
69 | + $value = $this->systemConfig->getValue($configName); |
|
70 | 70 | |
71 | - try { |
|
72 | - $value = $this->removeSubValue(array_slice($configNames, 1), $value, $input->hasParameterOption('--error-if-not-exists')); |
|
73 | - } catch (\UnexpectedValueException $e) { |
|
74 | - $output->writeln('<error>System config ' . implode(' => ', $configNames) . ' could not be deleted because it did not exist</error>'); |
|
75 | - return 1; |
|
76 | - } |
|
71 | + try { |
|
72 | + $value = $this->removeSubValue(array_slice($configNames, 1), $value, $input->hasParameterOption('--error-if-not-exists')); |
|
73 | + } catch (\UnexpectedValueException $e) { |
|
74 | + $output->writeln('<error>System config ' . implode(' => ', $configNames) . ' could not be deleted because it did not exist</error>'); |
|
75 | + return 1; |
|
76 | + } |
|
77 | 77 | |
78 | - $this->systemConfig->setValue($configName, $value); |
|
79 | - $output->writeln('<info>System config value ' . implode(' => ', $configNames) . ' deleted</info>'); |
|
80 | - return 0; |
|
81 | - } else { |
|
82 | - if ($input->hasParameterOption('--error-if-not-exists') && !in_array($configName, $this->systemConfig->getKeys())) { |
|
83 | - $output->writeln('<error>System config ' . $configName . ' could not be deleted because it did not exist</error>'); |
|
84 | - return 1; |
|
85 | - } |
|
78 | + $this->systemConfig->setValue($configName, $value); |
|
79 | + $output->writeln('<info>System config value ' . implode(' => ', $configNames) . ' deleted</info>'); |
|
80 | + return 0; |
|
81 | + } else { |
|
82 | + if ($input->hasParameterOption('--error-if-not-exists') && !in_array($configName, $this->systemConfig->getKeys())) { |
|
83 | + $output->writeln('<error>System config ' . $configName . ' could not be deleted because it did not exist</error>'); |
|
84 | + return 1; |
|
85 | + } |
|
86 | 86 | |
87 | - $this->systemConfig->deleteValue($configName); |
|
88 | - $output->writeln('<info>System config value ' . $configName . ' deleted</info>'); |
|
89 | - return 0; |
|
90 | - } |
|
91 | - } |
|
87 | + $this->systemConfig->deleteValue($configName); |
|
88 | + $output->writeln('<info>System config value ' . $configName . ' deleted</info>'); |
|
89 | + return 0; |
|
90 | + } |
|
91 | + } |
|
92 | 92 | |
93 | - protected function removeSubValue($keys, $currentValue, $throwError) { |
|
94 | - $nextKey = array_shift($keys); |
|
93 | + protected function removeSubValue($keys, $currentValue, $throwError) { |
|
94 | + $nextKey = array_shift($keys); |
|
95 | 95 | |
96 | - if (is_array($currentValue)) { |
|
97 | - if (isset($currentValue[$nextKey])) { |
|
98 | - if (empty($keys)) { |
|
99 | - unset($currentValue[$nextKey]); |
|
100 | - } else { |
|
101 | - $currentValue[$nextKey] = $this->removeSubValue($keys, $currentValue[$nextKey], $throwError); |
|
102 | - } |
|
103 | - } elseif ($throwError) { |
|
104 | - throw new \UnexpectedValueException('Config parameter does not exist'); |
|
105 | - } |
|
106 | - } elseif ($throwError) { |
|
107 | - throw new \UnexpectedValueException('Config parameter does not exist'); |
|
108 | - } |
|
96 | + if (is_array($currentValue)) { |
|
97 | + if (isset($currentValue[$nextKey])) { |
|
98 | + if (empty($keys)) { |
|
99 | + unset($currentValue[$nextKey]); |
|
100 | + } else { |
|
101 | + $currentValue[$nextKey] = $this->removeSubValue($keys, $currentValue[$nextKey], $throwError); |
|
102 | + } |
|
103 | + } elseif ($throwError) { |
|
104 | + throw new \UnexpectedValueException('Config parameter does not exist'); |
|
105 | + } |
|
106 | + } elseif ($throwError) { |
|
107 | + throw new \UnexpectedValueException('Config parameter does not exist'); |
|
108 | + } |
|
109 | 109 | |
110 | - return $currentValue; |
|
111 | - } |
|
110 | + return $currentValue; |
|
111 | + } |
|
112 | 112 | } |