getCookieParams(); $orders = []; if (isset($cookies['order']) && $cookies['order'] !== '') { $orders = explode(',', $cookies['order']); } $setCookie = null; if ($request->getMethod() === 'POST') { $postData = []; parse_str((string) $request->getBody(), $postData); $newOrder = $postData['udon'] ?? ''; if ($newOrder !== '') { $orders[] = $newOrder; $setCookie = 'order=' . urlencode(implode(',', $orders)) . '; path=/'; } } $orderList = ''; if (count($orders) > 0) { $orderList = '

現在の注文

'; $orderList .= '食べる'; } else { $orderList = '

まだ注文がありません。

'; } $body = << うどん店

うどん店

{$orderList}
HTML; $response = $this->responseFactory->createResponse(200) ->withHeader('Content-Type', 'text/html; charset=UTF-8') ->withBody($this->streamFactory->createStream($body)); if ($setCookie !== null) { $response = $response->withHeader('Set-Cookie', $setCookie); } return $response; } }