public function flashmsg() {
		Configure::write('debug', 0);
		if (!$this->request->is('ajax') || !$this->request->is('post') ||
			!$this->RequestHandler->prefers('json')) {
			throw new BadRequestException();
		}

		$data = [];
		$dataDefault = [
			'result' => false,
			'key' => null,
			'messages' => [],
		];
		$keys = $this->request->data('keys');
		$delete = (bool)$this->request->data('delete');
		if (empty($keys)) {
			$data[] = $dataDefault;
			$this->set(compact('data'));
			$this->set('_serialize', 'data');

			return;
		}
		$keys = (array)$keys;
		foreach ($keys as $key) {
			if (empty($key)) {
				$key = 'flash';
			}

			$dataItem = $dataDefault;
			$dataItem['key'] = $key;
			if ($delete) {
				$dataItem['result'] = $this->FlashMessage->deleteMessage($key);
			} else {
				$messages = $this->FlashMessage->getMessage($key);
				$dataItem['messages'] = $messages;
				$dataItem['result'] = !empty($messages);
			}
			$data[] = $dataItem;
		}

		$this->set(compact('data'));
		$this->set('_serialize', 'data');
	}
public function flashmsg() {
		Configure::write('debug', 0);
		if (!$this->request->is('ajax') || !$this->request->is('post') ||
			!$this->RequestHandler->prefers('json')) {
			throw new BadRequestException();
		}

		$data = [];
		$dataDefault = [
			'result' => false,
			'key' => null,
			'messages' => [],
		];
		$keys = $this->request->data('keys');
		$delete = (bool)$this->request->data('delete');
		if (empty($keys)) {
			$data[] = $dataDefault;
			$this->set(compact('data'));
			$this->set('_serialize', 'data');

			return;
		}
		$keys = (array)$keys;
		foreach ($keys as $key) {
			if (empty($key)) {
				$key = 'flash';
			}

			$dataItem = $dataDefault;
			$dataItem['key'] = $key;
			if ($delete) {
				$dataItem['result'] = $this->FlashMessage->deleteMessage($key);
			} else {
				$messages = $this->FlashMessage->getMessage($key);
				$dataItem['messages'] = $messages;
				$dataItem['result'] = !empty($messages);
			}
			$data[] = $dataItem;
		}

		$this->set(compact('data'));
		$this->set('_serialize', 'data');
	}
public function flashmsg ( ) { Configure :: write ( 'debug' , 0 ) ; if ( ! $ this -> request -> is ( 'ajax' ) || ! $ this -> request -> is ( 'post' ) || ! $ this -> RequestHandler -> prefers ( 'json' ) ) { throw new BadRequestException ( ) ; } $ data = [ ] ; $ dataDefault = [ 'result' => false , 'key' => null , 'messages' => [ ] , ] ; $ keys = $ this -> request -> data ( 'keys' ) ; $ delete = ( bool ) $ this -> request -> data ( 'delete' ) ; if ( empty ( $ keys ) ) { $ data [ ] = $ dataDefault ; $ this -> set ( compact ( 'data' ) ) ; $ this -> set ( '_serialize' , 'data' ) ; return ; } $ keys = ( array ) $ keys ; foreach ( $ keys as $ key ) { if ( empty ( $ key ) ) { $ key = 'flash' ; } $ dataItem = $ dataDefault ; $ dataItem [ 'key' ] = $ key ; if ( $ delete ) { $ dataItem [ 'result' ] = $ this -> FlashMessage -> deleteMessage ( $ key ) ; } else { $ messages = $ this -> FlashMessage -> getMessage ( $ key ) ; $ dataItem [ 'messages' ] = $ messages ; $ dataItem [ 'result' ] = ! empty ( $ messages ) ; } $ data [ ] = $ dataItem ; } $ this -> set ( compact ( 'data' ) ) ; $ this -> set ( '_serialize' , 'data' ) ; }
Action `flashmsg`. Is used to get message from session data

POST Data array:
- `keys` The name of the session key for reading messages.
- `delete` If True, delete message from session.

@throws BadRequestException if request is not `AJAX`, or not `POST`
or not `JSON`
@return void
Action flashmsg . Is used to get message from session data