src/View/Helper/FlashHelper.php
public function render($key = 'flash', array $options = []) {
		$options += ['types' => []];

		// Get the messages from the session
		$messages = (array)$this->_View->getRequest()->getSession()->read('Flash.' . $key);
		$transientMessages = (array)Configure::read('TransientFlash.' . $key);
		if ($transientMessages) {
			$messages = array_merge($messages, $transientMessages);
		}
		$messages = $this->_order($messages);

		$html = '';
		foreach ($messages as $message) {
			if ($options['types'] && !in_array($message['type'], $options['types'])) {
				continue;
			}

			$message = $options + $message;
			$html .= $this->_View->element($message['element'], $message);
		}

		if ($options['types']) {
			$messages = (array)$this->_View->getRequest()->getSession()->read('Flash.' . $key);
			foreach ($messages as $index => $message) {
				if (!in_array($message['type'], $options['types'])) {
					continue;
				}
				$this->_View->getRequest()->getSession()->delete('Flash.' . $key . '.' . $index);
			}
			foreach ($transientMessages as $index => $message) {
				if (!in_array($message['type'], $options['types'])) {
					continue;
				}
				Configure::delete('TransientFlash.' . $key . '.' . $index);
			}

		} else {
			$this->_View->getRequest()->getSession()->delete('Flash.' . $key);
			Configure::delete('TransientFlash.' . $key);
		}

		return $html;
	}
public function render($key = 'flash', array $options = []) {
		$options += ['types' => []];

		// Get the messages from the session
		$messages = (array)$this->_View->getRequest()->getSession()->read('Flash.' . $key);
		$transientMessages = (array)Configure::read('TransientFlash.' . $key);
		if ($transientMessages) {
			$messages = array_merge($messages, $transientMessages);
		}
		$messages = $this->_order($messages);

		$html = '';
		foreach ($messages as $message) {
			if ($options['types'] && !in_array($message['type'], $options['types'])) {
				continue;
			}

			$message = $options + $message;
			$html .= $this->_View->element($message['element'], $message);
		}

		if ($options['types']) {
			$messages = (array)$this->_View->getRequest()->getSession()->read('Flash.' . $key);
			foreach ($messages as $index => $message) {
				if (!in_array($message['type'], $options['types'])) {
					continue;
				}
				$this->_View->getRequest()->getSession()->delete('Flash.' . $key . '.' . $index);
			}
			foreach ($transientMessages as $index => $message) {
				if (!in_array($message['type'], $options['types'])) {
					continue;
				}
				Configure::delete('TransientFlash.' . $key . '.' . $index);
			}

		} else {
			$this->_View->getRequest()->getSession()->delete('Flash.' . $key);
			Configure::delete('TransientFlash.' . $key);
		}

		return $html;
	}
public function render ( $ key = 'flash' , array $ options = [ ] ) { $ options += [ 'types' => [ ] ] ; // Get the messages from the session $ messages = ( array ) $ this -> _View -> getRequest ( ) -> getSession ( ) -> read ( 'Flash.' . $ key ) ; $ transientMessages = ( array ) Configure :: read ( 'TransientFlash.' . $ key ) ; if ( $ transientMessages ) { $ messages = array_merge ( $ messages , $ transientMessages ) ; } $ messages = $ this -> _order ( $ messages ) ; $ html = '' ; foreach ( $ messages as $ message ) { if ( $ options [ 'types' ] && ! in_array ( $ message [ 'type' ] , $ options [ 'types' ] ) ) { continue ; } $ message = $ options + $ message ; $ html .= $ this -> _View -> element ( $ message [ 'element' ] , $ message ) ; } if ( $ options [ 'types' ] ) { $ messages = ( array ) $ this -> _View -> getRequest ( ) -> getSession ( ) -> read ( 'Flash.' . $ key ) ; foreach ( $ messages as $ index => $ message ) { if ( ! in_array ( $ message [ 'type' ] , $ options [ 'types' ] ) ) { continue ; } $ this -> _View -> getRequest ( ) -> getSession ( ) -> delete ( 'Flash.' . $ key . '.' . $ index ) ; } foreach ( $ transientMessages as $ index => $ message ) { if ( ! in_array ( $ message [ 'type' ] , $ options [ 'types' ] ) ) { continue ; } Configure :: delete ( 'TransientFlash.' . $ key . '.' . $ index ) ; } } else { $ this -> _View -> getRequest ( ) -> getSession ( ) -> delete ( 'Flash.' . $ key ) ; Configure :: delete ( 'TransientFlash.' . $ key ) ; } return $ html ; }
Displays flash messages.

Options:
- types: Types to render out, defaults to all

@param string $key The [Flash.]key you are rendering in the view.
@param array $options Additional options to use for the creation of this flash message.
Supports the 'params', and 'element' keys that are used in the helper.
@return string|null Rendered flash message or null if flash key does not exist
in session.
@throws \UnexpectedValueException If value for flash settings key is not an array.
Displays flash messages .