/**
  * @param MvcEvent $e
  * @return mixed|void
  */
 public function onDispatch(MvcEvent $e)
 {
     $viewModel = new ViewModel();
     $data = $this->authenticationService->getAuthData();
     $viewModel->setVariable('user', $data->user);
     $valid = $this->configurationData->isValid();
     $viewModel->setVariable('validInputs', $this->configurationData->getValidInput());
     if (!$valid) {
         $viewModel->setTemplate('frontend/gallery/error');
         $viewModel->setVariable('messages', $this->configurationData->getMessages());
         return $e->setResult($viewModel);
     }
     $collectionService = $this->collectionFactory->createCollection($this->configurationData);
     $images = $collectionService->getImages($this->configurationData);
     $viewModel->setVariable('images', $images);
     $this->sessionContainer->images = $images;
     $this->sessionContainer->valuesHash = md5(serialize($this->configurationData->getValues()));
     $viewModel->setTemplate('frontend/gallery/preview');
     return $e->setResult($viewModel);
 }
 /**
  * @param Request $request
  * @param Di $di
  */
 public function __construct(Request $request, Di $di)
 {
     parent::__construct($request, $di);
     $this->setData($this->initDefaults($request->getPost()));
 }