当前位置: 首页>>代码示例>>PHP>>正文


PHP Notification::getInstance方法代码示例

本文整理汇总了PHP中Icinga\Web\Notification::getInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP Notification::getInstance方法的具体用法?PHP Notification::getInstance怎么用?PHP Notification::getInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Icinga\Web\Notification的用法示例。


在下文中一共展示了Notification::getInstance方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: handleRequest

 /**
  * Process the given request using this form
  *
  * Redirects to the url set with setRedirectUrl() upon success. See onSuccess()
  * and onRequest() wherewith you can customize the processing logic.
  *
  * @param   Request     $request    The request to be processed
  *
  * @return  Request                 The request supposed to be processed
  */
 public function handleRequest(Request $request = null)
 {
     if ($request === null) {
         $request = $this->getRequest();
     } else {
         $this->request = $request;
     }
     $formData = $this->getRequestData();
     if ($this->getIsApiTarget() || $this->getUidDisabled() || $this->wasSent($formData)) {
         if ($frameUpload = (bool) $request->getUrl()->shift('_frameUpload', false)) {
             $this->getView()->layout()->setLayout('wrapped');
         }
         $this->populate($formData);
         // Necessary to get isSubmitted() to work
         if (!$this->getSubmitLabel() || $this->isSubmitted()) {
             if ($this->isValid($formData) && ($this->onSuccess !== null && false !== call_user_func($this->onSuccess, $this) || $this->onSuccess === null && false !== $this->onSuccess())) {
                 if ($this->getIsApiTarget() || $this->getRequest()->isApiRequest()) {
                     // API targets and API requests will never redirect but immediately respond w/ JSON-encoded
                     // notifications
                     $notifications = Notification::getInstance()->popMessages();
                     $message = null;
                     foreach ($notifications as $notification) {
                         if ($notification->type === Notification::SUCCESS) {
                             $message = $notification->message;
                             break;
                         }
                     }
                     $this->getResponse()->json()->setSuccessData($message !== null ? array('message' => $message) : null)->sendResponse();
                 } elseif (!$frameUpload) {
                     $this->getResponse()->redirectAndExit($this->getRedirectUrl());
                 } else {
                     $this->getView()->layout()->redirectUrl = $this->getRedirectUrl()->getAbsoluteUrl();
                 }
             } elseif ($this->getIsApiTarget()) {
                 $this->getResponse()->sendJson(array('status' => 'fail', 'data' => array_merge($this->getMessages(), $this->getErrorMessages())));
             }
         } elseif ($this->getValidatePartial()) {
             // The form can't be processed but we may want to show validation errors though
             $this->isValidPartial($formData);
         }
     } else {
         $this->onRequest();
     }
     return $request;
 }
开发者ID:ppuschmann,项目名称:icingaweb2,代码行数:55,代码来源:Form.php

示例2: postDispatchXhr

 protected function postDispatchXhr()
 {
     $layout = $this->_helper->layout();
     $layout->setLayout($this->xhrLayout);
     $resp = $this->getResponse();
     $notifications = Notification::getInstance();
     if ($notifications->hasMessages()) {
         $notificationList = array();
         foreach ($notifications->popMessages() as $m) {
             $notificationList[] = rawurlencode($m->type . ' ' . $m->message);
         }
         $resp->setHeader('X-Icinga-Notification', implode('&', $notificationList), true);
     }
     if ($this->reloadCss) {
         $resp->setHeader('X-Icinga-CssReload', 'now', true);
     }
     if ($this->view->title) {
         if (preg_match('~[\\r\\n]~', $this->view->title)) {
             // TODO: Innocent exception and error log for hack attempts
             throw new IcingaException('No way, guy');
         }
         $resp->setHeader('X-Icinga-Title', rawurlencode($this->view->title . ' :: Icinga Web'), true);
     } else {
         $resp->setHeader('X-Icinga-Title', rawurlencode('Icinga Web'), true);
     }
     if ($this->rerenderLayout) {
         $this->getResponse()->setHeader('X-Icinga-Container', 'layout', true);
     }
     if ($this->autorefreshInterval !== null) {
         $resp->setHeader('X-Icinga-Refresh', $this->autorefreshInterval, true);
     }
 }
开发者ID:NerdGZ,项目名称:icingaweb2,代码行数:32,代码来源:ActionController.php

示例3: setupNotifications

 /**
  * Initialize notifications to remove them immediately from session
  *
  * @return $this
  */
 private function setupNotifications()
 {
     Notification::getInstance();
     return $this;
 }
开发者ID:ZipRecruiter,项目名称:icingaweb2,代码行数:10,代码来源:Web.php

示例4: postDispatch

 /**
  * Detect whether the current request requires changes in the layout and apply them before rendering
  *
  * @see Zend_Controller_Action::postDispatch()
  */
 public function postDispatch()
 {
     Benchmark::measure('Action::postDispatch()');
     $layout = $this->_helper->layout();
     // $this->addModuleContainer();
     $isXhr = $this->_request->isXmlHttpRequest();
     $layout->moduleName = $this->_request->getModuleName();
     if ($layout->moduleName === 'default') {
         $layout->moduleName = false;
     } elseif ($isXhr) {
         header('X-Icinga-Module: ' . $layout->moduleName);
     }
     if ($user = $this->getRequest()->getUser()) {
         // Cast preference app.show_benchmark to bool because preferences loaded from a preferences storage are
         // always strings
         if ((bool) $user->getPreferences()->get('app.show_benchmark', false) === true) {
             Benchmark::measure('Response ready');
             $layout->benchmark = $this->renderBenchmark();
         }
     }
     if ($this->_request->getParam('format') === 'pdf') {
         $layout->setLayout('pdf');
         $this->sendAsPdf();
         exit;
     }
     if ($isXhr) {
         $layout->setLayout('inline');
     }
     $notifications = Notification::getInstance();
     if ($isXhr && !$this->isRedirect && $notifications->hasMessages()) {
         foreach ($notifications->getMessages() as $m) {
             header('X-Icinga-Notification: ' . rawurlencode($m->type . ' ' . $m->message));
         }
     }
     if ($isXhr && ($this->reloadCss || $this->getParam('_reload') === 'css')) {
         header('X-Icinga-CssReload: now');
     }
     if ($isXhr && $this->noXhrBody) {
         header('X-Icinga-Container: ignore');
         return;
     }
     if ($isXhr && $this->getWindowId() === 'undefined') {
         header('X-Icinga-WindowId: ' . $this->generateWindowId());
     }
     if ($this->view->title) {
         if (preg_match('~[\\r\\n]~', $this->view->title)) {
             // TODO: Innocent exception and error log for hack attempts
             throw new Exception('No way, guy');
         }
         header('X-Icinga-Title: ' . rawurlencode($this->view->title . ' :: Icinga Web'));
     }
     // TODO: _render=layout?
     if ($this->getParam('_render') === 'layout') {
         $layout->setLayout('body');
         header('X-Icinga-Container: layout');
     }
     if ($this->autorefreshInterval !== null) {
         header('X-Icinga-Refresh: ' . $this->autorefreshInterval);
     }
 }
开发者ID:vbereza,项目名称:icinga2-migration,代码行数:65,代码来源:ActionController.php


注:本文中的Icinga\Web\Notification::getInstance方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。