public function output( $type = null )
	{
		$session = $this->_di->getService( "session" );

        /**
         * Get the messages from the session
         */
		$messages = $session->get( "__flash__" );

		/**
		 * If there are no messages to output -> exit early
		 */
        if ( $messages == null )
        {
        	return;
        }

        /**
         * If a type is specified -> implode and return the type messages
         */
        if ( isset($type) )
        {
            /**
             * Get the messages of the type
             */
        	$messages_type = implode( $messages[$type] );

            /**
             * Clear the type messages in the flash session
             */
        	$messages[$type] = array();

			$session->set( "__flash__", $messages );

    	    return $messages_type;
        }

        /**
         * Create a string with all messages
         */
        $all_messages_str = "";

        foreach ( $messages as $messages_type )
        {
        	$all_messages_str .= implode( $messages_type );
        }

        /**
         * When all the messages have been output -> clear all the messages in the flash session
         */
		$session->set( "__flash__", array() );

        return $all_messages_str;
	}