From a52c6a7ec144b6c61dec8082f5f957115a32e74b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=B2=88=E5=94=81?= <52o@qq52o.cn>
Date: Fri, 23 Jul 2021 16:11:44 +0800
Subject: [PATCH] Optimize time zone question (#69)
---
installer/OptionalPackages.php | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/installer/OptionalPackages.php b/installer/OptionalPackages.php
index 8291e81c..a1c48d52 100644
--- a/installer/OptionalPackages.php
+++ b/installer/OptionalPackages.php
@@ -124,7 +124,18 @@ public function installHyperfScript()
$ask[] = "\n What time zone do you want to setup ?\n";
$ask[] = " [n] Default time zone for php.ini\n";
$ask[] = "Make your selection or type a time zone name, like Asia/Shanghai (n):\n";
- $answer = $this->io->ask(implode('', $ask), 'n');
+ $answer = $this->io->askAndValidate(
+ implode('', $ask),
+ function ($value) {
+ if ($value === 'y' || $value === 'yes') {
+ throw new \InvalidArgumentException("You should type a time zone name, like Asia/Shanghai. Or type n to skip.");
+ }
+
+ return $value;
+ },
+ null,
+ 'n'
+ );
$content = file_get_contents($this->installerSource . '/resources/bin/hyperf.stub');
if ($answer != 'n') {