/**
  * @param MvcEvent $e
  * @return mixed|void
  */
 public function onDispatch(MvcEvent $e)
 {
     $this->inputFilter->setData($this->params()->fromPost());
     if (!$this->inputFilter->isValid()) {
         $this->flashMessenger()->addErrorMessage($this->inputFilter->getMessages());
         return $this->redirect()->toRoute('frontend');
     }
     try {
         $this->pagesResource->download($this->inputFilter->getValue('site_url'));
         $this->flashMessenger()->addSuccessMessage('Url successfully queued for download all images');
     } catch (ApiException $e) {
         $this->flashMessenger()->addErrorMessage($e->getMessage());
     }
     $this->redirect()->toRoute('frontend');
 }
 /**
  * @param MvcEvent $e
  * @return mixed|void
  */
 public function onDispatch(MvcEvent $e)
 {
     $viewModel = new ViewModel();
     $data = $this->pagesResource->getCollection($this->params('page'), 10);
     $paginator = new ZendPaginator(new CallbackAdapter(function () use($data) {
         return $data->data;
     }, function () use($data) {
         return $data->total_items;
     }));
     $paginator->setCurrentPageNumber($data->page)->setItemCountPerPage($data->page_size);
     $viewModel->setVariable('data', $data->data);
     $viewModel->setVariable('paginator', $paginator);
     $viewModel->setTemplate('frontend/index');
     $e->setResult($viewModel);
 }