validateConfig()) return false; return Taskmanager::submit('MakeTarball', array( 'files' => $this->getFileArray(), 'destination' => $tgz, 'parentTask' => $parent, ), false); } protected function moduleVersion(): int { return self::VERSION; } protected function validateConfig(): bool { return true; } public function setData(string $key, $value): bool { if (!in_array($key, self::VALID_FIELDS)) return false; $this->moduleData[$key] = $value; return true; } public function allowDownload(): bool { return false; } /** * Creates a map with filepath => file content * @return array{"/etc/lightdm/qt-lightdm-greeter.conf.d/80-$id-customization.conf": string} */ private function getFileArray(): array { $id = $this->id(); $content = "[General]\n"; foreach (self::VALID_FIELDS as $field) { if (!isset($this->moduleData[$field])) continue; $content .= $field . '=' . $this->escapeString($this->moduleData[$field]) . "\n"; } return [ "/etc/lightdm/qt-lightdm-greeter.conf.d/80-$id-customization.conf" => $content, ]; } private function escapeString(string $str) { if (strpos($str, '\\') !== false) { $str = str_replace('\\', '\\\\', $str); } if (strpos($str, '"') !== false) { $str = str_replace('"', '\\"', $str); } if (strpos($str, ';') !== false) { $str = '"' . $str. '"'; } return $str; } }