/**
  * @param ServerRequestInterface $request
  * @param ResponseInterface $response
  * @return ResponseInterface
  */
 public function __invoke(ServerRequestInterface $request, ResponseInterface $response)
 {
     try {
         /**
          * @var Session $session
          */
         $session = $request->getAttribute('session');
         $album = new Album();
         $this->form->bind($album);
         $this->form->get('submit')->setValue('Add');
         if ($request->getMethod() === 'POST') {
             $this->albumService->addAlbum($request->getParsedBody());
             $session->getSegment('App\\Album')->setFlash('flash', ['type' => 'success', 'message' => sprintf('Successfully added album %s (%s)', $album->getTitle(), $album->getArtist())]);
             return new RedirectResponse($this->router->generateUri('album.index'));
         }
     } catch (\Exception $e) {
         // perhaps log an error and display a message to the user
     }
     return new HtmlResponse($this->template->render('album::add', ['form' => $this->form]));
 }