@@ -33,104 +33,104 @@ |
||
33 | 33 | use Symfony\Component\Console\Output\OutputInterface; |
34 | 34 | |
35 | 35 | class UpdateConfig extends Command { |
36 | - public const SUPPORTED_KEYS = [ |
|
37 | - 'name', 'url', 'imprintUrl', 'privacyUrl', 'slogan', 'color' |
|
38 | - ]; |
|
39 | - |
|
40 | - public const SUPPORTED_IMAGE_KEYS = [ |
|
41 | - 'background', 'logo', 'favicon', 'logoheader' |
|
42 | - ]; |
|
43 | - |
|
44 | - private $themingDefaults; |
|
45 | - private $imageManager; |
|
46 | - private $config; |
|
47 | - |
|
48 | - public function __construct(ThemingDefaults $themingDefaults, ImageManager $imageManager, IConfig $config) { |
|
49 | - parent::__construct(); |
|
50 | - |
|
51 | - $this->themingDefaults = $themingDefaults; |
|
52 | - $this->imageManager = $imageManager; |
|
53 | - $this->config = $config; |
|
54 | - } |
|
55 | - |
|
56 | - protected function configure() { |
|
57 | - $this |
|
58 | - ->setName('theming:config') |
|
59 | - ->setDescription('Set theming app config values') |
|
60 | - ->addArgument( |
|
61 | - 'key', |
|
62 | - InputArgument::OPTIONAL, |
|
63 | - 'Key to update the theming app configuration (leave empty to get a list of all configured values)' . PHP_EOL . |
|
64 | - 'One of: ' . implode(', ', self::SUPPORTED_KEYS) |
|
65 | - ) |
|
66 | - ->addArgument( |
|
67 | - 'value', |
|
68 | - InputArgument::OPTIONAL, |
|
69 | - 'Value to set (leave empty to obtain the current value)' |
|
70 | - ) |
|
71 | - ->addOption( |
|
72 | - 'reset', |
|
73 | - 'r', |
|
74 | - InputOption::VALUE_NONE, |
|
75 | - 'Reset the given config key to default' |
|
76 | - ); |
|
77 | - } |
|
78 | - |
|
79 | - |
|
80 | - protected function execute(InputInterface $input, OutputInterface $output): int { |
|
81 | - $key = $input->getArgument('key'); |
|
82 | - $value = $input->getArgument('value'); |
|
83 | - |
|
84 | - if ($key === null) { |
|
85 | - $output->writeln('Current theming config:'); |
|
86 | - foreach (self::SUPPORTED_KEYS as $key) { |
|
87 | - $value = $this->config->getAppValue('theming', $key, ''); |
|
88 | - $output->writeln('- ' . $key . ': ' . $value . ''); |
|
89 | - } |
|
90 | - foreach (self::SUPPORTED_IMAGE_KEYS as $key) { |
|
91 | - $value = $this->config->getAppValue('theming', $key . 'Mime', ''); |
|
92 | - $output->writeln('- ' . $key . ': ' . $value . ''); |
|
93 | - } |
|
94 | - return 0; |
|
95 | - } |
|
96 | - |
|
97 | - if (!in_array($key, self::SUPPORTED_KEYS, true) && !in_array($key, self::SUPPORTED_IMAGE_KEYS, true)) { |
|
98 | - $output->writeln('<error>Invalid config key provided</error>'); |
|
99 | - return 1; |
|
100 | - } |
|
101 | - |
|
102 | - if ($input->getOption('reset')) { |
|
103 | - $defaultValue = $this->themingDefaults->undo($key); |
|
104 | - $output->writeln('<info>Reset ' . $key . ' to ' . $defaultValue . '</info>'); |
|
105 | - return 0; |
|
106 | - } |
|
107 | - |
|
108 | - if ($value === null) { |
|
109 | - $value = $this->config->getAppValue('theming', $key, ''); |
|
110 | - if ($value !== '') { |
|
111 | - $output->writeln('<info>' . $key . ' is currently set to ' . $value . '</info>'); |
|
112 | - } else { |
|
113 | - $output->writeln('<info>' . $key . ' is currently not set</info>'); |
|
114 | - } |
|
115 | - return 0; |
|
116 | - } |
|
117 | - |
|
118 | - if (in_array($key, self::SUPPORTED_IMAGE_KEYS, true)) { |
|
119 | - if (strpos($value, '/') !== 0) { |
|
120 | - $output->writeln('<error>The image file needs to be provided as an absolute path: ' . $value . '.</error>'); |
|
121 | - return 1; |
|
122 | - } |
|
123 | - if (!file_exists($value)) { |
|
124 | - $output->writeln('<error>File could not be found: ' . $value . '.</error>'); |
|
125 | - return 1; |
|
126 | - } |
|
127 | - $value = $this->imageManager->updateImage($key, $value); |
|
128 | - $key = $key . 'Mime'; |
|
129 | - } |
|
130 | - |
|
131 | - $this->themingDefaults->set($key, $value); |
|
132 | - $output->writeln('<info>Updated ' . $key . ' to ' . $value . '</info>'); |
|
133 | - |
|
134 | - return 0; |
|
135 | - } |
|
36 | + public const SUPPORTED_KEYS = [ |
|
37 | + 'name', 'url', 'imprintUrl', 'privacyUrl', 'slogan', 'color' |
|
38 | + ]; |
|
39 | + |
|
40 | + public const SUPPORTED_IMAGE_KEYS = [ |
|
41 | + 'background', 'logo', 'favicon', 'logoheader' |
|
42 | + ]; |
|
43 | + |
|
44 | + private $themingDefaults; |
|
45 | + private $imageManager; |
|
46 | + private $config; |
|
47 | + |
|
48 | + public function __construct(ThemingDefaults $themingDefaults, ImageManager $imageManager, IConfig $config) { |
|
49 | + parent::__construct(); |
|
50 | + |
|
51 | + $this->themingDefaults = $themingDefaults; |
|
52 | + $this->imageManager = $imageManager; |
|
53 | + $this->config = $config; |
|
54 | + } |
|
55 | + |
|
56 | + protected function configure() { |
|
57 | + $this |
|
58 | + ->setName('theming:config') |
|
59 | + ->setDescription('Set theming app config values') |
|
60 | + ->addArgument( |
|
61 | + 'key', |
|
62 | + InputArgument::OPTIONAL, |
|
63 | + 'Key to update the theming app configuration (leave empty to get a list of all configured values)' . PHP_EOL . |
|
64 | + 'One of: ' . implode(', ', self::SUPPORTED_KEYS) |
|
65 | + ) |
|
66 | + ->addArgument( |
|
67 | + 'value', |
|
68 | + InputArgument::OPTIONAL, |
|
69 | + 'Value to set (leave empty to obtain the current value)' |
|
70 | + ) |
|
71 | + ->addOption( |
|
72 | + 'reset', |
|
73 | + 'r', |
|
74 | + InputOption::VALUE_NONE, |
|
75 | + 'Reset the given config key to default' |
|
76 | + ); |
|
77 | + } |
|
78 | + |
|
79 | + |
|
80 | + protected function execute(InputInterface $input, OutputInterface $output): int { |
|
81 | + $key = $input->getArgument('key'); |
|
82 | + $value = $input->getArgument('value'); |
|
83 | + |
|
84 | + if ($key === null) { |
|
85 | + $output->writeln('Current theming config:'); |
|
86 | + foreach (self::SUPPORTED_KEYS as $key) { |
|
87 | + $value = $this->config->getAppValue('theming', $key, ''); |
|
88 | + $output->writeln('- ' . $key . ': ' . $value . ''); |
|
89 | + } |
|
90 | + foreach (self::SUPPORTED_IMAGE_KEYS as $key) { |
|
91 | + $value = $this->config->getAppValue('theming', $key . 'Mime', ''); |
|
92 | + $output->writeln('- ' . $key . ': ' . $value . ''); |
|
93 | + } |
|
94 | + return 0; |
|
95 | + } |
|
96 | + |
|
97 | + if (!in_array($key, self::SUPPORTED_KEYS, true) && !in_array($key, self::SUPPORTED_IMAGE_KEYS, true)) { |
|
98 | + $output->writeln('<error>Invalid config key provided</error>'); |
|
99 | + return 1; |
|
100 | + } |
|
101 | + |
|
102 | + if ($input->getOption('reset')) { |
|
103 | + $defaultValue = $this->themingDefaults->undo($key); |
|
104 | + $output->writeln('<info>Reset ' . $key . ' to ' . $defaultValue . '</info>'); |
|
105 | + return 0; |
|
106 | + } |
|
107 | + |
|
108 | + if ($value === null) { |
|
109 | + $value = $this->config->getAppValue('theming', $key, ''); |
|
110 | + if ($value !== '') { |
|
111 | + $output->writeln('<info>' . $key . ' is currently set to ' . $value . '</info>'); |
|
112 | + } else { |
|
113 | + $output->writeln('<info>' . $key . ' is currently not set</info>'); |
|
114 | + } |
|
115 | + return 0; |
|
116 | + } |
|
117 | + |
|
118 | + if (in_array($key, self::SUPPORTED_IMAGE_KEYS, true)) { |
|
119 | + if (strpos($value, '/') !== 0) { |
|
120 | + $output->writeln('<error>The image file needs to be provided as an absolute path: ' . $value . '.</error>'); |
|
121 | + return 1; |
|
122 | + } |
|
123 | + if (!file_exists($value)) { |
|
124 | + $output->writeln('<error>File could not be found: ' . $value . '.</error>'); |
|
125 | + return 1; |
|
126 | + } |
|
127 | + $value = $this->imageManager->updateImage($key, $value); |
|
128 | + $key = $key . 'Mime'; |
|
129 | + } |
|
130 | + |
|
131 | + $this->themingDefaults->set($key, $value); |
|
132 | + $output->writeln('<info>Updated ' . $key . ' to ' . $value . '</info>'); |
|
133 | + |
|
134 | + return 0; |
|
135 | + } |
|
136 | 136 | } |
@@ -60,8 +60,8 @@ discard block |
||
60 | 60 | ->addArgument( |
61 | 61 | 'key', |
62 | 62 | InputArgument::OPTIONAL, |
63 | - 'Key to update the theming app configuration (leave empty to get a list of all configured values)' . PHP_EOL . |
|
64 | - 'One of: ' . implode(', ', self::SUPPORTED_KEYS) |
|
63 | + 'Key to update the theming app configuration (leave empty to get a list of all configured values)'.PHP_EOL. |
|
64 | + 'One of: '.implode(', ', self::SUPPORTED_KEYS) |
|
65 | 65 | ) |
66 | 66 | ->addArgument( |
67 | 67 | 'value', |
@@ -85,11 +85,11 @@ discard block |
||
85 | 85 | $output->writeln('Current theming config:'); |
86 | 86 | foreach (self::SUPPORTED_KEYS as $key) { |
87 | 87 | $value = $this->config->getAppValue('theming', $key, ''); |
88 | - $output->writeln('- ' . $key . ': ' . $value . ''); |
|
88 | + $output->writeln('- '.$key.': '.$value.''); |
|
89 | 89 | } |
90 | 90 | foreach (self::SUPPORTED_IMAGE_KEYS as $key) { |
91 | - $value = $this->config->getAppValue('theming', $key . 'Mime', ''); |
|
92 | - $output->writeln('- ' . $key . ': ' . $value . ''); |
|
91 | + $value = $this->config->getAppValue('theming', $key.'Mime', ''); |
|
92 | + $output->writeln('- '.$key.': '.$value.''); |
|
93 | 93 | } |
94 | 94 | return 0; |
95 | 95 | } |
@@ -101,35 +101,35 @@ discard block |
||
101 | 101 | |
102 | 102 | if ($input->getOption('reset')) { |
103 | 103 | $defaultValue = $this->themingDefaults->undo($key); |
104 | - $output->writeln('<info>Reset ' . $key . ' to ' . $defaultValue . '</info>'); |
|
104 | + $output->writeln('<info>Reset '.$key.' to '.$defaultValue.'</info>'); |
|
105 | 105 | return 0; |
106 | 106 | } |
107 | 107 | |
108 | 108 | if ($value === null) { |
109 | 109 | $value = $this->config->getAppValue('theming', $key, ''); |
110 | 110 | if ($value !== '') { |
111 | - $output->writeln('<info>' . $key . ' is currently set to ' . $value . '</info>'); |
|
111 | + $output->writeln('<info>'.$key.' is currently set to '.$value.'</info>'); |
|
112 | 112 | } else { |
113 | - $output->writeln('<info>' . $key . ' is currently not set</info>'); |
|
113 | + $output->writeln('<info>'.$key.' is currently not set</info>'); |
|
114 | 114 | } |
115 | 115 | return 0; |
116 | 116 | } |
117 | 117 | |
118 | 118 | if (in_array($key, self::SUPPORTED_IMAGE_KEYS, true)) { |
119 | 119 | if (strpos($value, '/') !== 0) { |
120 | - $output->writeln('<error>The image file needs to be provided as an absolute path: ' . $value . '.</error>'); |
|
120 | + $output->writeln('<error>The image file needs to be provided as an absolute path: '.$value.'.</error>'); |
|
121 | 121 | return 1; |
122 | 122 | } |
123 | 123 | if (!file_exists($value)) { |
124 | - $output->writeln('<error>File could not be found: ' . $value . '.</error>'); |
|
124 | + $output->writeln('<error>File could not be found: '.$value.'.</error>'); |
|
125 | 125 | return 1; |
126 | 126 | } |
127 | 127 | $value = $this->imageManager->updateImage($key, $value); |
128 | - $key = $key . 'Mime'; |
|
128 | + $key = $key.'Mime'; |
|
129 | 129 | } |
130 | 130 | |
131 | 131 | $this->themingDefaults->set($key, $value); |
132 | - $output->writeln('<info>Updated ' . $key . ' to ' . $value . '</info>'); |
|
132 | + $output->writeln('<info>Updated '.$key.' to '.$value.'</info>'); |
|
133 | 133 | |
134 | 134 | return 0; |
135 | 135 | } |