
#ifdef HAVE_CONFIG_H
#include "../../ext_config.h"
#endif

#include <php.h>
#include "../../php_ext.h"
#include "../../ext.h"

#include <Zend/zend_operators.h>
#include <Zend/zend_exceptions.h>
#include <Zend/zend_interfaces.h>

#include "kernel/main.h"
#include "kernel/object.h"
#include "kernel/memory.h"
#include "kernel/fcall.h"
#include "kernel/array.h"
#include "kernel/operators.h"
#include "kernel/exception.h"
#include "kernel/concat.h"
#include "kernel/string.h"


/**
 * This file is part of the Phalcon Framework.
 *
 * (c) Phalcon Team <team@phalcon.io>
 *
 * For the full copyright and license information, please view the LICENSE.txt
 * file that was distributed with this source code.
 */
/**
 * Shows HTML notifications related to different circumstances. Classes can be
 * stylized using CSS
 *
 *```php
 * $flash->success("The record was successfully deleted");
 * $flash->error("Cannot open the file");
 *```
 *
 * Class AbstractFlash
 *
 * @package Phalcon\Flash
 */
ZEPHIR_INIT_CLASS(Phalcon_Flash_AbstractFlash)
{
	ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Flash, AbstractFlash, phalcon, flash_abstractflash, phalcon_di_abstractinjectionaware_ce, phalcon_flash_abstractflash_method_entry, ZEND_ACC_EXPLICIT_ABSTRACT_CLASS);

	/**
	 * @var bool
	 */
	zend_declare_property_bool(phalcon_flash_abstractflash_ce, SL("autoescape"), 1, ZEND_ACC_PROTECTED);
	/**
	 * @var bool
	 */
	zend_declare_property_bool(phalcon_flash_abstractflash_ce, SL("automaticHtml"), 1, ZEND_ACC_PROTECTED);
	/**
	 * @var array
	 */
	zend_declare_property_null(phalcon_flash_abstractflash_ce, SL("cssClasses"), ZEND_ACC_PROTECTED);
	/**
	 * @var array
	 */
	zend_declare_property_null(phalcon_flash_abstractflash_ce, SL("cssIconClasses"), ZEND_ACC_PROTECTED);
	/**
	 * @var string
	 */
	zend_declare_property_string(phalcon_flash_abstractflash_ce, SL("customTemplate"), "", ZEND_ACC_PROTECTED);
	/**
	 * @var EscaperInterface | null
	 */
	zend_declare_property_null(phalcon_flash_abstractflash_ce, SL("escaperService"), ZEND_ACC_PROTECTED);
	/**
	 * @var bool
	 */
	zend_declare_property_bool(phalcon_flash_abstractflash_ce, SL("implicitFlush"), 1, ZEND_ACC_PROTECTED);
	/**
	 * @var Interpolate
	 */
	zend_declare_property_null(phalcon_flash_abstractflash_ce, SL("interpolator"), ZEND_ACC_PROTECTED);
	/**
	 * @var array
	 */
	zend_declare_property_null(phalcon_flash_abstractflash_ce, SL("messages"), ZEND_ACC_PROTECTED);
	/**
	 * @var SessionInterface|null
	 */
	zend_declare_property_null(phalcon_flash_abstractflash_ce, SL("sessionService"), ZEND_ACC_PROTECTED);
	phalcon_flash_abstractflash_ce->create_object = zephir_init_properties_Phalcon_Flash_AbstractFlash;

	zend_class_implements(phalcon_flash_abstractflash_ce, 1, phalcon_flash_flashinterface_ce);
	return SUCCESS;
}

/**
 * AbstractFlash constructor.
 *
 * @param EscaperInterface|null $escaper
 * @param SessionInterface|null $session
 */
PHP_METHOD(Phalcon_Flash_AbstractFlash, __construct)
{
	zval _1;
	zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL;
	zend_long ZEPHIR_LAST_CALL_STATUS;
	zval *escaper = NULL, escaper_sub, *session = NULL, session_sub, __$null, _0;
	zval *this_ptr = getThis();

	ZVAL_UNDEF(&escaper_sub);
	ZVAL_UNDEF(&session_sub);
	ZVAL_NULL(&__$null);
	ZVAL_UNDEF(&_0);
	ZVAL_UNDEF(&_1);
	static zend_string *_zephir_prop_0 = NULL;
	static zend_string *_zephir_prop_1 = NULL;
	static zend_string *_zephir_prop_2 = NULL;
	static zend_string *_zephir_prop_3 = NULL;
	if (UNEXPECTED(!_zephir_prop_0)) {
		_zephir_prop_0 = zend_string_init("escaperService", 14, 1);
	}
	if (UNEXPECTED(!_zephir_prop_1)) {
		_zephir_prop_1 = zend_string_init("sessionService", 14, 1);
	}
	if (UNEXPECTED(!_zephir_prop_2)) {
		_zephir_prop_2 = zend_string_init("interpolator", 12, 1);
	}
	if (UNEXPECTED(!_zephir_prop_3)) {
		_zephir_prop_3 = zend_string_init("cssClasses", 10, 1);
	}

	bool is_null_true = 1;
	ZEND_PARSE_PARAMETERS_START(0, 2)
		Z_PARAM_OPTIONAL
		Z_PARAM_OBJECT_OF_CLASS_OR_NULL(escaper, phalcon_html_escaper_escaperinterface_ce)
		Z_PARAM_OBJECT_OF_CLASS_OR_NULL(session, phalcon_session_managerinterface_ce)
	ZEND_PARSE_PARAMETERS_END();
	ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0);
	zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__);
	zephir_fetch_params(1, 0, 2, &escaper, &session);
	if (!escaper) {
		escaper = &escaper_sub;
		escaper = &__$null;
	}
	if (!session) {
		session = &session_sub;
		session = &__$null;
	}
	zephir_update_property_zval_cached(this_ptr, _zephir_prop_0, 202, escaper);
	zephir_update_property_zval_cached(this_ptr, _zephir_prop_1, 203, session);
	ZEPHIR_INIT_VAR(&_0);
	object_init_ex(&_0, phalcon_support_helper_str_interpolate_ce);
	if (zephir_has_constructor(&_0)) {
		ZEPHIR_CALL_METHOD(NULL, &_0, "__construct", NULL, 0);
		zephir_check_call_status();
	}

	zephir_update_property_zval_cached(this_ptr, _zephir_prop_2, 204, &_0);
	ZEPHIR_INIT_VAR(&_1);
	zephir_create_array(&_1, 4, 0);
	add_assoc_stringl_ex(&_1, SL("error"), SL("errorMessage"));
	add_assoc_stringl_ex(&_1, SL("notice"), SL("noticeMessage"));
	add_assoc_stringl_ex(&_1, SL("success"), SL("successMessage"));
	add_assoc_stringl_ex(&_1, SL("warning"), SL("warningMessage"));
	zephir_update_property_zval_cached(this_ptr, _zephir_prop_3, 205, &_1);
	ZEPHIR_MM_RESTORE();
}

/**
 * Clears accumulated messages when implicit flush is disabled
 */
PHP_METHOD(Phalcon_Flash_AbstractFlash, clear)
{
	zval _0;
	zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL;
	zval *this_ptr = getThis();

	ZVAL_UNDEF(&_0);
	static zend_string *_zephir_prop_0 = NULL;
	if (UNEXPECTED(!_zephir_prop_0)) {
		_zephir_prop_0 = zend_string_init("messages", 8, 1);
	}
	ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0);
	zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__);

	ZEPHIR_INIT_VAR(&_0);
	array_init(&_0);
	zephir_update_property_zval_cached(this_ptr, _zephir_prop_0, 206, &_0);
	ZEPHIR_MM_RESTORE();
}

/**
 * Shows a HTML error message
 *
 *```php
 * $flash->error("This is an error");
 *```
 *
 * @param string $message
 *
 * @return string|null
 */
PHP_METHOD(Phalcon_Flash_AbstractFlash, error)
{
	zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL;
	zend_long ZEPHIR_LAST_CALL_STATUS;
	zval message_zv, _0;
	zend_string *message = NULL;
	zval *this_ptr = getThis();

	ZVAL_UNDEF(&message_zv);
	ZVAL_UNDEF(&_0);
	ZEND_PARSE_PARAMETERS_START(1, 1)
		Z_PARAM_STR(message)
	ZEND_PARSE_PARAMETERS_END();
	ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0);
	zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__);
	zephir_memory_observe(&message_zv);
	ZVAL_STR_COPY(&message_zv, message);
	ZEPHIR_INIT_VAR(&_0);
	ZVAL_STRING(&_0, "error");
	ZEPHIR_RETURN_CALL_METHOD(this_ptr, "message", NULL, 0, &_0, &message_zv);
	zephir_check_call_status();
	RETURN_MM();
}

/**
 * @return bool
 */
PHP_METHOD(Phalcon_Flash_AbstractFlash, getAutoescape)
{

	RETURN_MEMBER(getThis(), "autoescape");
}

/**
 * @return bool
 */
PHP_METHOD(Phalcon_Flash_AbstractFlash, getAutomaticHtml)
{

	RETURN_MEMBER(getThis(), "automaticHtml");
}

/**
 * @return array
 */
PHP_METHOD(Phalcon_Flash_AbstractFlash, getCssClasses)
{

	RETURN_MEMBER_TYPED(getThis(), "cssClasses", IS_ARRAY);
}

/**
 * @return array
 */
PHP_METHOD(Phalcon_Flash_AbstractFlash, getCssIconClasses)
{

	RETURN_MEMBER_TYPED(getThis(), "cssIconClasses", IS_ARRAY);
}

/**
 * @return string
 */
PHP_METHOD(Phalcon_Flash_AbstractFlash, getCustomTemplate)
{

	RETURN_MEMBER_TYPED(getThis(), "customTemplate", IS_STRING);
}

/**
 * Returns the Escaper Service
 *
 * @return EscaperInterface
 * @throws Exception
 */
PHP_METHOD(Phalcon_Flash_AbstractFlash, getEscaperService)
{
	zend_bool _2;
	zval _0, _1, _3, _4, _5, _6$$4, _7$$4, _8$$4;
	zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL;
	zend_long ZEPHIR_LAST_CALL_STATUS;
	zval *this_ptr = getThis();

	ZVAL_UNDEF(&_0);
	ZVAL_UNDEF(&_1);
	ZVAL_UNDEF(&_3);
	ZVAL_UNDEF(&_4);
	ZVAL_UNDEF(&_5);
	ZVAL_UNDEF(&_6$$4);
	ZVAL_UNDEF(&_7$$4);
	ZVAL_UNDEF(&_8$$4);
	static zend_string *_zephir_prop_0 = NULL;
	static zend_string *_zephir_prop_1 = NULL;
	if (UNEXPECTED(!_zephir_prop_0)) {
		_zephir_prop_0 = zend_string_init("escaperService", 14, 1);
	}
	if (UNEXPECTED(!_zephir_prop_1)) {
		_zephir_prop_1 = zend_string_init("container", 9, 1);
	}
	ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0);
	zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__);

	zephir_read_property_cached(&_0, this_ptr, _zephir_prop_0, 202, PH_NOISY_CC | PH_READONLY);
	if (Z_TYPE_P(&_0) != IS_NULL) {
		RETURN_MM_MEMBER(getThis(), "escaperService");
	}
	zephir_read_property_cached(&_1, this_ptr, _zephir_prop_1, 207, PH_NOISY_CC | PH_READONLY);
	_2 = Z_TYPE_P(&_1) != IS_NULL;
	if (_2) {
		zephir_read_property_cached(&_3, this_ptr, _zephir_prop_1, 207, PH_NOISY_CC | PH_READONLY);
		ZEPHIR_INIT_VAR(&_5);
		ZVAL_STRING(&_5, "escaper");
		ZEPHIR_CALL_METHOD(&_4, &_3, "has", NULL, 0, &_5);
		zephir_check_call_status();
		_2 = ZEPHIR_IS_TRUE_IDENTICAL(&_4);
	}
	if (_2) {
		zephir_read_property_cached(&_6$$4, this_ptr, _zephir_prop_1, 207, PH_NOISY_CC | PH_READONLY);
		ZEPHIR_INIT_VAR(&_8$$4);
		ZVAL_STRING(&_8$$4, "escaper");
		ZEPHIR_CALL_METHOD(&_7$$4, &_6$$4, "getshared", NULL, 0, &_8$$4);
		zephir_check_call_status();
		zephir_update_property_zval_cached(this_ptr, _zephir_prop_0, 202, &_7$$4);
		RETURN_MM_MEMBER(getThis(), "escaperService");
	}
	ZEPHIR_INIT_NVAR(&_5);
	object_init_ex(&_5, phalcon_flash_exceptions_escaperserviceunavailable_ce);
	ZEPHIR_CALL_METHOD(NULL, &_5, "__construct", NULL, 192);
	zephir_check_call_status();
	zephir_throw_exception_debug(&_5, "phalcon/Flash/AbstractFlash.zep", 194);
	ZEPHIR_MM_RESTORE();
	return;
}

/**
 * Outputs a message. Delivery semantics differ per implementation:
 * `Direct` renders and emits immediately, `Session` stores the raw
 * message for output on a later request.
 *
 * @param string $type
 * @param mixed  $message
 *
 * @return string|null
 */
PHP_METHOD(Phalcon_Flash_AbstractFlash, message)
{
}

/**
 * Shows a HTML notice/information message
 *
 *```php
 * $flash->notice("This is an information");
 *```
 *
 * @param string $message
 *
 * @return string|null
 */
PHP_METHOD(Phalcon_Flash_AbstractFlash, notice)
{
	zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL;
	zend_long ZEPHIR_LAST_CALL_STATUS;
	zval message_zv, _0;
	zend_string *message = NULL;
	zval *this_ptr = getThis();

	ZVAL_UNDEF(&message_zv);
	ZVAL_UNDEF(&_0);
	ZEND_PARSE_PARAMETERS_START(1, 1)
		Z_PARAM_STR(message)
	ZEND_PARSE_PARAMETERS_END();
	ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0);
	zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__);
	zephir_memory_observe(&message_zv);
	ZVAL_STR_COPY(&message_zv, message);
	ZEPHIR_INIT_VAR(&_0);
	ZVAL_STRING(&_0, "notice");
	ZEPHIR_RETURN_CALL_METHOD(this_ptr, "message", NULL, 0, &_0, &message_zv);
	zephir_check_call_status();
	RETURN_MM();
}

/**
 * Set the autoescape mode in generated HTML
 *
 * @param bool $autoescape
 */
PHP_METHOD(Phalcon_Flash_AbstractFlash, setAutoescape)
{
	zval *autoescape_param = NULL, __$true, __$false;
	zend_bool autoescape;
	zval *this_ptr = getThis();

	ZVAL_BOOL(&__$true, 1);
	ZVAL_BOOL(&__$false, 0);
	static zend_string *_zephir_prop_0 = NULL;
	if (UNEXPECTED(!_zephir_prop_0)) {
		_zephir_prop_0 = zend_string_init("autoescape", 10, 1);
	}

	ZEND_PARSE_PARAMETERS_START(1, 1)
		Z_PARAM_BOOL(autoescape)
	ZEND_PARSE_PARAMETERS_END();
	zephir_fetch_params_without_memory_grow(1, 0, &autoescape_param);
	if (autoescape) {
		zephir_update_property_zval_cached(this_ptr, _zephir_prop_0, 208, &__$true);
	} else {
		zephir_update_property_zval_cached(this_ptr, _zephir_prop_0, 208, &__$false);
	}
	RETURN_THISW();
}

/**
 * Set if the output must be implicitly formatted with HTML
 *
 * @param bool $automaticHtml
 */
PHP_METHOD(Phalcon_Flash_AbstractFlash, setAutomaticHtml)
{
	zval *automaticHtml_param = NULL, __$true, __$false;
	zend_bool automaticHtml;
	zval *this_ptr = getThis();

	ZVAL_BOOL(&__$true, 1);
	ZVAL_BOOL(&__$false, 0);
	static zend_string *_zephir_prop_0 = NULL;
	if (UNEXPECTED(!_zephir_prop_0)) {
		_zephir_prop_0 = zend_string_init("automaticHtml", 13, 1);
	}

	ZEND_PARSE_PARAMETERS_START(1, 1)
		Z_PARAM_BOOL(automaticHtml)
	ZEND_PARSE_PARAMETERS_END();
	zephir_fetch_params_without_memory_grow(1, 0, &automaticHtml_param);
	if (automaticHtml) {
		zephir_update_property_zval_cached(this_ptr, _zephir_prop_0, 209, &__$true);
	} else {
		zephir_update_property_zval_cached(this_ptr, _zephir_prop_0, 209, &__$false);
	}
	RETURN_THISW();
}

/**
 * Set an array with CSS classes to format the messages
 *
 * @param array $cssClasses
 */
PHP_METHOD(Phalcon_Flash_AbstractFlash, setCssClasses)
{
	zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL;
	zval *cssClasses_param = NULL;
	zval cssClasses;
	zval *this_ptr = getThis();

	ZVAL_UNDEF(&cssClasses);
	static zend_string *_zephir_prop_0 = NULL;
	if (UNEXPECTED(!_zephir_prop_0)) {
		_zephir_prop_0 = zend_string_init("cssClasses", 10, 1);
	}

	ZEND_PARSE_PARAMETERS_START(1, 1)
		ZEPHIR_Z_PARAM_ARRAY(cssClasses, cssClasses_param)
	ZEND_PARSE_PARAMETERS_END();
	ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0);
	zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__);
	zephir_fetch_params(1, 1, 0, &cssClasses_param);
	zephir_get_arrval(&cssClasses, cssClasses_param);
	zephir_update_property_zval_cached(this_ptr, _zephir_prop_0, 205, &cssClasses);
	RETURN_THIS();
}

/**
 * Set an array with CSS classes to format the icon messages
 *
 * @param array $cssIconClasses
 */
PHP_METHOD(Phalcon_Flash_AbstractFlash, setCssIconClasses)
{
	zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL;
	zval *cssIconClasses_param = NULL;
	zval cssIconClasses;
	zval *this_ptr = getThis();

	ZVAL_UNDEF(&cssIconClasses);
	static zend_string *_zephir_prop_0 = NULL;
	if (UNEXPECTED(!_zephir_prop_0)) {
		_zephir_prop_0 = zend_string_init("cssIconClasses", 14, 1);
	}

	ZEND_PARSE_PARAMETERS_START(1, 1)
		ZEPHIR_Z_PARAM_ARRAY(cssIconClasses, cssIconClasses_param)
	ZEND_PARSE_PARAMETERS_END();
	ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0);
	zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__);
	zephir_fetch_params(1, 1, 0, &cssIconClasses_param);
	zephir_get_arrval(&cssIconClasses, cssIconClasses_param);
	zephir_update_property_zval_cached(this_ptr, _zephir_prop_0, 210, &cssIconClasses);
	RETURN_THIS();
}

/**
 * Set a custom template for showing the messages
 *
 * @param string $customTemplate
 */
PHP_METHOD(Phalcon_Flash_AbstractFlash, setCustomTemplate)
{
	zval customTemplate_zv;
	zend_string *customTemplate = NULL;
	zval *this_ptr = getThis();

	ZVAL_UNDEF(&customTemplate_zv);
	static zend_string *_zephir_prop_0 = NULL;
	if (UNEXPECTED(!_zephir_prop_0)) {
		_zephir_prop_0 = zend_string_init("customTemplate", 14, 1);
	}

	ZEND_PARSE_PARAMETERS_START(1, 1)
		Z_PARAM_STR(customTemplate)
	ZEND_PARSE_PARAMETERS_END();
	ZVAL_STR(&customTemplate_zv, customTemplate);
	zephir_update_property_zval_cached(this_ptr, _zephir_prop_0, 211, &customTemplate_zv);
	RETURN_THISW();
}

/**
 * Sets the Escaper Service
 *
 * @param EscaperInterface $escaperService
 */
PHP_METHOD(Phalcon_Flash_AbstractFlash, setEscaperService)
{
	zval *escaperService, escaperService_sub;
	zval *this_ptr = getThis();

	ZVAL_UNDEF(&escaperService_sub);
	static zend_string *_zephir_prop_0 = NULL;
	if (UNEXPECTED(!_zephir_prop_0)) {
		_zephir_prop_0 = zend_string_init("escaperService", 14, 1);
	}

	ZEND_PARSE_PARAMETERS_START(1, 1)
		Z_PARAM_OBJECT_OF_CLASS(escaperService, phalcon_html_escaper_escaperinterface_ce)
	ZEND_PARSE_PARAMETERS_END();
	zephir_fetch_params_without_memory_grow(1, 0, &escaperService);
	zephir_update_property_zval_cached(this_ptr, _zephir_prop_0, 202, escaperService);
	RETURN_THISW();
}

/**
 * Set whether the output must be implicitly flushed to the output or
 * returned as string
 *
 * Note: `output()` is an echo API and requires implicit flush to remain
 * enabled (the default). With implicit flush disabled, `message()` returns
 * the rendered string while `output()` does not emit it.
 *
 * @param bool $implicitFlush
 */
PHP_METHOD(Phalcon_Flash_AbstractFlash, setImplicitFlush)
{
	zval *implicitFlush_param = NULL, __$true, __$false;
	zend_bool implicitFlush;
	zval *this_ptr = getThis();

	ZVAL_BOOL(&__$true, 1);
	ZVAL_BOOL(&__$false, 0);
	static zend_string *_zephir_prop_0 = NULL;
	if (UNEXPECTED(!_zephir_prop_0)) {
		_zephir_prop_0 = zend_string_init("implicitFlush", 13, 1);
	}

	ZEND_PARSE_PARAMETERS_START(1, 1)
		Z_PARAM_BOOL(implicitFlush)
	ZEND_PARSE_PARAMETERS_END();
	zephir_fetch_params_without_memory_grow(1, 0, &implicitFlush_param);
	if (implicitFlush) {
		zephir_update_property_zval_cached(this_ptr, _zephir_prop_0, 212, &__$true);
	} else {
		zephir_update_property_zval_cached(this_ptr, _zephir_prop_0, 212, &__$false);
	}
	RETURN_THISW();
}

/**
 * Shows a HTML success message
 *
 *```php
 * $flash->success("The process was finished successfully");
 *```
 *
 * @param string $message
 *
 * @return string|null
 */
PHP_METHOD(Phalcon_Flash_AbstractFlash, success)
{
	zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL;
	zend_long ZEPHIR_LAST_CALL_STATUS;
	zval message_zv, _0;
	zend_string *message = NULL;
	zval *this_ptr = getThis();

	ZVAL_UNDEF(&message_zv);
	ZVAL_UNDEF(&_0);
	ZEND_PARSE_PARAMETERS_START(1, 1)
		Z_PARAM_STR(message)
	ZEND_PARSE_PARAMETERS_END();
	ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0);
	zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__);
	zephir_memory_observe(&message_zv);
	ZVAL_STR_COPY(&message_zv, message);
	ZEPHIR_INIT_VAR(&_0);
	ZVAL_STRING(&_0, "success");
	ZEPHIR_RETURN_CALL_METHOD(this_ptr, "message", NULL, 0, &_0, &message_zv);
	zephir_check_call_status();
	RETURN_MM();
}

/**
 * Outputs a message formatting it with HTML
 *
 *```php
 * $flash->outputMessage("error", $message);
 *```
 *
 * @param string $type
 * @param mixed  $message
 *
 * @return string|null
 * @throws Exception
 */
PHP_METHOD(Phalcon_Flash_AbstractFlash, outputMessage)
{
	zend_bool _0, _8;
	zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL;
	zephir_fcall_cache_entry *_4 = NULL, *_5 = NULL;
	zend_long ZEPHIR_LAST_CALL_STATUS;
	zval type_zv, *message = NULL, message_sub, content, html, item, prepared, *_3, _7, _1$$3, _2$$4, _6$$5, _9$$8;
	zend_string *type = NULL;
	zval *this_ptr = getThis();

	ZVAL_UNDEF(&type_zv);
	ZVAL_UNDEF(&message_sub);
	ZVAL_UNDEF(&content);
	ZVAL_UNDEF(&html);
	ZVAL_UNDEF(&item);
	ZVAL_UNDEF(&prepared);
	ZVAL_UNDEF(&_7);
	ZVAL_UNDEF(&_1$$3);
	ZVAL_UNDEF(&_2$$4);
	ZVAL_UNDEF(&_6$$5);
	ZVAL_UNDEF(&_9$$8);
	static zend_string *_zephir_prop_0 = NULL;
	if (UNEXPECTED(!_zephir_prop_0)) {
		_zephir_prop_0 = zend_string_init("implicitFlush", 13, 1);
	}

	ZEND_PARSE_PARAMETERS_START(2, 2)
		Z_PARAM_STR(type)
		Z_PARAM_ZVAL(message)
	ZEND_PARSE_PARAMETERS_END();
	ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0);
	zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__);
	message = ZEND_CALL_ARG(execute_data, 2);
	zephir_memory_observe(&type_zv);
	ZVAL_STR_COPY(&type_zv, type);
	ZEPHIR_SEPARATE_PARAM(message);
	ZEPHIR_INIT_VAR(&content);
	ZVAL_STRING(&content, "");
	_0 = Z_TYPE_P(message) != IS_ARRAY;
	if (_0) {
		_0 = Z_TYPE_P(message) != IS_STRING;
	}
	if (_0) {
		ZEPHIR_INIT_VAR(&_1$$3);
		object_init_ex(&_1$$3, phalcon_flash_exceptions_flashmessagenotstringorarray_ce);
		ZEPHIR_CALL_METHOD(NULL, &_1$$3, "__construct", NULL, 193);
		zephir_check_call_status();
		zephir_throw_exception_debug(&_1$$3, "phalcon/Flash/AbstractFlash.zep", 350);
		ZEPHIR_MM_RESTORE();
		return;
	}
	if (Z_TYPE_P(message) != IS_ARRAY) {
		ZEPHIR_INIT_VAR(&_2$$4);
		zephir_create_array(&_2$$4, 1, 0);
		zephir_array_fast_append(&_2$$4, message);
		ZEPHIR_CPY_WRT(message, &_2$$4);
	}
	zephir_is_iterable(message, 0, "phalcon/Flash/AbstractFlash.zep", 376);
	if (Z_TYPE_P(message) == IS_ARRAY) {
		ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(message), _3)
		{
			ZEPHIR_INIT_NVAR(&item);
			ZVAL_COPY(&item, _3);
			ZEPHIR_CALL_METHOD(&prepared, this_ptr, "prepareescapedmessage", &_4, 194, &item);
			zephir_check_call_status();
			ZEPHIR_CALL_METHOD(&html, this_ptr, "preparehtmlmessage", &_5, 195, &type_zv, &prepared);
			zephir_check_call_status();
			zephir_read_property_cached(&_6$$5, this_ptr, _zephir_prop_0, 212, PH_NOISY_CC | PH_READONLY);
			if (ZEPHIR_IS_TRUE_IDENTICAL(&_6$$5)) {
				zend_print_zval(&html, 0);
			} else {
				zephir_concat_self(&content, &html);
				zephir_update_property_array_append(this_ptr, SL("messages"), &html);
			}
		} ZEND_HASH_FOREACH_END();
	} else {
		ZEPHIR_CALL_METHOD(NULL, message, "rewind", NULL, 0);
		zephir_check_call_status();
		_8 = 1;
		while (1) {
			if (_8) {
				_8 = 0;
			} else {
				ZEPHIR_CALL_METHOD(NULL, message, "next", NULL, 0);
				zephir_check_call_status();
			}
			ZEPHIR_CALL_METHOD(&_7, message, "valid", NULL, 0);
			zephir_check_call_status();
			if (!zend_is_true(&_7)) {
				break;
			}
			ZEPHIR_CALL_METHOD(&item, message, "current", NULL, 0);
			zephir_check_call_status();
				ZEPHIR_CALL_METHOD(&prepared, this_ptr, "prepareescapedmessage", &_4, 194, &item);
				zephir_check_call_status();
				ZEPHIR_CALL_METHOD(&html, this_ptr, "preparehtmlmessage", &_5, 195, &type_zv, &prepared);
				zephir_check_call_status();
				zephir_read_property_cached(&_9$$8, this_ptr, _zephir_prop_0, 212, PH_NOISY_CC | PH_READONLY);
				if (ZEPHIR_IS_TRUE_IDENTICAL(&_9$$8)) {
					zend_print_zval(&html, 0);
				} else {
					zephir_concat_self(&content, &html);
					zephir_update_property_array_append(this_ptr, SL("messages"), &html);
				}
		}
	}
	ZEPHIR_INIT_NVAR(&item);
	RETURN_CCTOR(&content);
}

/**
 * Shows a HTML warning message
 *
 *```php
 * $flash->warning("Hey, this is important");
 *```
 *
 * @param string $message
 *
 * @return string|null
 */
PHP_METHOD(Phalcon_Flash_AbstractFlash, warning)
{
	zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL;
	zend_long ZEPHIR_LAST_CALL_STATUS;
	zval message_zv, _0;
	zend_string *message = NULL;
	zval *this_ptr = getThis();

	ZVAL_UNDEF(&message_zv);
	ZVAL_UNDEF(&_0);
	ZEND_PARSE_PARAMETERS_START(1, 1)
		Z_PARAM_STR(message)
	ZEND_PARSE_PARAMETERS_END();
	ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0);
	zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__);
	zephir_memory_observe(&message_zv);
	ZVAL_STR_COPY(&message_zv, message);
	ZEPHIR_INIT_VAR(&_0);
	ZVAL_STRING(&_0, "warning");
	ZEPHIR_RETURN_CALL_METHOD(this_ptr, "message", NULL, 0, &_0, &message_zv);
	zephir_check_call_status();
	RETURN_MM();
}

/**
 * Returns the template for the CSS classes (with icon classes). It will
 * either be the custom one (defined) or the default
 *
 * @param string $cssClasses
 * @param string $cssIconClasses
 *
 * @return string
 */
PHP_METHOD(Phalcon_Flash_AbstractFlash, getTemplate)
{
	zval _4;
	zval divString, iconString, template;
	zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL;
	zend_long ZEPHIR_LAST_CALL_STATUS;
	zval cssClasses_zv, cssIconClasses_zv, _0, _1, _2, _3;
	zend_string *cssClasses = NULL, *cssIconClasses = NULL;
	zval *this_ptr = getThis();

	ZVAL_UNDEF(&cssClasses_zv);
	ZVAL_UNDEF(&cssIconClasses_zv);
	ZVAL_UNDEF(&_0);
	ZVAL_UNDEF(&_1);
	ZVAL_UNDEF(&_2);
	ZVAL_UNDEF(&_3);
	ZVAL_UNDEF(&divString);
	ZVAL_UNDEF(&iconString);
	ZVAL_UNDEF(&template);
	ZVAL_UNDEF(&_4);
	static zend_string *_zephir_prop_0 = NULL;
	static zend_string *_zephir_prop_1 = NULL;
	if (UNEXPECTED(!_zephir_prop_0)) {
		_zephir_prop_0 = zend_string_init("customTemplate", 14, 1);
	}
	if (UNEXPECTED(!_zephir_prop_1)) {
		_zephir_prop_1 = zend_string_init("interpolator", 12, 1);
	}

	ZEND_PARSE_PARAMETERS_START(2, 2)
		Z_PARAM_STR(cssClasses)
		Z_PARAM_STR(cssIconClasses)
	ZEND_PARSE_PARAMETERS_END();
	ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0);
	zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__);
	zephir_memory_observe(&cssClasses_zv);
	ZVAL_STR_COPY(&cssClasses_zv, cssClasses);
	zephir_memory_observe(&cssIconClasses_zv);
	ZVAL_STR_COPY(&cssIconClasses_zv, cssIconClasses);
	ZEPHIR_INIT_VAR(&_0);
	ZEPHIR_GET_CONSTANT(&_0, "PHP_EOL");
	ZEPHIR_INIT_VAR(&_1);
	ZEPHIR_CONCAT_SV(&_1, "<div%divString%>%iconString%%message%</div>", &_0);
	zephir_get_strval(&template, &_1);
	ZEPHIR_INIT_VAR(&divString);
	ZVAL_STRING(&divString, "");
	ZEPHIR_INIT_VAR(&iconString);
	ZVAL_STRING(&iconString, "");
	zephir_read_property_cached(&_2, this_ptr, _zephir_prop_0, 211, PH_NOISY_CC | PH_READONLY);
	if (!(ZEPHIR_IS_EMPTY(&_2))) {
		RETURN_MM_MEMBER_TYPED(getThis(), "customTemplate", IS_STRING);
	}
	if (!(ZEPHIR_IS_EMPTY(&cssClasses_zv))) {
		ZEPHIR_INIT_NVAR(&divString);
		ZVAL_STRING(&divString, " class=\"%cssClass%\"");
		if (!(ZEPHIR_IS_EMPTY(&cssIconClasses_zv))) {
			ZEPHIR_INIT_NVAR(&iconString);
			ZVAL_STRING(&iconString, "<i class=\"%cssIconClass%\"></i> ");
		}
	}
	zephir_read_property_cached(&_3, this_ptr, _zephir_prop_1, 204, PH_NOISY_CC | PH_READONLY);
	ZEPHIR_INIT_VAR(&_4);
	zephir_create_array(&_4, 2, 0);
	zephir_array_update_string(&_4, SL("divString"), &divString, PH_COPY | PH_SEPARATE);
	zephir_array_update_string(&_4, SL("iconString"), &iconString, PH_COPY | PH_SEPARATE);
	ZEPHIR_RETURN_CALL_METHOD(&_3, "__invoke", NULL, 0, &template, &_4);
	zephir_check_call_status();
	RETURN_MM();
}

/**
 * Returns the message escaped if the autoEscape is true, otherwise the
 * original message is returned
 *
 * @param string $message
 *
 * @return string
 * @throws Exception
 */
PHP_METHOD(Phalcon_Flash_AbstractFlash, prepareEscapedMessage)
{
	zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL;
	zend_long ZEPHIR_LAST_CALL_STATUS;
	zval message_zv, escaper, _0;
	zend_string *message = NULL;
	zval *this_ptr = getThis();

	ZVAL_UNDEF(&message_zv);
	ZVAL_UNDEF(&escaper);
	ZVAL_UNDEF(&_0);
	static zend_string *_zephir_prop_0 = NULL;
	if (UNEXPECTED(!_zephir_prop_0)) {
		_zephir_prop_0 = zend_string_init("autoescape", 10, 1);
	}

	ZEND_PARSE_PARAMETERS_START(1, 1)
		Z_PARAM_STR(message)
	ZEND_PARSE_PARAMETERS_END();
	ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0);
	zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__);
	zephir_memory_observe(&message_zv);
	ZVAL_STR_COPY(&message_zv, message);
	zephir_read_property_cached(&_0, this_ptr, _zephir_prop_0, 208, PH_NOISY_CC | PH_READONLY);
	if (!ZEPHIR_IS_TRUE_IDENTICAL(&_0)) {
		RETURN_STR(zend_string_copy(message));
	}
	ZEPHIR_CALL_METHOD(&escaper, this_ptr, "getescaperservice", NULL, 0);
	zephir_check_call_status();
	ZEPHIR_RETURN_CALL_METHOD(&escaper, "html", NULL, 0, &message_zv);
	zephir_check_call_status();
	RETURN_MM();
}

/**
 * Prepares the HTML output for the message. If automaticHtml is not set
 * then the original message is returned
 *
 * @param string $type
 * @param string $message
 *
 * @return string
 */
PHP_METHOD(Phalcon_Flash_AbstractFlash, prepareHtmlMessage)
{
	zval _8;
	zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL;
	zend_long ZEPHIR_LAST_CALL_STATUS;
	zval type_zv, message_zv, cssClasses, cssIconClasses, _0, _1, _2, _3, _4, _5, _6, _7;
	zend_string *type = NULL, *message = NULL;
	zval *this_ptr = getThis();

	ZVAL_UNDEF(&type_zv);
	ZVAL_UNDEF(&message_zv);
	ZVAL_UNDEF(&cssClasses);
	ZVAL_UNDEF(&cssIconClasses);
	ZVAL_UNDEF(&_0);
	ZVAL_UNDEF(&_1);
	ZVAL_UNDEF(&_2);
	ZVAL_UNDEF(&_3);
	ZVAL_UNDEF(&_4);
	ZVAL_UNDEF(&_5);
	ZVAL_UNDEF(&_6);
	ZVAL_UNDEF(&_7);
	ZVAL_UNDEF(&_8);
	static zend_string *_zephir_prop_0 = NULL;
	static zend_string *_zephir_prop_1 = NULL;
	static zend_string *_zephir_prop_2 = NULL;
	static zend_string *_zephir_prop_3 = NULL;
	if (UNEXPECTED(!_zephir_prop_0)) {
		_zephir_prop_0 = zend_string_init("automaticHtml", 13, 1);
	}
	if (UNEXPECTED(!_zephir_prop_1)) {
		_zephir_prop_1 = zend_string_init("cssClasses", 10, 1);
	}
	if (UNEXPECTED(!_zephir_prop_2)) {
		_zephir_prop_2 = zend_string_init("cssIconClasses", 14, 1);
	}
	if (UNEXPECTED(!_zephir_prop_3)) {
		_zephir_prop_3 = zend_string_init("interpolator", 12, 1);
	}

	ZEND_PARSE_PARAMETERS_START(2, 2)
		Z_PARAM_STR(type)
		Z_PARAM_STR(message)
	ZEND_PARSE_PARAMETERS_END();
	ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0);
	zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__);
	zephir_memory_observe(&type_zv);
	ZVAL_STR_COPY(&type_zv, type);
	zephir_memory_observe(&message_zv);
	ZVAL_STR_COPY(&message_zv, message);
	zephir_read_property_cached(&_0, this_ptr, _zephir_prop_0, 209, PH_NOISY_CC | PH_READONLY);
	if (!ZEPHIR_IS_TRUE_IDENTICAL(&_0)) {
		RETURN_STR(zend_string_copy(message));
	}
	zephir_read_property_cached(&_2, this_ptr, _zephir_prop_1, 205, PH_NOISY_CC | PH_READONLY);
	ZEPHIR_CALL_METHOD(&_1, this_ptr, "checkclasses", NULL, 196, &_2, &type_zv);
	zephir_check_call_status();
	ZVAL_LONG(&_3, 3);
	ZEPHIR_INIT_VAR(&_4);
	ZVAL_STRING(&_4, "utf-8");
	ZEPHIR_CALL_FUNCTION(&cssClasses, "htmlspecialchars", NULL, 197, &_1, &_3, &_4);
	zephir_check_call_status();
	zephir_read_property_cached(&_3, this_ptr, _zephir_prop_2, 210, PH_NOISY_CC | PH_READONLY);
	ZEPHIR_CALL_METHOD(&_5, this_ptr, "checkclasses", NULL, 196, &_3, &type_zv);
	zephir_check_call_status();
	ZVAL_LONG(&_6, 3);
	ZEPHIR_INIT_NVAR(&_4);
	ZVAL_STRING(&_4, "utf-8");
	ZEPHIR_CALL_FUNCTION(&cssIconClasses, "htmlspecialchars", NULL, 197, &_5, &_6, &_4);
	zephir_check_call_status();
	zephir_read_property_cached(&_6, this_ptr, _zephir_prop_3, 204, PH_NOISY_CC | PH_READONLY);
	ZEPHIR_CALL_METHOD(&_7, this_ptr, "gettemplate", NULL, 198, &cssClasses, &cssIconClasses);
	zephir_check_call_status();
	ZEPHIR_INIT_VAR(&_8);
	zephir_create_array(&_8, 3, 0);
	zephir_array_update_string(&_8, SL("cssClass"), &cssClasses, PH_COPY | PH_SEPARATE);
	zephir_array_update_string(&_8, SL("cssIconClass"), &cssIconClasses, PH_COPY | PH_SEPARATE);
	zephir_array_update_string(&_8, SL("message"), &message_zv, PH_COPY | PH_SEPARATE);
	ZEPHIR_RETURN_CALL_METHOD(&_6, "__invoke", NULL, 0, &_7, &_8);
	zephir_check_call_status();
	RETURN_MM();
}

/**
 * Checks the collection and returns the content as a string
 * (array is joined)
 *
 * @param array  $collection
 * @param string $type
 *
 * @return string
 */
PHP_METHOD(Phalcon_Flash_AbstractFlash, checkClasses)
{
	zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL;
	zend_string *type = NULL;
	zval *collection_param = NULL, type_zv, content, _0$$5, _1$$4;
	zval collection;

	ZVAL_UNDEF(&collection);
	ZVAL_UNDEF(&type_zv);
	ZVAL_UNDEF(&content);
	ZVAL_UNDEF(&_0$$5);
	ZVAL_UNDEF(&_1$$4);
	ZEND_PARSE_PARAMETERS_START(2, 2)
		ZEPHIR_Z_PARAM_ARRAY(collection, collection_param)
		Z_PARAM_STR(type)
	ZEND_PARSE_PARAMETERS_END();
	ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0);
	zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__);
	collection_param = ZEND_CALL_ARG(execute_data, 1);
	zephir_get_arrval(&collection, collection_param);
	zephir_memory_observe(&type_zv);
	ZVAL_STR_COPY(&type_zv, type);
	ZEPHIR_INIT_VAR(&content);
	ZVAL_STRING(&content, "");
	if (zephir_array_isset_value(&collection, &type_zv)) {
		ZEPHIR_OBS_NVAR(&content);
		zephir_array_fetch(&content, &collection, &type_zv, PH_NOISY, "phalcon/Flash/AbstractFlash.zep", 504);
	}
	if (1 != ZEPHIR_IS_EMPTY(&content)) {
		if (Z_TYPE_P(&content) != IS_ARRAY) {
			ZEPHIR_INIT_VAR(&_0$$5);
			zephir_create_array(&_0$$5, 1, 0);
			zephir_array_fast_append(&_0$$5, &content);
			ZEPHIR_CPY_WRT(&content, &_0$$5);
		}
		ZEPHIR_INIT_VAR(&_1$$4);
		zephir_fast_join_str(&_1$$4, SL(" "), &content);
		ZEPHIR_CPY_WRT(&content, &_1$$4);
	}
	RETURN_CCTOR(&content);
}

zend_object *zephir_init_properties_Phalcon_Flash_AbstractFlash(zend_class_entry *class_type)
{
		zval _0, _2, _4, _1$$3, _3$$4, _5$$5;
	zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL;
		ZVAL_UNDEF(&_0);
	ZVAL_UNDEF(&_2);
	ZVAL_UNDEF(&_4);
	ZVAL_UNDEF(&_1$$3);
	ZVAL_UNDEF(&_3$$4);
	ZVAL_UNDEF(&_5$$5);
	

		ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0);
		zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__);
	
	{
		zval local_this_ptr, *this_ptr = &local_this_ptr;
		ZEPHIR_CREATE_OBJECT(this_ptr, class_type);
		zephir_read_property_ex(&_0, this_ptr, ZEND_STRL("messages"), PH_NOISY_CC | PH_READONLY);
		if (Z_TYPE_P(&_0) == IS_NULL) {
			ZEPHIR_INIT_VAR(&_1$$3);
			array_init(&_1$$3);
			zephir_update_property_zval_ex(this_ptr, ZEND_STRL("messages"), &_1$$3);
		}
		zephir_read_property_ex(&_2, this_ptr, ZEND_STRL("cssIconClasses"), PH_NOISY_CC | PH_READONLY);
		if (Z_TYPE_P(&_2) == IS_NULL) {
			ZEPHIR_INIT_VAR(&_3$$4);
			array_init(&_3$$4);
			zephir_update_property_zval_ex(this_ptr, ZEND_STRL("cssIconClasses"), &_3$$4);
		}
		zephir_read_property_ex(&_4, this_ptr, ZEND_STRL("cssClasses"), PH_NOISY_CC | PH_READONLY);
		if (Z_TYPE_P(&_4) == IS_NULL) {
			ZEPHIR_INIT_VAR(&_5$$5);
			array_init(&_5$$5);
			zephir_update_property_zval_ex(this_ptr, ZEND_STRL("cssClasses"), &_5$$5);
		}
		ZEPHIR_MM_RESTORE();
		return Z_OBJ_P(this_ptr);
	}
}

