コード例 #1
0
 /**
  * Flash used container names.
  *
  * @param Notification $notification
  * @return void
  */
 protected function flashContainerNames(Notification $notification)
 {
     $names = array();
     foreach ($notification->getContainers() as $container) {
         $names[] = $container->getName();
     }
     $this->getSession()->flash($this->getConfig()->get('notification.session_prefix') . 'containers', $names);
 }
コード例 #2
0
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request $request
  * @param  \Closure $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     $containerNames = $this->session->get($this->sessionPrefix . 'containers', array());
     $sessionVariables = $this->session->all();
     foreach ($containerNames as $containerName) {
         foreach ($sessionVariables as $sessionKey => $value) {
             if (strpos($sessionKey, $this->sessionPrefix . $containerName) === 0 && is_string($value)) {
                 $jsonMessage = json_decode($value);
                 $this->notification->container($containerName)->add($jsonMessage->type, new Message($jsonMessage->type, $jsonMessage->message, false, $jsonMessage->format, $jsonMessage->alias, $jsonMessage->position), false);
             }
         }
     }
     return $next($request);
 }
コード例 #3
0
 /**
  * Register the service provider.
  *
  * @return void
  */
 public function register()
 {
     $this->app['config']->package('edvinaskrucas/notification', __DIR__ . '/../config');
     $this->app['notification'] = $this->app->share(function ($app) {
         $config = $app['config'];
         $notification = new Notification($config->get('notification::default_container'), $config->get('notification::default_types'), $config->get('notification::default_format'), $config->get('notification::default_formats'));
         $notification->setEventDispatcher($app['events']);
         return $notification;
     });
     $this->app->bind('Krucas\\Notification\\Subscriber', function ($app) {
         return new Subscriber($app['session'], $app['config']);
     });
     $this->app['events']->subscribe('Krucas\\Notification\\Subscriber');
 }
コード例 #4
0
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request $request
  * @param  \Closure $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     $containers = $this->session->get($this->key, []);
     if (count($containers) > 0) {
         foreach ($containers as $name => $messages) {
             /** @var \Krucas\Notification\Message $message */
             foreach ($messages as $message) {
                 $this->notification->container($name)->add($message->getType(), $message, false);
             }
         }
     }
     $this->session->forget($this->key);
     return $next($request);
 }
コード例 #5
0
 /**
  * Register the service provider.
  *
  * @return void
  */
 public function register()
 {
     $this->mergeConfigFrom(__DIR__ . '/../../config/notification.php', 'notification');
     $this->app->singleton('notification', function ($app) {
         $config = $app['config'];
         $notification = new Notification($config->get('notification.default_container'), $config->get('notification.default_types'), $config->get('notification.types'), $config->get('notification.default_format'), $config->get('notification.format'), $config->get('notification.default_formats'), $config->get('notification.formats'));
         $notification->setEventDispatcher($app['events']);
         return $notification;
     });
     $this->app->alias('notification', 'Krucas\\Notification\\Notification');
     $this->app->singleton('Krucas\\Notification\\Subscriber', function ($app) {
         return new Subscriber($app['session.store'], $app['config']['notification.session_key']);
     });
     $this->app->singleton('Krucas\\Notification\\Middleware\\NotificationMiddleware', function ($app) {
         return new NotificationMiddleware($app['session.store'], $app['notification'], $app['config']->get('notification.session_key'));
     });
 }
コード例 #6
0
ファイル: _ide_helper.php プロジェクト: phillipmadsen/deved
 /**
  * Unset the event dispatcher for models.
  *
  * @return void 
  * @static 
  */
 public static function unsetEventDispatcher()
 {
     \Krucas\Notification\Notification::unsetEventDispatcher();
 }
コード例 #7
0
 /**
  * {@inheritdoc}
  *
  * @param string $message
  * @param array $parameters (optional)
  * @return void
  **/
 public function warning($message, array $parameters = [])
 {
     $this->notification->warning($message);
 }