Exemplo n.º 1
0
/**
 * Returns the messages in the session flasher
 *
 * @param string $type
 * @param boolean $remove
 * @return array
 */
PHP_METHOD(Phalcon_Flash_Session, getMessages){

	zval *type = NULL, *remove = NULL, *messages, *return_messages;
	zval *do_remove;

	PHALCON_MM_GROW();

	phalcon_fetch_params(1, 0, 2, &type, &remove);
	
	if (!type) {
		PHALCON_INIT_VAR(type);
	}
	
	if (!remove) {
		PHALCON_INIT_VAR(remove);
		ZVAL_BOOL(remove, 1);
	}

	if (Z_TYPE_P(type) != IS_NULL) {
		PHALCON_INIT_VAR(do_remove);
		ZVAL_FALSE(do_remove);
	}
	else {
		do_remove = remove;
	}

	PHALCON_INIT_VAR(messages);
	phalcon_call_method_p1(messages, this_ptr, "_getsessionmessages", do_remove);
	if (Z_TYPE_P(messages) == IS_ARRAY) {
		if (likely(Z_TYPE_P(type) != IS_NULL)) {
			if (phalcon_array_isset(messages, type)) {
				PHALCON_OBS_VAR(return_messages);
				phalcon_array_fetch(&return_messages, messages, type, PH_NOISY);
				RETVAL_ZVAL(return_messages, 1, 0);
				if (zend_is_true(remove)) {
					phalcon_array_unset(&messages, type, 0);
					phalcon_call_method_p1_noret(this_ptr, "_setsessionmessages", messages);
				}

				PHALCON_MM_RESTORE();
				return;
			}

			RETURN_MM_EMPTY_ARRAY();
		}
	
		RETURN_CCTOR(messages);
	}
	
	RETURN_MM_EMPTY_ARRAY();
}
Exemplo n.º 2
0
/**
 * Returns the messages in the session flasher
 *
 * @param string $type
 * @param boolean $remove
 * @return array
 */
PHP_METHOD(Phalcon_Flash_Session, getMessages){

	zval *type = NULL, *remove = NULL, *messages = NULL, *return_messages;
	zval *do_remove;

	PHALCON_MM_GROW();

	phalcon_fetch_params(1, 0, 2, &type, &remove);

	if (!type) {
		type = PHALCON_GLOBAL(z_null);
	}

	if (!remove) {
		remove = PHALCON_GLOBAL(z_true);
	}

	if (Z_TYPE_P(type) != IS_NULL) {
		do_remove = PHALCON_GLOBAL(z_false);
	}
	else {
		do_remove = remove;
	}

	PHALCON_CALL_METHOD(&messages, this_ptr, "_getsessionmessages", do_remove);
	if (Z_TYPE_P(messages) == IS_ARRAY) {
		if (likely(Z_TYPE_P(type) != IS_NULL)) {
			if (phalcon_array_isset_fetch(&return_messages, messages, type)) {
				RETVAL_ZVAL(return_messages, 1, 0);
				if (zend_is_true(remove)) {
					phalcon_array_unset(&messages, type, 0);
					PHALCON_CALL_METHOD(NULL, this_ptr, "_setsessionmessages", messages);
				}

				PHALCON_MM_RESTORE();
				return;
			}

			RETURN_MM_EMPTY_ARRAY();
		}
	
		RETURN_CCTOR(messages);
	}
	
	RETURN_MM_EMPTY_ARRAY();
}
Exemplo n.º 3
0
/**
 * Returns the messages produced by a failed operation
 *
 * @return Phalcon\Mvc\Model\MessageInterface[]
 */
PHP_METHOD(Phalcon_Mvc_Model_Query_Status, getMessages){

	zval *model;

	PHALCON_MM_GROW();

	PHALCON_OBS_VAR(model);
	phalcon_read_property_this(&model, this_ptr, SL("_model"), PH_NOISY_CC);
	if (Z_TYPE_P(model) == IS_OBJECT) {
		phalcon_call_method(return_value, model, "getmessages");
		RETURN_MM();
	}
	
	RETURN_MM_EMPTY_ARRAY();
}
Exemplo n.º 4
0
/**
 * Returns all the attached listeners of a certain type
 *
 * @param string $type
 * @return array
 */
PHP_METHOD(Phalcon_Events_Manager, getListeners){

	zval *type, *events, *fire_events;

	PHALCON_MM_GROW();

	phalcon_fetch_params(1, 1, 0, &type);
	
	PHALCON_OBS_VAR(events);
	phalcon_read_property_this(&events, this_ptr, SL("_events"), PH_NOISY_CC);
	if (Z_TYPE_P(events) == IS_ARRAY) { 
		if (phalcon_array_isset(events, type)) {
			PHALCON_OBS_VAR(fire_events);
			phalcon_array_fetch(&fire_events, events, type, PH_NOISY);
			RETURN_CCTOR(fire_events);
		}
	}
	
	RETURN_MM_EMPTY_ARRAY();
}