public function message() {
		$this->response->disableCache();
		Configure::write('debug', 0);
		if (!$this->RequestHandler->prefers('sse')) {
			throw new BadRequestException();
		}

		$retry = CAKE_NOTIFY_SSE_RETRY;
		$event = 'webNotification';
		$result = [
			'result' => false,
			'messages' => [],
			'retry' => $retry
		];
		if (!$this->Session->started()) {
			$this->Session->renew();
		}

		$userInfo = $this->Auth->user();
		if (empty($userInfo)) {
			$userInfo = [];
		}
		$userId = Hash::get($userInfo, 'id');
		$userRole = Hash::get($userInfo, 'role');
		$prefix = Hash::get($userInfo, 'prefix');

		$lastId = 0;
		if ($this->Session->check('Notifications.lastId')) {
			$lastId = (int)$this->Session->read('Notifications.lastId');
		}

		$notifications = $this->Notification->getNotifications($lastId, $userId, $userRole);
		if (empty($notifications)) {
			$data = json_encode($result);
			$this->set(compact('retry', 'data', 'event'));

			return;
		}

		$iconDefault = '/favicon.ico';
		/*
		$language = new Language();
		$lang = mb_strtoupper($language->getCurrentUiLang(true));
		*/
		foreach ($notifications as $notificationItem) {
			extract($notificationItem['Notification']);
			$lastId = $id;
			$icon = $iconDefault;
			if (isset($data['url']) && is_array($data['url'])) {
				if (!empty($prefix)) {
					$data['url'][$prefix] = true;
				}
				$data['url'] = Router::url($data['url']);
			}
			if (isset($data['icon'])) {
				if (!empty($data['icon'])) {
					$icon = $data['icon'];
				}
				unset($data['icon']);
			}
			$result['messages'][] = compact('tag', 'title', 'body', 'icon', 'data'/*, 'lang'*/);
		}
		if (!empty($result['messages'])) {
			$result['result'] = true;
			$this->Session->write('Notifications.lastId', $lastId);
		}

		$data = json_encode($result);
		$this->set(compact('retry', 'data', 'event'));
	}
public function message() {
		$this->response->disableCache();
		Configure::write('debug', 0);
		if (!$this->RequestHandler->prefers('sse')) {
			throw new BadRequestException();
		}

		$retry = CAKE_NOTIFY_SSE_RETRY;
		$event = 'webNotification';
		$result = [
			'result' => false,
			'messages' => [],
			'retry' => $retry
		];
		if (!$this->Session->started()) {
			$this->Session->renew();
		}

		$userInfo = $this->Auth->user();
		if (empty($userInfo)) {
			$userInfo = [];
		}
		$userId = Hash::get($userInfo, 'id');
		$userRole = Hash::get($userInfo, 'role');
		$prefix = Hash::get($userInfo, 'prefix');

		$lastId = 0;
		if ($this->Session->check('Notifications.lastId')) {
			$lastId = (int)$this->Session->read('Notifications.lastId');
		}

		$notifications = $this->Notification->getNotifications($lastId, $userId, $userRole);
		if (empty($notifications)) {
			$data = json_encode($result);
			$this->set(compact('retry', 'data', 'event'));

			return;
		}

		$iconDefault = '/favicon.ico';
		/*
		$language = new Language();
		$lang = mb_strtoupper($language->getCurrentUiLang(true));
		*/
		foreach ($notifications as $notificationItem) {
			extract($notificationItem['Notification']);
			$lastId = $id;
			$icon = $iconDefault;
			if (isset($data['url']) && is_array($data['url'])) {
				if (!empty($prefix)) {
					$data['url'][$prefix] = true;
				}
				$data['url'] = Router::url($data['url']);
			}
			if (isset($data['icon'])) {
				if (!empty($data['icon'])) {
					$icon = $data['icon'];
				}
				unset($data['icon']);
			}
			$result['messages'][] = compact('tag', 'title', 'body', 'icon', 'data'/*, 'lang'*/);
		}
		if (!empty($result['messages'])) {
			$result['result'] = true;
			$this->Session->write('Notifications.lastId', $lastId);
		}

		$data = json_encode($result);
		$this->set(compact('retry', 'data', 'event'));
	}
public function message ( ) { $ this -> response -> disableCache ( ) ; Configure :: write ( 'debug' , 0 ) ; if ( ! $ this -> RequestHandler -> prefers ( 'sse' ) ) { throw new BadRequestException ( ) ; } $ retry = CAKE_NOTIFY_SSE_RETRY ; $ event = 'webNotification' ; $ result = [ 'result' => false , 'messages' => [ ] , 'retry' => $ retry ] ; if ( ! $ this -> Session -> started ( ) ) { $ this -> Session -> renew ( ) ; } $ userInfo = $ this -> Auth -> user ( ) ; if ( empty ( $ userInfo ) ) { $ userInfo = [ ] ; } $ userId = Hash :: get ( $ userInfo , 'id' ) ; $ userRole = Hash :: get ( $ userInfo , 'role' ) ; $ prefix = Hash :: get ( $ userInfo , 'prefix' ) ; $ lastId = 0 ; if ( $ this -> Session -> check ( 'Notifications.lastId' ) ) { $ lastId = ( int ) $ this -> Session -> read ( 'Notifications.lastId' ) ; } $ notifications = $ this -> Notification -> getNotifications ( $ lastId , $ userId , $ userRole ) ; if ( empty ( $ notifications ) ) { $ data = json_encode ( $ result ) ; $ this -> set ( compact ( 'retry' , 'data' , 'event' ) ) ; return ; } $ iconDefault = '/favicon.ico' ; /*
		$language = new Language();
		$lang = mb_strtoupper($language->getCurrentUiLang(true));
		*/ foreach ( $ notifications as $ notificationItem ) { extract ( $ notificationItem [ 'Notification' ] ) ; $ lastId = $ id ; $ icon = $ iconDefault ; if ( isset ( $ data [ 'url' ] ) && is_array ( $ data [ 'url' ] ) ) { if ( ! empty ( $ prefix ) ) { $ data [ 'url' ] [ $ prefix ] = true ; } $ data [ 'url' ] = Router :: url ( $ data [ 'url' ] ) ; } if ( isset ( $ data [ 'icon' ] ) ) { if ( ! empty ( $ data [ 'icon' ] ) ) { $ icon = $ data [ 'icon' ] ; } unset ( $ data [ 'icon' ] ) ; } $ result [ 'messages' ] [ ] = compact ( 'tag' , 'title' , 'body' , 'icon' , 'data' /*, 'lang'*/ ) ; } if ( ! empty ( $ result [ 'messages' ] ) ) { $ result [ 'result' ] = true ; $ this -> Session -> write ( 'Notifications.lastId' , $ lastId ) ; } $ data = json_encode ( $ result ) ; $ this -> set ( compact ( 'retry' , 'data' , 'event' ) ) ; }
Action `message`. Is used to get data of notifications

@throws BadRequestException if request is not `SSE`
@return void
Action message . Is used to get data of notifications