public function seedMessages() { $helper = new FlashMessenger(); $helper->setSessionManager($this->session); $helper->addMessage('foo'); $helper->addMessage('bar'); unset($helper); }
public function seedMessages() { $helper = new FlashMessenger(); $helper->setSessionManager($this->session); $helper->addMessage('foo'); $helper->addMessage('bar'); $helper->addInfoMessage('bar-info'); $helper->addSuccessMessage('bar-success'); $helper->addErrorMessage('bar-error'); unset($helper); }
protected function addSpecificMessage($type, $title, $description = null, array $messages = null) { $className = '\\Application\\Common\\Message\\' . ucfirst($type) . 'Message'; if (!class_exists($className)) { throw new \InvalidArgumentException('Class "' . $className . '" is undefined.'); } $message = new $className($title, $description, $messages); return parent::addMessage($message); }
public function checkAuthentication(MvcEvent $event) { $auth = $event->getApplication()->getServiceManager()->get("Authentication\\AuthenticationService"); $target = $event->getTarget(); $match = $event->getRouteMatch(); if (!$auth->hasIdentity()) { $strController = $match->getParam('controller'); $arrConfigAcl = $event->getApplication()->getServiceManager()->get('config')['acl']['public']; $flashMessenger = new FlashMessenger(); $strAction = $match->getParam('action'); $arrMessage = array('danger' => array('É preciso está autenticado para acessar esta funcionalidade.')); if (!array_key_exists($strController, $arrConfigAcl)) { $flashMessenger->addMessage($arrMessage); return $target->redirect()->toUrl('/authentication'); } if (!in_array($strAction, $arrConfigAcl[$strController])) { $flashMessenger->addMessage($arrMessage); return $target->redirect()->toUrl('/authentication'); } } }
/** * @param string $to * @param string $toName * @param string $subject * @param string $message * @param string $from * @param string $fromName * * @return bool|FlashMessenger */ public function sendMail($to, $toName, $subject, $message, $from, $fromName) { $transport = new SmtpTransport(); $options = new SmtpOptions(['host' => $this->settings->__invoke('mail', 'host'), 'name' => $this->settings->__invoke('mail', 'name'), 'connection_class' => $this->settings->__invoke('mail', 'connection_class'), 'connection_config' => ['username' => $this->settings->__invoke('mail', 'username'), 'password' => $this->settings->__invoke('mail', 'password'), 'ssl' => $this->settings->__invoke('mail', 'ssl')], 'port' => $this->settings->__invoke('mail', 'port')]); $htmlPart = new MimePart($message); $htmlPart->type = 'text/html'; $body = new MimeMessage(); $body->setParts([$htmlPart]); $mail = new Message(); $mail->setFrom($from, $fromName); $mail->addTo($to, $toName); $mail->setSubject($subject); $mail->setEncoding('UTF-8'); $mail->setBody($body); $mail->getHeaders()->addHeaderLine('MIME-Version: 1.0'); $mail->getHeaders()->addHeaderLine('Content-Type', 'text/html; charset=UTF-8'); try { $transport->setOptions($options); $transport->send($mail); return true; } catch (\Exception $e) { return $this->flashMessenger->addMessage('Email not send', 'error'); } }
/** * Figure out which bib IDs to load from the ILS. * * @param \VuFind\ILS\Connection $catalog ILS connection * @param \VuFind\Search\Solr\Params $params Solr parameters * @param string $range Range setting * @param string $dept Department setting * @param \Zend\Mvc\Controller\Plugin\FlashMessenger $flash Flash messenger * * @return array */ public function getBibIDsFromCatalog($catalog, $params, $range, $dept, $flash) { // The code always pulls in enough catalog results to get a fixed number // of pages worth of Solr results. Note that if the Solr index is out of // sync with the ILS, we may see fewer results than expected. $resultPages = $this->getResultPages(); $perPage = $params->getLimit(); $newItems = $catalog->getNewItems(1, $perPage * $resultPages, $range, $dept); // Build a list of unique IDs $bibIDs = []; for ($i = 0; $i < count($newItems['results']); $i++) { $bibIDs[] = $newItems['results'][$i]['id']; } // Truncate the list if it is too long: $limit = $params->getQueryIDLimit(); if (count($bibIDs) > $limit) { $bibIDs = array_slice($bibIDs, 0, $limit); $flash->addMessage('too_many_new_items', 'info'); } return $bibIDs; }
public function recordAction() { $id = $this->request->getParam('id'); $sid = $_SESSION[$this->id]['sid']; $offset = $this->request->getParam('offset', null, true); $targets = $this->query->fillTargetInfo(); try { // get the record $results = $this->engine->getRawRecord($sid, $id, $offset, $targets); } catch (\Exception $e) { // Exception probably a session timeout; go back to front page $fm = new FlashMessenger(); $fm->addMessage('Session timeout: ' . $e->getMessage()); $params = $this->query->getAllSearchParams(); $params['lang'] = $this->request->getParam('lang'); $params['controller'] = $this->request->getParam('controller'); $params['action'] = 'index'; $url = $this->request->url_for($params); return $this->redirect()->toUrl($url); } // set links $this->helper->addRecordLinks($results); $this->helper->addExternalRecordLinks($results, $this->config); // add to response //var_dump($results); $this->data["results"] = $results; return $this->data; }
public function recordAction() { $uo = new UserOptions($this->request); $sid = $uo->getSessionData('pz2session'); $targets = new Targets($uo->getSessionData('source_type'), $uo->getSessionData('targets')); $id = $this->request->getParam('id'); $offset = $this->request->getParam('offset', null, true); try { // get the record $results = $this->engine->getRawRecord($sid, $id, $offset, $targets); } catch (\Exception $e) { // Exception probably a session timeout; go back to front page $fm = new FlashMessenger(); $fm->addMessage('Session timeout: ' . $e->getMessage()); $params = $this->query->getAllSearchParams(); $params['lang'] = $this->request->getParam('lang'); $params['controller'] = $this->request->getParam('controller'); $params['action'] = 'index'; $url = $this->request->url_for($params); return $this->redirect()->toUrl($url); } // set links $this->helper->addRecordLinks($results); $this->helper->addExternalRecordLinks($results, $this->config); // add to response $this->data->setVariable('results', $results); return $this->data; }