-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f275685
commit 296955b
Showing
2 changed files
with
92 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
... | ||
use Symfony\Component\Console\Question\Question; | ||
|
||
class NotifyUnprocessedInquiryCommand extends ContainerAwareCommand | ||
{ | ||
... | ||
|
||
protected function execute(InputInterface $input, OutputInterface $output) | ||
{ | ||
... | ||
|
||
if (count($inquiryList) > 0) { | ||
|
||
$output->writeln(count($inquiryList) . '件の未処理お問い合わせがあります'); | ||
|
||
if ($this->confirmSend($input, $output)) { | ||
$this->sendMail($inquiryList, $output); | ||
} | ||
} else { | ||
$output->writeln("未処理なし"); | ||
} | ||
} | ||
|
||
private function confirmSend($input, $output) | ||
{ | ||
$qHelper = $this->getHelper('question'); | ||
|
||
$question = new Question('通知メールを送信しますか? [y/n]: ', null); | ||
$question->setValidator(function ($answer) { | ||
$answer = strtolower(substr($answer, 0, 1)); | ||
if (!in_array($answer, ['y', 'n'])) { | ||
throw new \RuntimeException( | ||
'yまたはnを入力してください' | ||
); | ||
} | ||
return $answer; | ||
}); | ||
$question->setMaxAttempts(3); | ||
|
||
return $qHelper->ask($input, $output, $question) == 'y'; | ||
} | ||
|
||
private function sendMail($inquiryList, $output) | ||
{ | ||
$container = $this->getContainer(); | ||
$templating = $container->get('templating'); | ||
... | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters