@@ -10,60 +10,60 @@ |
||
| 10 | 10 | use Test\TestCase; |
| 11 | 11 | |
| 12 | 12 | class CastHelperTest extends TestCase { |
| 13 | - private CastHelper $castHelper; |
|
| 13 | + private CastHelper $castHelper; |
|
| 14 | 14 | |
| 15 | - protected function setUp(): void { |
|
| 16 | - parent::setUp(); |
|
| 17 | - $this->castHelper = new CastHelper(); |
|
| 18 | - } |
|
| 15 | + protected function setUp(): void { |
|
| 16 | + parent::setUp(); |
|
| 17 | + $this->castHelper = new CastHelper(); |
|
| 18 | + } |
|
| 19 | 19 | |
| 20 | - public static function castValueProvider(): array { |
|
| 21 | - return [ |
|
| 22 | - [null, 'string', ['value' => '', 'readable-value' => 'empty string']], |
|
| 20 | + public static function castValueProvider(): array { |
|
| 21 | + return [ |
|
| 22 | + [null, 'string', ['value' => '', 'readable-value' => 'empty string']], |
|
| 23 | 23 | |
| 24 | - ['abc', 'string', ['value' => 'abc', 'readable-value' => 'string abc']], |
|
| 24 | + ['abc', 'string', ['value' => 'abc', 'readable-value' => 'string abc']], |
|
| 25 | 25 | |
| 26 | - ['123', 'integer', ['value' => 123, 'readable-value' => 'integer 123']], |
|
| 27 | - ['456', 'int', ['value' => 456, 'readable-value' => 'integer 456']], |
|
| 26 | + ['123', 'integer', ['value' => 123, 'readable-value' => 'integer 123']], |
|
| 27 | + ['456', 'int', ['value' => 456, 'readable-value' => 'integer 456']], |
|
| 28 | 28 | |
| 29 | - ['2.25', 'double', ['value' => 2.25, 'readable-value' => 'double 2.25']], |
|
| 30 | - ['0.5', 'float', ['value' => 0.5, 'readable-value' => 'double 0.5']], |
|
| 29 | + ['2.25', 'double', ['value' => 2.25, 'readable-value' => 'double 2.25']], |
|
| 30 | + ['0.5', 'float', ['value' => 0.5, 'readable-value' => 'double 0.5']], |
|
| 31 | 31 | |
| 32 | - ['', 'null', ['value' => null, 'readable-value' => 'null']], |
|
| 32 | + ['', 'null', ['value' => null, 'readable-value' => 'null']], |
|
| 33 | 33 | |
| 34 | - ['true', 'boolean', ['value' => true, 'readable-value' => 'boolean true']], |
|
| 35 | - ['false', 'bool', ['value' => false, 'readable-value' => 'boolean false']], |
|
| 36 | - ]; |
|
| 37 | - } |
|
| 34 | + ['true', 'boolean', ['value' => true, 'readable-value' => 'boolean true']], |
|
| 35 | + ['false', 'bool', ['value' => false, 'readable-value' => 'boolean false']], |
|
| 36 | + ]; |
|
| 37 | + } |
|
| 38 | 38 | |
| 39 | - /** |
|
| 40 | - * @dataProvider castValueProvider |
|
| 41 | - */ |
|
| 42 | - public function testCastValue($value, $type, $expectedValue): void { |
|
| 43 | - $this->assertSame( |
|
| 44 | - $expectedValue, |
|
| 45 | - $this->castHelper->castValue($value, $type) |
|
| 46 | - ); |
|
| 47 | - } |
|
| 39 | + /** |
|
| 40 | + * @dataProvider castValueProvider |
|
| 41 | + */ |
|
| 42 | + public function testCastValue($value, $type, $expectedValue): void { |
|
| 43 | + $this->assertSame( |
|
| 44 | + $expectedValue, |
|
| 45 | + $this->castHelper->castValue($value, $type) |
|
| 46 | + ); |
|
| 47 | + } |
|
| 48 | 48 | |
| 49 | - public static function castValueInvalidProvider(): array { |
|
| 50 | - return [ |
|
| 51 | - ['123', 'foobar'], |
|
| 49 | + public static function castValueInvalidProvider(): array { |
|
| 50 | + return [ |
|
| 51 | + ['123', 'foobar'], |
|
| 52 | 52 | |
| 53 | - [null, 'integer'], |
|
| 54 | - ['abc', 'integer'], |
|
| 55 | - ['76ggg', 'double'], |
|
| 56 | - ['true', 'float'], |
|
| 57 | - ['foobar', 'boolean'], |
|
| 58 | - ]; |
|
| 59 | - } |
|
| 53 | + [null, 'integer'], |
|
| 54 | + ['abc', 'integer'], |
|
| 55 | + ['76ggg', 'double'], |
|
| 56 | + ['true', 'float'], |
|
| 57 | + ['foobar', 'boolean'], |
|
| 58 | + ]; |
|
| 59 | + } |
|
| 60 | 60 | |
| 61 | - /** |
|
| 62 | - * @dataProvider castValueInvalidProvider |
|
| 63 | - */ |
|
| 64 | - public function testCastValueInvalid($value, $type): void { |
|
| 65 | - $this->expectException(\InvalidArgumentException::class); |
|
| 61 | + /** |
|
| 62 | + * @dataProvider castValueInvalidProvider |
|
| 63 | + */ |
|
| 64 | + public function testCastValueInvalid($value, $type): void { |
|
| 65 | + $this->expectException(\InvalidArgumentException::class); |
|
| 66 | 66 | |
| 67 | - $this->castHelper->castValue($value, $type); |
|
| 68 | - } |
|
| 67 | + $this->castHelper->castValue($value, $type); |
|
| 68 | + } |
|
| 69 | 69 | } |
@@ -15,102 +15,102 @@ |
||
| 15 | 15 | use Test\TestCase; |
| 16 | 16 | |
| 17 | 17 | class SetConfigTest extends TestCase { |
| 18 | - /** @var \PHPUnit\Framework\MockObject\MockObject */ |
|
| 19 | - protected $systemConfig; |
|
| 20 | - |
|
| 21 | - /** @var \PHPUnit\Framework\MockObject\MockObject */ |
|
| 22 | - protected $consoleInput; |
|
| 23 | - /** @var \PHPUnit\Framework\MockObject\MockObject */ |
|
| 24 | - protected $consoleOutput; |
|
| 25 | - |
|
| 26 | - /** @var \Symfony\Component\Console\Command\Command */ |
|
| 27 | - protected $command; |
|
| 28 | - |
|
| 29 | - protected function setUp(): void { |
|
| 30 | - parent::setUp(); |
|
| 31 | - |
|
| 32 | - $systemConfig = $this->systemConfig = $this->getMockBuilder(SystemConfig::class) |
|
| 33 | - ->disableOriginalConstructor() |
|
| 34 | - ->getMock(); |
|
| 35 | - $this->consoleInput = $this->getMockBuilder(InputInterface::class)->getMock(); |
|
| 36 | - $this->consoleOutput = $this->getMockBuilder(OutputInterface::class)->getMock(); |
|
| 37 | - |
|
| 38 | - /** @var \OC\SystemConfig $systemConfig */ |
|
| 39 | - $this->command = new SetConfig($systemConfig, new CastHelper()); |
|
| 40 | - } |
|
| 41 | - |
|
| 42 | - |
|
| 43 | - public static function dataTest() { |
|
| 44 | - return [ |
|
| 45 | - [['name'], 'newvalue', null, 'newvalue'], |
|
| 46 | - [['a', 'b', 'c'], 'foobar', null, ['b' => ['c' => 'foobar']]], |
|
| 47 | - [['a', 'b', 'c'], 'foobar', ['b' => ['d' => 'barfoo']], ['b' => ['d' => 'barfoo', 'c' => 'foobar']]], |
|
| 48 | - ]; |
|
| 49 | - } |
|
| 50 | - |
|
| 51 | - /** |
|
| 52 | - * @dataProvider dataTest |
|
| 53 | - * |
|
| 54 | - * @param array $configNames |
|
| 55 | - * @param string $newValue |
|
| 56 | - * @param mixed $existingData |
|
| 57 | - * @param mixed $expectedValue |
|
| 58 | - */ |
|
| 59 | - public function testSet($configNames, $newValue, $existingData, $expectedValue): void { |
|
| 60 | - $this->systemConfig->expects($this->once()) |
|
| 61 | - ->method('setValue') |
|
| 62 | - ->with($configNames[0], $expectedValue); |
|
| 63 | - $this->systemConfig->method('getValue') |
|
| 64 | - ->with($configNames[0]) |
|
| 65 | - ->willReturn($existingData); |
|
| 66 | - |
|
| 67 | - $this->consoleInput->expects($this->once()) |
|
| 68 | - ->method('getArgument') |
|
| 69 | - ->with('name') |
|
| 70 | - ->willReturn($configNames); |
|
| 71 | - $this->consoleInput->method('getOption') |
|
| 72 | - ->willReturnMap([ |
|
| 73 | - ['value', $newValue], |
|
| 74 | - ['type', 'string'], |
|
| 75 | - ]); |
|
| 76 | - |
|
| 77 | - $this->invokePrivate($this->command, 'execute', [$this->consoleInput, $this->consoleOutput]); |
|
| 78 | - } |
|
| 79 | - |
|
| 80 | - public static function setUpdateOnlyProvider(): array { |
|
| 81 | - return [ |
|
| 82 | - [['name'], null], |
|
| 83 | - [['a', 'b', 'c'], null], |
|
| 84 | - [['a', 'b', 'c'], ['b' => 'foobar']], |
|
| 85 | - [['a', 'b', 'c'], ['b' => ['d' => 'foobar']]], |
|
| 86 | - ]; |
|
| 87 | - } |
|
| 88 | - |
|
| 89 | - /** |
|
| 90 | - * @dataProvider setUpdateOnlyProvider |
|
| 91 | - */ |
|
| 92 | - public function testSetUpdateOnly($configNames, $existingData): void { |
|
| 93 | - $this->expectException(\UnexpectedValueException::class); |
|
| 94 | - |
|
| 95 | - $this->systemConfig->expects($this->never()) |
|
| 96 | - ->method('setValue'); |
|
| 97 | - $this->systemConfig->method('getValue') |
|
| 98 | - ->with($configNames[0]) |
|
| 99 | - ->willReturn($existingData); |
|
| 100 | - $this->systemConfig->method('getKeys') |
|
| 101 | - ->willReturn($existingData ? $configNames[0] : []); |
|
| 102 | - |
|
| 103 | - $this->consoleInput->expects($this->once()) |
|
| 104 | - ->method('getArgument') |
|
| 105 | - ->with('name') |
|
| 106 | - ->willReturn($configNames); |
|
| 107 | - $this->consoleInput->method('getOption') |
|
| 108 | - ->willReturnMap([ |
|
| 109 | - ['value', 'foobar'], |
|
| 110 | - ['type', 'string'], |
|
| 111 | - ['update-only', true], |
|
| 112 | - ]); |
|
| 113 | - |
|
| 114 | - $this->invokePrivate($this->command, 'execute', [$this->consoleInput, $this->consoleOutput]); |
|
| 115 | - } |
|
| 18 | + /** @var \PHPUnit\Framework\MockObject\MockObject */ |
|
| 19 | + protected $systemConfig; |
|
| 20 | + |
|
| 21 | + /** @var \PHPUnit\Framework\MockObject\MockObject */ |
|
| 22 | + protected $consoleInput; |
|
| 23 | + /** @var \PHPUnit\Framework\MockObject\MockObject */ |
|
| 24 | + protected $consoleOutput; |
|
| 25 | + |
|
| 26 | + /** @var \Symfony\Component\Console\Command\Command */ |
|
| 27 | + protected $command; |
|
| 28 | + |
|
| 29 | + protected function setUp(): void { |
|
| 30 | + parent::setUp(); |
|
| 31 | + |
|
| 32 | + $systemConfig = $this->systemConfig = $this->getMockBuilder(SystemConfig::class) |
|
| 33 | + ->disableOriginalConstructor() |
|
| 34 | + ->getMock(); |
|
| 35 | + $this->consoleInput = $this->getMockBuilder(InputInterface::class)->getMock(); |
|
| 36 | + $this->consoleOutput = $this->getMockBuilder(OutputInterface::class)->getMock(); |
|
| 37 | + |
|
| 38 | + /** @var \OC\SystemConfig $systemConfig */ |
|
| 39 | + $this->command = new SetConfig($systemConfig, new CastHelper()); |
|
| 40 | + } |
|
| 41 | + |
|
| 42 | + |
|
| 43 | + public static function dataTest() { |
|
| 44 | + return [ |
|
| 45 | + [['name'], 'newvalue', null, 'newvalue'], |
|
| 46 | + [['a', 'b', 'c'], 'foobar', null, ['b' => ['c' => 'foobar']]], |
|
| 47 | + [['a', 'b', 'c'], 'foobar', ['b' => ['d' => 'barfoo']], ['b' => ['d' => 'barfoo', 'c' => 'foobar']]], |
|
| 48 | + ]; |
|
| 49 | + } |
|
| 50 | + |
|
| 51 | + /** |
|
| 52 | + * @dataProvider dataTest |
|
| 53 | + * |
|
| 54 | + * @param array $configNames |
|
| 55 | + * @param string $newValue |
|
| 56 | + * @param mixed $existingData |
|
| 57 | + * @param mixed $expectedValue |
|
| 58 | + */ |
|
| 59 | + public function testSet($configNames, $newValue, $existingData, $expectedValue): void { |
|
| 60 | + $this->systemConfig->expects($this->once()) |
|
| 61 | + ->method('setValue') |
|
| 62 | + ->with($configNames[0], $expectedValue); |
|
| 63 | + $this->systemConfig->method('getValue') |
|
| 64 | + ->with($configNames[0]) |
|
| 65 | + ->willReturn($existingData); |
|
| 66 | + |
|
| 67 | + $this->consoleInput->expects($this->once()) |
|
| 68 | + ->method('getArgument') |
|
| 69 | + ->with('name') |
|
| 70 | + ->willReturn($configNames); |
|
| 71 | + $this->consoleInput->method('getOption') |
|
| 72 | + ->willReturnMap([ |
|
| 73 | + ['value', $newValue], |
|
| 74 | + ['type', 'string'], |
|
| 75 | + ]); |
|
| 76 | + |
|
| 77 | + $this->invokePrivate($this->command, 'execute', [$this->consoleInput, $this->consoleOutput]); |
|
| 78 | + } |
|
| 79 | + |
|
| 80 | + public static function setUpdateOnlyProvider(): array { |
|
| 81 | + return [ |
|
| 82 | + [['name'], null], |
|
| 83 | + [['a', 'b', 'c'], null], |
|
| 84 | + [['a', 'b', 'c'], ['b' => 'foobar']], |
|
| 85 | + [['a', 'b', 'c'], ['b' => ['d' => 'foobar']]], |
|
| 86 | + ]; |
|
| 87 | + } |
|
| 88 | + |
|
| 89 | + /** |
|
| 90 | + * @dataProvider setUpdateOnlyProvider |
|
| 91 | + */ |
|
| 92 | + public function testSetUpdateOnly($configNames, $existingData): void { |
|
| 93 | + $this->expectException(\UnexpectedValueException::class); |
|
| 94 | + |
|
| 95 | + $this->systemConfig->expects($this->never()) |
|
| 96 | + ->method('setValue'); |
|
| 97 | + $this->systemConfig->method('getValue') |
|
| 98 | + ->with($configNames[0]) |
|
| 99 | + ->willReturn($existingData); |
|
| 100 | + $this->systemConfig->method('getKeys') |
|
| 101 | + ->willReturn($existingData ? $configNames[0] : []); |
|
| 102 | + |
|
| 103 | + $this->consoleInput->expects($this->once()) |
|
| 104 | + ->method('getArgument') |
|
| 105 | + ->with('name') |
|
| 106 | + ->willReturn($configNames); |
|
| 107 | + $this->consoleInput->method('getOption') |
|
| 108 | + ->willReturnMap([ |
|
| 109 | + ['value', 'foobar'], |
|
| 110 | + ['type', 'string'], |
|
| 111 | + ['update-only', true], |
|
| 112 | + ]); |
|
| 113 | + |
|
| 114 | + $this->invokePrivate($this->command, 'execute', [$this->consoleInput, $this->consoleOutput]); |
|
| 115 | + } |
|
| 116 | 116 | } |
@@ -122,141 +122,141 @@ |
||
| 122 | 122 | $config = Server::get(IConfig::class); |
| 123 | 123 | |
| 124 | 124 | if ($config->getSystemValueBool('installed', false)) { |
| 125 | - $application->add(Server::get(Disable::class)); |
|
| 126 | - $application->add(Server::get(Enable::class)); |
|
| 127 | - $application->add(Server::get(Install::class)); |
|
| 128 | - $application->add(Server::get(GetPath::class)); |
|
| 129 | - $application->add(Server::get(ListApps::class)); |
|
| 130 | - $application->add(Server::get(Remove::class)); |
|
| 131 | - $application->add(Server::get(Update::class)); |
|
| 125 | + $application->add(Server::get(Disable::class)); |
|
| 126 | + $application->add(Server::get(Enable::class)); |
|
| 127 | + $application->add(Server::get(Install::class)); |
|
| 128 | + $application->add(Server::get(GetPath::class)); |
|
| 129 | + $application->add(Server::get(ListApps::class)); |
|
| 130 | + $application->add(Server::get(Remove::class)); |
|
| 131 | + $application->add(Server::get(Update::class)); |
|
| 132 | 132 | |
| 133 | - $application->add(Server::get(Cleanup::class)); |
|
| 134 | - $application->add(Server::get(Enforce::class)); |
|
| 135 | - $application->add(Server::get(Command\TwoFactorAuth\Enable::class)); |
|
| 136 | - $application->add(Server::get(Command\TwoFactorAuth\Disable::class)); |
|
| 137 | - $application->add(Server::get(State::class)); |
|
| 133 | + $application->add(Server::get(Cleanup::class)); |
|
| 134 | + $application->add(Server::get(Enforce::class)); |
|
| 135 | + $application->add(Server::get(Command\TwoFactorAuth\Enable::class)); |
|
| 136 | + $application->add(Server::get(Command\TwoFactorAuth\Disable::class)); |
|
| 137 | + $application->add(Server::get(State::class)); |
|
| 138 | 138 | |
| 139 | - $application->add(Server::get(Mode::class)); |
|
| 140 | - $application->add(Server::get(Job::class)); |
|
| 141 | - $application->add(Server::get(ListCommand::class)); |
|
| 142 | - $application->add(Server::get(Delete::class)); |
|
| 143 | - $application->add(Server::get(JobWorker::class)); |
|
| 139 | + $application->add(Server::get(Mode::class)); |
|
| 140 | + $application->add(Server::get(Job::class)); |
|
| 141 | + $application->add(Server::get(ListCommand::class)); |
|
| 142 | + $application->add(Server::get(Delete::class)); |
|
| 143 | + $application->add(Server::get(JobWorker::class)); |
|
| 144 | 144 | |
| 145 | - $application->add(Server::get(Test::class)); |
|
| 145 | + $application->add(Server::get(Test::class)); |
|
| 146 | 146 | |
| 147 | - $application->add(Server::get(DeleteConfig::class)); |
|
| 148 | - $application->add(Server::get(GetConfig::class)); |
|
| 149 | - $application->add(Server::get(SetConfig::class)); |
|
| 150 | - $application->add(Server::get(Import::class)); |
|
| 151 | - $application->add(Server::get(ListConfigs::class)); |
|
| 152 | - $application->add(Server::get(Command\Config\System\DeleteConfig::class)); |
|
| 153 | - $application->add(Server::get(Command\Config\System\GetConfig::class)); |
|
| 154 | - $application->add(Server::get(Command\Config\System\SetConfig::class)); |
|
| 147 | + $application->add(Server::get(DeleteConfig::class)); |
|
| 148 | + $application->add(Server::get(GetConfig::class)); |
|
| 149 | + $application->add(Server::get(SetConfig::class)); |
|
| 150 | + $application->add(Server::get(Import::class)); |
|
| 151 | + $application->add(Server::get(ListConfigs::class)); |
|
| 152 | + $application->add(Server::get(Command\Config\System\DeleteConfig::class)); |
|
| 153 | + $application->add(Server::get(Command\Config\System\GetConfig::class)); |
|
| 154 | + $application->add(Server::get(Command\Config\System\SetConfig::class)); |
|
| 155 | 155 | |
| 156 | - $application->add(Server::get(File::class)); |
|
| 157 | - $application->add(Server::get(Space::class)); |
|
| 158 | - $application->add(Server::get(Storage::class)); |
|
| 159 | - $application->add(Server::get(Storages::class)); |
|
| 156 | + $application->add(Server::get(File::class)); |
|
| 157 | + $application->add(Server::get(Space::class)); |
|
| 158 | + $application->add(Server::get(Storage::class)); |
|
| 159 | + $application->add(Server::get(Storages::class)); |
|
| 160 | 160 | |
| 161 | - $application->add(Server::get(ConvertType::class)); |
|
| 162 | - $application->add(Server::get(ConvertMysqlToMB4::class)); |
|
| 163 | - $application->add(Server::get(ConvertFilecacheBigInt::class)); |
|
| 164 | - $application->add(Server::get(AddMissingColumns::class)); |
|
| 165 | - $application->add(Server::get(AddMissingIndices::class)); |
|
| 166 | - $application->add(Server::get(AddMissingPrimaryKeys::class)); |
|
| 167 | - $application->add(Server::get(ExpectedSchema::class)); |
|
| 168 | - $application->add(Server::get(ExportSchema::class)); |
|
| 161 | + $application->add(Server::get(ConvertType::class)); |
|
| 162 | + $application->add(Server::get(ConvertMysqlToMB4::class)); |
|
| 163 | + $application->add(Server::get(ConvertFilecacheBigInt::class)); |
|
| 164 | + $application->add(Server::get(AddMissingColumns::class)); |
|
| 165 | + $application->add(Server::get(AddMissingIndices::class)); |
|
| 166 | + $application->add(Server::get(AddMissingPrimaryKeys::class)); |
|
| 167 | + $application->add(Server::get(ExpectedSchema::class)); |
|
| 168 | + $application->add(Server::get(ExportSchema::class)); |
|
| 169 | 169 | |
| 170 | - $application->add(Server::get(GenerateMetadataCommand::class)); |
|
| 171 | - $application->add(Server::get(PreviewCommand::class)); |
|
| 172 | - if ($config->getSystemValueBool('debug', false)) { |
|
| 173 | - $application->add(Server::get(StatusCommand::class)); |
|
| 174 | - $application->add(Server::get(MigrateCommand::class)); |
|
| 175 | - $application->add(Server::get(GenerateCommand::class)); |
|
| 176 | - $application->add(Server::get(ExecuteCommand::class)); |
|
| 177 | - } |
|
| 170 | + $application->add(Server::get(GenerateMetadataCommand::class)); |
|
| 171 | + $application->add(Server::get(PreviewCommand::class)); |
|
| 172 | + if ($config->getSystemValueBool('debug', false)) { |
|
| 173 | + $application->add(Server::get(StatusCommand::class)); |
|
| 174 | + $application->add(Server::get(MigrateCommand::class)); |
|
| 175 | + $application->add(Server::get(GenerateCommand::class)); |
|
| 176 | + $application->add(Server::get(ExecuteCommand::class)); |
|
| 177 | + } |
|
| 178 | 178 | |
| 179 | - $application->add(Server::get(Command\Encryption\Disable::class)); |
|
| 180 | - $application->add(Server::get(Command\Encryption\Enable::class)); |
|
| 181 | - $application->add(Server::get(ListModules::class)); |
|
| 182 | - $application->add(Server::get(SetDefaultModule::class)); |
|
| 183 | - $application->add(Server::get(Command\Encryption\Status::class)); |
|
| 184 | - $application->add(Server::get(EncryptAll::class)); |
|
| 185 | - $application->add(Server::get(DecryptAll::class)); |
|
| 179 | + $application->add(Server::get(Command\Encryption\Disable::class)); |
|
| 180 | + $application->add(Server::get(Command\Encryption\Enable::class)); |
|
| 181 | + $application->add(Server::get(ListModules::class)); |
|
| 182 | + $application->add(Server::get(SetDefaultModule::class)); |
|
| 183 | + $application->add(Server::get(Command\Encryption\Status::class)); |
|
| 184 | + $application->add(Server::get(EncryptAll::class)); |
|
| 185 | + $application->add(Server::get(DecryptAll::class)); |
|
| 186 | 186 | |
| 187 | - $application->add(Server::get(Manage::class)); |
|
| 188 | - $application->add(Server::get(Command\Log\File::class)); |
|
| 187 | + $application->add(Server::get(Manage::class)); |
|
| 188 | + $application->add(Server::get(Command\Log\File::class)); |
|
| 189 | 189 | |
| 190 | - $application->add(Server::get(ChangeKeyStorageRoot::class)); |
|
| 191 | - $application->add(Server::get(ShowKeyStorageRoot::class)); |
|
| 192 | - $application->add(Server::get(MigrateKeyStorage::class)); |
|
| 190 | + $application->add(Server::get(ChangeKeyStorageRoot::class)); |
|
| 191 | + $application->add(Server::get(ShowKeyStorageRoot::class)); |
|
| 192 | + $application->add(Server::get(MigrateKeyStorage::class)); |
|
| 193 | 193 | |
| 194 | - $application->add(Server::get(DataFingerprint::class)); |
|
| 195 | - $application->add(Server::get(UpdateDB::class)); |
|
| 196 | - $application->add(Server::get(UpdateJS::class)); |
|
| 197 | - $application->add(Server::get(Command\Maintenance\Mode::class)); |
|
| 198 | - $application->add(Server::get(UpdateHtaccess::class)); |
|
| 199 | - $application->add(Server::get(UpdateTheme::class)); |
|
| 194 | + $application->add(Server::get(DataFingerprint::class)); |
|
| 195 | + $application->add(Server::get(UpdateDB::class)); |
|
| 196 | + $application->add(Server::get(UpdateJS::class)); |
|
| 197 | + $application->add(Server::get(Command\Maintenance\Mode::class)); |
|
| 198 | + $application->add(Server::get(UpdateHtaccess::class)); |
|
| 199 | + $application->add(Server::get(UpdateTheme::class)); |
|
| 200 | 200 | |
| 201 | - $application->add(Server::get(Upgrade::class)); |
|
| 202 | - $application->add(Server::get(Repair::class)); |
|
| 203 | - $application->add(Server::get(RepairShareOwnership::class)); |
|
| 201 | + $application->add(Server::get(Upgrade::class)); |
|
| 202 | + $application->add(Server::get(Repair::class)); |
|
| 203 | + $application->add(Server::get(RepairShareOwnership::class)); |
|
| 204 | 204 | |
| 205 | - $application->add(Server::get(Command\Preview\Cleanup::class)); |
|
| 206 | - $application->add(Server::get(Generate::class)); |
|
| 207 | - $application->add(Server::get(Command\Preview\Repair::class)); |
|
| 208 | - $application->add(Server::get(ResetRenderedTexts::class)); |
|
| 205 | + $application->add(Server::get(Command\Preview\Cleanup::class)); |
|
| 206 | + $application->add(Server::get(Generate::class)); |
|
| 207 | + $application->add(Server::get(Command\Preview\Repair::class)); |
|
| 208 | + $application->add(Server::get(ResetRenderedTexts::class)); |
|
| 209 | 209 | |
| 210 | - $application->add(Server::get(Add::class)); |
|
| 211 | - $application->add(Server::get(Command\User\Delete::class)); |
|
| 212 | - $application->add(Server::get(Command\User\Disable::class)); |
|
| 213 | - $application->add(Server::get(Command\User\Enable::class)); |
|
| 214 | - $application->add(Server::get(LastSeen::class)); |
|
| 215 | - $application->add(Server::get(Report::class)); |
|
| 216 | - $application->add(Server::get(ResetPassword::class)); |
|
| 217 | - $application->add(Server::get(Setting::class)); |
|
| 218 | - $application->add(Server::get(Profile::class)); |
|
| 219 | - $application->add(Server::get(Command\User\ListCommand::class)); |
|
| 220 | - $application->add(Server::get(ClearGeneratedAvatarCacheCommand::class)); |
|
| 221 | - $application->add(Server::get(Info::class)); |
|
| 222 | - $application->add(Server::get(SyncAccountDataCommand::class)); |
|
| 223 | - $application->add(Server::get(Command\User\AuthTokens\Add::class)); |
|
| 224 | - $application->add(Server::get(Command\User\AuthTokens\ListCommand::class)); |
|
| 225 | - $application->add(Server::get(Command\User\AuthTokens\Delete::class)); |
|
| 226 | - $application->add(Server::get(Verify::class)); |
|
| 227 | - $application->add(Server::get(Welcome::class)); |
|
| 210 | + $application->add(Server::get(Add::class)); |
|
| 211 | + $application->add(Server::get(Command\User\Delete::class)); |
|
| 212 | + $application->add(Server::get(Command\User\Disable::class)); |
|
| 213 | + $application->add(Server::get(Command\User\Enable::class)); |
|
| 214 | + $application->add(Server::get(LastSeen::class)); |
|
| 215 | + $application->add(Server::get(Report::class)); |
|
| 216 | + $application->add(Server::get(ResetPassword::class)); |
|
| 217 | + $application->add(Server::get(Setting::class)); |
|
| 218 | + $application->add(Server::get(Profile::class)); |
|
| 219 | + $application->add(Server::get(Command\User\ListCommand::class)); |
|
| 220 | + $application->add(Server::get(ClearGeneratedAvatarCacheCommand::class)); |
|
| 221 | + $application->add(Server::get(Info::class)); |
|
| 222 | + $application->add(Server::get(SyncAccountDataCommand::class)); |
|
| 223 | + $application->add(Server::get(Command\User\AuthTokens\Add::class)); |
|
| 224 | + $application->add(Server::get(Command\User\AuthTokens\ListCommand::class)); |
|
| 225 | + $application->add(Server::get(Command\User\AuthTokens\Delete::class)); |
|
| 226 | + $application->add(Server::get(Verify::class)); |
|
| 227 | + $application->add(Server::get(Welcome::class)); |
|
| 228 | 228 | |
| 229 | - $application->add(Server::get(Command\Group\Add::class)); |
|
| 230 | - $application->add(Server::get(Command\Group\Delete::class)); |
|
| 231 | - $application->add(Server::get(Command\Group\ListCommand::class)); |
|
| 232 | - $application->add(Server::get(AddUser::class)); |
|
| 233 | - $application->add(Server::get(RemoveUser::class)); |
|
| 234 | - $application->add(Server::get(Command\Group\Info::class)); |
|
| 229 | + $application->add(Server::get(Command\Group\Add::class)); |
|
| 230 | + $application->add(Server::get(Command\Group\Delete::class)); |
|
| 231 | + $application->add(Server::get(Command\Group\ListCommand::class)); |
|
| 232 | + $application->add(Server::get(AddUser::class)); |
|
| 233 | + $application->add(Server::get(RemoveUser::class)); |
|
| 234 | + $application->add(Server::get(Command\Group\Info::class)); |
|
| 235 | 235 | |
| 236 | - $application->add(Server::get(Command\SystemTag\ListCommand::class)); |
|
| 237 | - $application->add(Server::get(Command\SystemTag\Delete::class)); |
|
| 238 | - $application->add(Server::get(Command\SystemTag\Add::class)); |
|
| 239 | - $application->add(Server::get(Edit::class)); |
|
| 236 | + $application->add(Server::get(Command\SystemTag\ListCommand::class)); |
|
| 237 | + $application->add(Server::get(Command\SystemTag\Delete::class)); |
|
| 238 | + $application->add(Server::get(Command\SystemTag\Add::class)); |
|
| 239 | + $application->add(Server::get(Edit::class)); |
|
| 240 | 240 | |
| 241 | - $application->add(Server::get(ListCertificates::class)); |
|
| 242 | - $application->add(Server::get(ExportCertificates::class)); |
|
| 243 | - $application->add(Server::get(ImportCertificate::class)); |
|
| 244 | - $application->add(Server::get(RemoveCertificate::class)); |
|
| 245 | - $application->add(Server::get(BruteforceAttempts::class)); |
|
| 246 | - $application->add(Server::get(BruteforceResetAttempts::class)); |
|
| 247 | - $application->add(Server::get(SetupChecks::class)); |
|
| 248 | - $application->add(Server::get(Get::class)); |
|
| 241 | + $application->add(Server::get(ListCertificates::class)); |
|
| 242 | + $application->add(Server::get(ExportCertificates::class)); |
|
| 243 | + $application->add(Server::get(ImportCertificate::class)); |
|
| 244 | + $application->add(Server::get(RemoveCertificate::class)); |
|
| 245 | + $application->add(Server::get(BruteforceAttempts::class)); |
|
| 246 | + $application->add(Server::get(BruteforceResetAttempts::class)); |
|
| 247 | + $application->add(Server::get(SetupChecks::class)); |
|
| 248 | + $application->add(Server::get(Get::class)); |
|
| 249 | 249 | |
| 250 | - $application->add(Server::get(GetCommand::class)); |
|
| 251 | - $application->add(Server::get(EnabledCommand::class)); |
|
| 252 | - $application->add(Server::get(Command\TaskProcessing\ListCommand::class)); |
|
| 253 | - $application->add(Server::get(Statistics::class)); |
|
| 250 | + $application->add(Server::get(GetCommand::class)); |
|
| 251 | + $application->add(Server::get(EnabledCommand::class)); |
|
| 252 | + $application->add(Server::get(Command\TaskProcessing\ListCommand::class)); |
|
| 253 | + $application->add(Server::get(Statistics::class)); |
|
| 254 | 254 | |
| 255 | - $application->add(Server::get(RedisCommand::class)); |
|
| 256 | - $application->add(Server::get(DistributedClear::class)); |
|
| 257 | - $application->add(Server::get(DistributedDelete::class)); |
|
| 258 | - $application->add(Server::get(DistributedGet::class)); |
|
| 259 | - $application->add(Server::get(DistributedSet::class)); |
|
| 255 | + $application->add(Server::get(RedisCommand::class)); |
|
| 256 | + $application->add(Server::get(DistributedClear::class)); |
|
| 257 | + $application->add(Server::get(DistributedDelete::class)); |
|
| 258 | + $application->add(Server::get(DistributedGet::class)); |
|
| 259 | + $application->add(Server::get(DistributedSet::class)); |
|
| 260 | 260 | } else { |
| 261 | - $application->add(Server::get(Command\Maintenance\Install::class)); |
|
| 261 | + $application->add(Server::get(Command\Maintenance\Install::class)); |
|
| 262 | 262 | } |
@@ -15,29 +15,29 @@ |
||
| 15 | 15 | use Symfony\Component\Console\Output\OutputInterface; |
| 16 | 16 | |
| 17 | 17 | class DistributedDelete extends Base { |
| 18 | - public function __construct( |
|
| 19 | - protected ICacheFactory $cacheFactory, |
|
| 20 | - ) { |
|
| 21 | - parent::__construct(); |
|
| 22 | - } |
|
| 18 | + public function __construct( |
|
| 19 | + protected ICacheFactory $cacheFactory, |
|
| 20 | + ) { |
|
| 21 | + parent::__construct(); |
|
| 22 | + } |
|
| 23 | 23 | |
| 24 | - protected function configure(): void { |
|
| 25 | - $this |
|
| 26 | - ->setName('memcache:distributed:delete') |
|
| 27 | - ->setDescription('Delete a value in the distributed memcache') |
|
| 28 | - ->addArgument('key', InputArgument::REQUIRED, 'The key to delete'); |
|
| 29 | - parent::configure(); |
|
| 30 | - } |
|
| 24 | + protected function configure(): void { |
|
| 25 | + $this |
|
| 26 | + ->setName('memcache:distributed:delete') |
|
| 27 | + ->setDescription('Delete a value in the distributed memcache') |
|
| 28 | + ->addArgument('key', InputArgument::REQUIRED, 'The key to delete'); |
|
| 29 | + parent::configure(); |
|
| 30 | + } |
|
| 31 | 31 | |
| 32 | - protected function execute(InputInterface $input, OutputInterface $output): int { |
|
| 33 | - $cache = $this->cacheFactory->createDistributed(); |
|
| 34 | - $key = $input->getArgument('key'); |
|
| 35 | - if ($cache->remove($key)) { |
|
| 36 | - $output->writeln('<info>Distributed cache key <info>' . $key . '</info> deleted</info>'); |
|
| 37 | - return 0; |
|
| 38 | - } else { |
|
| 39 | - $output->writeln('<error>Failed to delete cache key ' . $key . '</error>'); |
|
| 40 | - return 1; |
|
| 41 | - } |
|
| 42 | - } |
|
| 32 | + protected function execute(InputInterface $input, OutputInterface $output): int { |
|
| 33 | + $cache = $this->cacheFactory->createDistributed(); |
|
| 34 | + $key = $input->getArgument('key'); |
|
| 35 | + if ($cache->remove($key)) { |
|
| 36 | + $output->writeln('<info>Distributed cache key <info>' . $key . '</info> deleted</info>'); |
|
| 37 | + return 0; |
|
| 38 | + } else { |
|
| 39 | + $output->writeln('<error>Failed to delete cache key ' . $key . '</error>'); |
|
| 40 | + return 1; |
|
| 41 | + } |
|
| 42 | + } |
|
| 43 | 43 | } |
@@ -15,33 +15,33 @@ |
||
| 15 | 15 | use Symfony\Component\Console\Output\OutputInterface; |
| 16 | 16 | |
| 17 | 17 | class DistributedClear extends Base { |
| 18 | - public function __construct( |
|
| 19 | - protected ICacheFactory $cacheFactory, |
|
| 20 | - ) { |
|
| 21 | - parent::__construct(); |
|
| 22 | - } |
|
| 18 | + public function __construct( |
|
| 19 | + protected ICacheFactory $cacheFactory, |
|
| 20 | + ) { |
|
| 21 | + parent::__construct(); |
|
| 22 | + } |
|
| 23 | 23 | |
| 24 | - protected function configure(): void { |
|
| 25 | - $this |
|
| 26 | - ->setName('memcache:distributed:clear') |
|
| 27 | - ->setDescription('Clear values from the distributed memcache') |
|
| 28 | - ->addOption('prefix', null, InputOption::VALUE_REQUIRED, 'Only remove keys matching the prefix'); |
|
| 29 | - parent::configure(); |
|
| 30 | - } |
|
| 24 | + protected function configure(): void { |
|
| 25 | + $this |
|
| 26 | + ->setName('memcache:distributed:clear') |
|
| 27 | + ->setDescription('Clear values from the distributed memcache') |
|
| 28 | + ->addOption('prefix', null, InputOption::VALUE_REQUIRED, 'Only remove keys matching the prefix'); |
|
| 29 | + parent::configure(); |
|
| 30 | + } |
|
| 31 | 31 | |
| 32 | - protected function execute(InputInterface $input, OutputInterface $output): int { |
|
| 33 | - $cache = $this->cacheFactory->createDistributed(); |
|
| 34 | - $prefix = $input->getOption('prefix'); |
|
| 35 | - if ($cache->clear($prefix)) { |
|
| 36 | - if ($prefix) { |
|
| 37 | - $output->writeln('<info>Distributed cache matching prefix ' . $prefix . ' cleared</info>'); |
|
| 38 | - } else { |
|
| 39 | - $output->writeln('<info>Distributed cache cleared</info>'); |
|
| 40 | - } |
|
| 41 | - return 0; |
|
| 42 | - } else { |
|
| 43 | - $output->writeln('<error>Failed to clear cache</error>'); |
|
| 44 | - return 1; |
|
| 45 | - } |
|
| 46 | - } |
|
| 32 | + protected function execute(InputInterface $input, OutputInterface $output): int { |
|
| 33 | + $cache = $this->cacheFactory->createDistributed(); |
|
| 34 | + $prefix = $input->getOption('prefix'); |
|
| 35 | + if ($cache->clear($prefix)) { |
|
| 36 | + if ($prefix) { |
|
| 37 | + $output->writeln('<info>Distributed cache matching prefix ' . $prefix . ' cleared</info>'); |
|
| 38 | + } else { |
|
| 39 | + $output->writeln('<info>Distributed cache cleared</info>'); |
|
| 40 | + } |
|
| 41 | + return 0; |
|
| 42 | + } else { |
|
| 43 | + $output->writeln('<error>Failed to clear cache</error>'); |
|
| 44 | + return 1; |
|
| 45 | + } |
|
| 46 | + } |
|
| 47 | 47 | } |
@@ -15,26 +15,26 @@ |
||
| 15 | 15 | use Symfony\Component\Console\Output\OutputInterface; |
| 16 | 16 | |
| 17 | 17 | class DistributedGet extends Base { |
| 18 | - public function __construct( |
|
| 19 | - protected ICacheFactory $cacheFactory, |
|
| 20 | - ) { |
|
| 21 | - parent::__construct(); |
|
| 22 | - } |
|
| 18 | + public function __construct( |
|
| 19 | + protected ICacheFactory $cacheFactory, |
|
| 20 | + ) { |
|
| 21 | + parent::__construct(); |
|
| 22 | + } |
|
| 23 | 23 | |
| 24 | - protected function configure(): void { |
|
| 25 | - $this |
|
| 26 | - ->setName('memcache:distributed:get') |
|
| 27 | - ->setDescription('Get a value from the distributed memcache') |
|
| 28 | - ->addArgument('key', InputArgument::REQUIRED, 'The key to retrieve'); |
|
| 29 | - parent::configure(); |
|
| 30 | - } |
|
| 24 | + protected function configure(): void { |
|
| 25 | + $this |
|
| 26 | + ->setName('memcache:distributed:get') |
|
| 27 | + ->setDescription('Get a value from the distributed memcache') |
|
| 28 | + ->addArgument('key', InputArgument::REQUIRED, 'The key to retrieve'); |
|
| 29 | + parent::configure(); |
|
| 30 | + } |
|
| 31 | 31 | |
| 32 | - protected function execute(InputInterface $input, OutputInterface $output): int { |
|
| 33 | - $cache = $this->cacheFactory->createDistributed(); |
|
| 34 | - $key = $input->getArgument('key'); |
|
| 32 | + protected function execute(InputInterface $input, OutputInterface $output): int { |
|
| 33 | + $cache = $this->cacheFactory->createDistributed(); |
|
| 34 | + $key = $input->getArgument('key'); |
|
| 35 | 35 | |
| 36 | - $value = $cache->get($key); |
|
| 37 | - $this->writeMixedInOutputFormat($input, $output, $value); |
|
| 38 | - return 0; |
|
| 39 | - } |
|
| 36 | + $value = $cache->get($key); |
|
| 37 | + $this->writeMixedInOutputFormat($input, $output, $value); |
|
| 38 | + return 0; |
|
| 39 | + } |
|
| 40 | 40 | } |
@@ -17,41 +17,41 @@ |
||
| 17 | 17 | use Symfony\Component\Console\Output\OutputInterface; |
| 18 | 18 | |
| 19 | 19 | class DistributedSet extends Base { |
| 20 | - public function __construct( |
|
| 21 | - protected ICacheFactory $cacheFactory, |
|
| 22 | - private CastHelper $castHelper, |
|
| 23 | - ) { |
|
| 24 | - parent::__construct(); |
|
| 25 | - } |
|
| 20 | + public function __construct( |
|
| 21 | + protected ICacheFactory $cacheFactory, |
|
| 22 | + private CastHelper $castHelper, |
|
| 23 | + ) { |
|
| 24 | + parent::__construct(); |
|
| 25 | + } |
|
| 26 | 26 | |
| 27 | - protected function configure(): void { |
|
| 28 | - $this |
|
| 29 | - ->setName('memcache:distributed:set') |
|
| 30 | - ->setDescription('Set a value in the distributed memcache') |
|
| 31 | - ->addArgument('key', InputArgument::REQUIRED, 'The key to set') |
|
| 32 | - ->addArgument('value', InputArgument::REQUIRED, 'The value to set') |
|
| 33 | - ->addOption( |
|
| 34 | - 'type', |
|
| 35 | - null, |
|
| 36 | - InputOption::VALUE_REQUIRED, |
|
| 37 | - 'Value type [string, integer, float, boolean, json, null]', |
|
| 38 | - 'string' |
|
| 39 | - ); |
|
| 40 | - parent::configure(); |
|
| 41 | - } |
|
| 27 | + protected function configure(): void { |
|
| 28 | + $this |
|
| 29 | + ->setName('memcache:distributed:set') |
|
| 30 | + ->setDescription('Set a value in the distributed memcache') |
|
| 31 | + ->addArgument('key', InputArgument::REQUIRED, 'The key to set') |
|
| 32 | + ->addArgument('value', InputArgument::REQUIRED, 'The value to set') |
|
| 33 | + ->addOption( |
|
| 34 | + 'type', |
|
| 35 | + null, |
|
| 36 | + InputOption::VALUE_REQUIRED, |
|
| 37 | + 'Value type [string, integer, float, boolean, json, null]', |
|
| 38 | + 'string' |
|
| 39 | + ); |
|
| 40 | + parent::configure(); |
|
| 41 | + } |
|
| 42 | 42 | |
| 43 | - protected function execute(InputInterface $input, OutputInterface $output): int { |
|
| 44 | - $cache = $this->cacheFactory->createDistributed(); |
|
| 45 | - $key = $input->getArgument('key'); |
|
| 46 | - $value = $input->getArgument('value'); |
|
| 47 | - $type = $input->getOption('type'); |
|
| 48 | - ['value' => $value, 'readable-value' => $readable] = $this->castHelper->castValue($value, $type); |
|
| 49 | - if ($cache->set($key, $value)) { |
|
| 50 | - $output->writeln('Distributed cache key <info>' . $key . '</info> set to <info>' . $readable . '</info>'); |
|
| 51 | - return 0; |
|
| 52 | - } else { |
|
| 53 | - $output->writeln('<error>Failed to set cache key ' . $key . '</error>'); |
|
| 54 | - return 1; |
|
| 55 | - } |
|
| 56 | - } |
|
| 43 | + protected function execute(InputInterface $input, OutputInterface $output): int { |
|
| 44 | + $cache = $this->cacheFactory->createDistributed(); |
|
| 45 | + $key = $input->getArgument('key'); |
|
| 46 | + $value = $input->getArgument('value'); |
|
| 47 | + $type = $input->getOption('type'); |
|
| 48 | + ['value' => $value, 'readable-value' => $readable] = $this->castHelper->castValue($value, $type); |
|
| 49 | + if ($cache->set($key, $value)) { |
|
| 50 | + $output->writeln('Distributed cache key <info>' . $key . '</info> set to <info>' . $readable . '</info>'); |
|
| 51 | + return 0; |
|
| 52 | + } else { |
|
| 53 | + $output->writeln('<error>Failed to set cache key ' . $key . '</error>'); |
|
| 54 | + return 1; |
|
| 55 | + } |
|
| 56 | + } |
|
| 57 | 57 | } |
@@ -15,110 +15,110 @@ |
||
| 15 | 15 | use Symfony\Component\Console\Output\OutputInterface; |
| 16 | 16 | |
| 17 | 17 | class SetConfig extends Base { |
| 18 | - public function __construct( |
|
| 19 | - SystemConfig $systemConfig, |
|
| 20 | - private CastHelper $castHelper, |
|
| 21 | - ) { |
|
| 22 | - parent::__construct($systemConfig); |
|
| 23 | - } |
|
| 18 | + public function __construct( |
|
| 19 | + SystemConfig $systemConfig, |
|
| 20 | + private CastHelper $castHelper, |
|
| 21 | + ) { |
|
| 22 | + parent::__construct($systemConfig); |
|
| 23 | + } |
|
| 24 | 24 | |
| 25 | - protected function configure() { |
|
| 26 | - parent::configure(); |
|
| 25 | + protected function configure() { |
|
| 26 | + parent::configure(); |
|
| 27 | 27 | |
| 28 | - $this |
|
| 29 | - ->setName('config:system:set') |
|
| 30 | - ->setDescription('Set a system config value') |
|
| 31 | - ->addArgument( |
|
| 32 | - 'name', |
|
| 33 | - InputArgument::REQUIRED | InputArgument::IS_ARRAY, |
|
| 34 | - 'Name of the config parameter, specify multiple for array parameter' |
|
| 35 | - ) |
|
| 36 | - ->addOption( |
|
| 37 | - 'type', |
|
| 38 | - null, |
|
| 39 | - InputOption::VALUE_REQUIRED, |
|
| 40 | - 'Value type [string, integer, double, boolean]', |
|
| 41 | - 'string' |
|
| 42 | - ) |
|
| 43 | - ->addOption( |
|
| 44 | - 'value', |
|
| 45 | - null, |
|
| 46 | - InputOption::VALUE_REQUIRED, |
|
| 47 | - 'The new value of the config' |
|
| 48 | - ) |
|
| 49 | - ->addOption( |
|
| 50 | - 'update-only', |
|
| 51 | - null, |
|
| 52 | - InputOption::VALUE_NONE, |
|
| 53 | - 'Only updates the value, if it is not set before, it is not being added' |
|
| 54 | - ) |
|
| 55 | - ; |
|
| 56 | - } |
|
| 28 | + $this |
|
| 29 | + ->setName('config:system:set') |
|
| 30 | + ->setDescription('Set a system config value') |
|
| 31 | + ->addArgument( |
|
| 32 | + 'name', |
|
| 33 | + InputArgument::REQUIRED | InputArgument::IS_ARRAY, |
|
| 34 | + 'Name of the config parameter, specify multiple for array parameter' |
|
| 35 | + ) |
|
| 36 | + ->addOption( |
|
| 37 | + 'type', |
|
| 38 | + null, |
|
| 39 | + InputOption::VALUE_REQUIRED, |
|
| 40 | + 'Value type [string, integer, double, boolean]', |
|
| 41 | + 'string' |
|
| 42 | + ) |
|
| 43 | + ->addOption( |
|
| 44 | + 'value', |
|
| 45 | + null, |
|
| 46 | + InputOption::VALUE_REQUIRED, |
|
| 47 | + 'The new value of the config' |
|
| 48 | + ) |
|
| 49 | + ->addOption( |
|
| 50 | + 'update-only', |
|
| 51 | + null, |
|
| 52 | + InputOption::VALUE_NONE, |
|
| 53 | + 'Only updates the value, if it is not set before, it is not being added' |
|
| 54 | + ) |
|
| 55 | + ; |
|
| 56 | + } |
|
| 57 | 57 | |
| 58 | - protected function execute(InputInterface $input, OutputInterface $output): int { |
|
| 59 | - $configNames = $input->getArgument('name'); |
|
| 60 | - $configName = $configNames[0]; |
|
| 61 | - $configValue = $this->castHelper->castValue($input->getOption('value'), $input->getOption('type')); |
|
| 62 | - $updateOnly = $input->getOption('update-only'); |
|
| 58 | + protected function execute(InputInterface $input, OutputInterface $output): int { |
|
| 59 | + $configNames = $input->getArgument('name'); |
|
| 60 | + $configName = $configNames[0]; |
|
| 61 | + $configValue = $this->castHelper->castValue($input->getOption('value'), $input->getOption('type')); |
|
| 62 | + $updateOnly = $input->getOption('update-only'); |
|
| 63 | 63 | |
| 64 | - if (count($configNames) > 1) { |
|
| 65 | - $existingValue = $this->systemConfig->getValue($configName); |
|
| 64 | + if (count($configNames) > 1) { |
|
| 65 | + $existingValue = $this->systemConfig->getValue($configName); |
|
| 66 | 66 | |
| 67 | - $newValue = $this->mergeArrayValue( |
|
| 68 | - array_slice($configNames, 1), $existingValue, $configValue['value'], $updateOnly |
|
| 69 | - ); |
|
| 67 | + $newValue = $this->mergeArrayValue( |
|
| 68 | + array_slice($configNames, 1), $existingValue, $configValue['value'], $updateOnly |
|
| 69 | + ); |
|
| 70 | 70 | |
| 71 | - $this->systemConfig->setValue($configName, $newValue); |
|
| 72 | - } else { |
|
| 73 | - if ($updateOnly && !in_array($configName, $this->systemConfig->getKeys(), true)) { |
|
| 74 | - throw new \UnexpectedValueException('Config parameter does not exist'); |
|
| 75 | - } |
|
| 71 | + $this->systemConfig->setValue($configName, $newValue); |
|
| 72 | + } else { |
|
| 73 | + if ($updateOnly && !in_array($configName, $this->systemConfig->getKeys(), true)) { |
|
| 74 | + throw new \UnexpectedValueException('Config parameter does not exist'); |
|
| 75 | + } |
|
| 76 | 76 | |
| 77 | - $this->systemConfig->setValue($configName, $configValue['value']); |
|
| 78 | - } |
|
| 77 | + $this->systemConfig->setValue($configName, $configValue['value']); |
|
| 78 | + } |
|
| 79 | 79 | |
| 80 | - $output->writeln('<info>System config value ' . implode(' => ', $configNames) . ' set to ' . $configValue['readable-value'] . '</info>'); |
|
| 81 | - return 0; |
|
| 82 | - } |
|
| 80 | + $output->writeln('<info>System config value ' . implode(' => ', $configNames) . ' set to ' . $configValue['readable-value'] . '</info>'); |
|
| 81 | + return 0; |
|
| 82 | + } |
|
| 83 | 83 | |
| 84 | - /** |
|
| 85 | - * @param array $configNames |
|
| 86 | - * @param mixed $existingValues |
|
| 87 | - * @param mixed $value |
|
| 88 | - * @param bool $updateOnly |
|
| 89 | - * @return array merged value |
|
| 90 | - * @throws \UnexpectedValueException |
|
| 91 | - */ |
|
| 92 | - protected function mergeArrayValue(array $configNames, $existingValues, $value, $updateOnly) { |
|
| 93 | - $configName = array_shift($configNames); |
|
| 94 | - if (!is_array($existingValues)) { |
|
| 95 | - $existingValues = []; |
|
| 96 | - } |
|
| 97 | - if (!empty($configNames)) { |
|
| 98 | - if (isset($existingValues[$configName])) { |
|
| 99 | - $existingValue = $existingValues[$configName]; |
|
| 100 | - } else { |
|
| 101 | - $existingValue = []; |
|
| 102 | - } |
|
| 103 | - $existingValues[$configName] = $this->mergeArrayValue($configNames, $existingValue, $value, $updateOnly); |
|
| 104 | - } else { |
|
| 105 | - if (!isset($existingValues[$configName]) && $updateOnly) { |
|
| 106 | - throw new \UnexpectedValueException('Config parameter does not exist'); |
|
| 107 | - } |
|
| 108 | - $existingValues[$configName] = $value; |
|
| 109 | - } |
|
| 110 | - return $existingValues; |
|
| 111 | - } |
|
| 84 | + /** |
|
| 85 | + * @param array $configNames |
|
| 86 | + * @param mixed $existingValues |
|
| 87 | + * @param mixed $value |
|
| 88 | + * @param bool $updateOnly |
|
| 89 | + * @return array merged value |
|
| 90 | + * @throws \UnexpectedValueException |
|
| 91 | + */ |
|
| 92 | + protected function mergeArrayValue(array $configNames, $existingValues, $value, $updateOnly) { |
|
| 93 | + $configName = array_shift($configNames); |
|
| 94 | + if (!is_array($existingValues)) { |
|
| 95 | + $existingValues = []; |
|
| 96 | + } |
|
| 97 | + if (!empty($configNames)) { |
|
| 98 | + if (isset($existingValues[$configName])) { |
|
| 99 | + $existingValue = $existingValues[$configName]; |
|
| 100 | + } else { |
|
| 101 | + $existingValue = []; |
|
| 102 | + } |
|
| 103 | + $existingValues[$configName] = $this->mergeArrayValue($configNames, $existingValue, $value, $updateOnly); |
|
| 104 | + } else { |
|
| 105 | + if (!isset($existingValues[$configName]) && $updateOnly) { |
|
| 106 | + throw new \UnexpectedValueException('Config parameter does not exist'); |
|
| 107 | + } |
|
| 108 | + $existingValues[$configName] = $value; |
|
| 109 | + } |
|
| 110 | + return $existingValues; |
|
| 111 | + } |
|
| 112 | 112 | |
| 113 | - /** |
|
| 114 | - * @param string $optionName |
|
| 115 | - * @param CompletionContext $context |
|
| 116 | - * @return string[] |
|
| 117 | - */ |
|
| 118 | - public function completeOptionValues($optionName, CompletionContext $context) { |
|
| 119 | - if ($optionName === 'type') { |
|
| 120 | - return ['string', 'integer', 'double', 'boolean', 'json', 'null']; |
|
| 121 | - } |
|
| 122 | - return parent::completeOptionValues($optionName, $context); |
|
| 123 | - } |
|
| 113 | + /** |
|
| 114 | + * @param string $optionName |
|
| 115 | + * @param CompletionContext $context |
|
| 116 | + * @return string[] |
|
| 117 | + */ |
|
| 118 | + public function completeOptionValues($optionName, CompletionContext $context) { |
|
| 119 | + if ($optionName === 'type') { |
|
| 120 | + return ['string', 'integer', 'double', 'boolean', 'json', 'null']; |
|
| 121 | + } |
|
| 122 | + return parent::completeOptionValues($optionName, $context); |
|
| 123 | + } |
|
| 124 | 124 | } |
@@ -9,68 +9,68 @@ |
||
| 9 | 9 | namespace OC\Core\Command\Config\System; |
| 10 | 10 | |
| 11 | 11 | class CastHelper { |
| 12 | - /** |
|
| 13 | - * @return array{value: mixed, readable-value: string} |
|
| 14 | - */ |
|
| 15 | - public function castValue(?string $value, string $type): array { |
|
| 16 | - switch ($type) { |
|
| 17 | - case 'integer': |
|
| 18 | - case 'int': |
|
| 19 | - if (!is_numeric($value)) { |
|
| 20 | - throw new \InvalidArgumentException('Non-numeric value specified'); |
|
| 21 | - } |
|
| 22 | - return [ |
|
| 23 | - 'value' => (int)$value, |
|
| 24 | - 'readable-value' => 'integer ' . (int)$value, |
|
| 25 | - ]; |
|
| 12 | + /** |
|
| 13 | + * @return array{value: mixed, readable-value: string} |
|
| 14 | + */ |
|
| 15 | + public function castValue(?string $value, string $type): array { |
|
| 16 | + switch ($type) { |
|
| 17 | + case 'integer': |
|
| 18 | + case 'int': |
|
| 19 | + if (!is_numeric($value)) { |
|
| 20 | + throw new \InvalidArgumentException('Non-numeric value specified'); |
|
| 21 | + } |
|
| 22 | + return [ |
|
| 23 | + 'value' => (int)$value, |
|
| 24 | + 'readable-value' => 'integer ' . (int)$value, |
|
| 25 | + ]; |
|
| 26 | 26 | |
| 27 | - case 'double': |
|
| 28 | - case 'float': |
|
| 29 | - if (!is_numeric($value)) { |
|
| 30 | - throw new \InvalidArgumentException('Non-numeric value specified'); |
|
| 31 | - } |
|
| 32 | - return [ |
|
| 33 | - 'value' => (float)$value, |
|
| 34 | - 'readable-value' => 'double ' . (float)$value, |
|
| 35 | - ]; |
|
| 27 | + case 'double': |
|
| 28 | + case 'float': |
|
| 29 | + if (!is_numeric($value)) { |
|
| 30 | + throw new \InvalidArgumentException('Non-numeric value specified'); |
|
| 31 | + } |
|
| 32 | + return [ |
|
| 33 | + 'value' => (float)$value, |
|
| 34 | + 'readable-value' => 'double ' . (float)$value, |
|
| 35 | + ]; |
|
| 36 | 36 | |
| 37 | - case 'boolean': |
|
| 38 | - case 'bool': |
|
| 39 | - $value = strtolower($value); |
|
| 40 | - return match ($value) { |
|
| 41 | - 'true' => [ |
|
| 42 | - 'value' => true, |
|
| 43 | - 'readable-value' => 'boolean ' . $value, |
|
| 44 | - ], |
|
| 45 | - 'false' => [ |
|
| 46 | - 'value' => false, |
|
| 47 | - 'readable-value' => 'boolean ' . $value, |
|
| 48 | - ], |
|
| 49 | - default => throw new \InvalidArgumentException('Unable to parse value as boolean'), |
|
| 50 | - }; |
|
| 37 | + case 'boolean': |
|
| 38 | + case 'bool': |
|
| 39 | + $value = strtolower($value); |
|
| 40 | + return match ($value) { |
|
| 41 | + 'true' => [ |
|
| 42 | + 'value' => true, |
|
| 43 | + 'readable-value' => 'boolean ' . $value, |
|
| 44 | + ], |
|
| 45 | + 'false' => [ |
|
| 46 | + 'value' => false, |
|
| 47 | + 'readable-value' => 'boolean ' . $value, |
|
| 48 | + ], |
|
| 49 | + default => throw new \InvalidArgumentException('Unable to parse value as boolean'), |
|
| 50 | + }; |
|
| 51 | 51 | |
| 52 | - case 'null': |
|
| 53 | - return [ |
|
| 54 | - 'value' => null, |
|
| 55 | - 'readable-value' => 'null', |
|
| 56 | - ]; |
|
| 52 | + case 'null': |
|
| 53 | + return [ |
|
| 54 | + 'value' => null, |
|
| 55 | + 'readable-value' => 'null', |
|
| 56 | + ]; |
|
| 57 | 57 | |
| 58 | - case 'string': |
|
| 59 | - $value = (string)$value; |
|
| 60 | - return [ |
|
| 61 | - 'value' => $value, |
|
| 62 | - 'readable-value' => ($value === '') ? 'empty string' : 'string ' . $value, |
|
| 63 | - ]; |
|
| 58 | + case 'string': |
|
| 59 | + $value = (string)$value; |
|
| 60 | + return [ |
|
| 61 | + 'value' => $value, |
|
| 62 | + 'readable-value' => ($value === '') ? 'empty string' : 'string ' . $value, |
|
| 63 | + ]; |
|
| 64 | 64 | |
| 65 | - case 'json': |
|
| 66 | - $value = json_decode($value, true); |
|
| 67 | - return [ |
|
| 68 | - 'value' => $value, |
|
| 69 | - 'readable-value' => 'json ' . json_encode($value), |
|
| 70 | - ]; |
|
| 65 | + case 'json': |
|
| 66 | + $value = json_decode($value, true); |
|
| 67 | + return [ |
|
| 68 | + 'value' => $value, |
|
| 69 | + 'readable-value' => 'json ' . json_encode($value), |
|
| 70 | + ]; |
|
| 71 | 71 | |
| 72 | - default: |
|
| 73 | - throw new \InvalidArgumentException('Invalid type'); |
|
| 74 | - } |
|
| 75 | - } |
|
| 72 | + default: |
|
| 73 | + throw new \InvalidArgumentException('Invalid type'); |
|
| 74 | + } |
|
| 75 | + } |
|
| 76 | 76 | } |