예제 #1
0
PHP_METHOD(Test_TryTest, testTry4) {

	zephir_nts_static zephir_fcall_cache_entry *_2 = NULL, *_3 = NULL;
	int ZEPHIR_LAST_CALL_STATUS;
	zval *a_param = NULL, *_0 = NULL, *_1 = NULL;
	zend_bool a;

	ZEPHIR_MM_GROW();
	zephir_fetch_params(1, 1, 0, &a_param);

	a = zephir_get_boolval(a_param);



	/* try_start_1: */

		if (a) {
			ZEPHIR_INIT_VAR(_0);
			object_init_ex(_0, zend_exception_get_default(TSRMLS_C));
			ZEPHIR_INIT_VAR(_1);
			ZVAL_STRING(_1, "error!", ZEPHIR_TEMP_PARAM_COPY);
			ZEPHIR_CALL_METHOD(NULL, _0, "__construct", &_2, _1);
			zephir_check_temp_parameter(_1);
			zephir_check_call_status_or_jump(try_end_1);
			zephir_throw_exception_debug(_0, "test/trytest.zep", 46 TSRMLS_CC);
			goto try_end_1;

		} else {
			ZEPHIR_INIT_NVAR(_0);
			object_init_ex(_0, spl_ce_RuntimeException);
			ZEPHIR_INIT_NVAR(_1);
			ZVAL_STRING(_1, "error!", ZEPHIR_TEMP_PARAM_COPY);
			ZEPHIR_CALL_METHOD(NULL, _0, "__construct", &_3, _1);
			zephir_check_temp_parameter(_1);
			zephir_check_call_status_or_jump(try_end_1);
			zephir_throw_exception_debug(_0, "test/trytest.zep", 48 TSRMLS_CC);
			goto try_end_1;

		}

	try_end_1:

	if (EG(exception)) {
		ZEPHIR_INIT_NVAR(_0);
		ZEPHIR_CPY_WRT(_0, EG(exception));
		if (zephir_instance_of_ev(_0, spl_ce_RuntimeException TSRMLS_CC)) {
			zend_clear_exception(TSRMLS_C);
			RETURN_MM_STRING("domain error", 1);
		}
		ZEPHIR_INIT_NVAR(_0);
		ZEPHIR_CPY_WRT(_0, EG(exception));
		if (zephir_instance_of_ev(_0, zend_exception_get_default(TSRMLS_C) TSRMLS_CC)) {
			zend_clear_exception(TSRMLS_C);
			RETURN_MM_STRING("error", 1);
		}
	}
	RETURN_MM_BOOL(0);

}
예제 #2
0
PHP_METHOD(Test_TryTest, testTry7) {

	int ZEPHIR_LAST_CALL_STATUS;
	zval *a_param = NULL, *e = NULL, *_0 = NULL, *_1 = NULL;
	zend_bool a;

	ZEPHIR_MM_GROW();
	zephir_fetch_params(1, 1, 0, &a_param);

	a = zephir_get_boolval(a_param);



	/* try_start_1: */

		if (a) {
			ZEPHIR_INIT_VAR(_0);
			object_init_ex(_0, zend_exception_get_default(TSRMLS_C));
			ZEPHIR_INIT_VAR(_1);
			ZVAL_STRING(_1, "error!", 0);
			ZEPHIR_CALL_METHOD(NULL, _0, "__construct", NULL, _1);
			zephir_check_temp_parameter(_1);
			zephir_check_call_status_or_jump(try_end_1);
			zephir_throw_exception_debug(_0, "test/trytest.zep", 99 TSRMLS_CC);
			goto try_end_1;

		} else {
			ZEPHIR_INIT_LNVAR(_0);
			object_init_ex(_0, spl_ce_RuntimeException);
			ZEPHIR_INIT_NVAR(_1);
			ZVAL_STRING(_1, "error!", 0);
			ZEPHIR_CALL_METHOD(NULL, _0, "__construct", NULL, _1);
			zephir_check_temp_parameter(_1);
			zephir_check_call_status_or_jump(try_end_1);
			zephir_throw_exception_debug(_0, "test/trytest.zep", 101 TSRMLS_CC);
			goto try_end_1;

		}

	try_end_1:

	if (EG(exception)) {
		ZEPHIR_CPY_WRT(e, EG(exception));
		if (zephir_instance_of_ev(e, spl_ce_RuntimeException TSRMLS_CC)) {
			zend_clear_exception(TSRMLS_C);
			RETURN_MM_STRING("any error", 1);
		}
		if (zephir_instance_of_ev(e, zend_exception_get_default(TSRMLS_C) TSRMLS_CC)) {
			zend_clear_exception(TSRMLS_C);
			RETURN_MM_STRING("any error", 1);
		}
	}

}
예제 #3
0
PHP_METHOD(Test_TryTest, testTry8) {

	zephir_nts_static zephir_fcall_cache_entry *_2 = NULL;
	int ZEPHIR_LAST_CALL_STATUS;
	zval *_0, *_1;

	ZEPHIR_MM_GROW();


	/* try_start_1: */

		ZEPHIR_INIT_VAR(_0);
		object_init_ex(_0, zend_exception_get_default(TSRMLS_C));
		ZEPHIR_INIT_VAR(_1);
		ZVAL_STRING(_1, "error 1!", ZEPHIR_TEMP_PARAM_COPY);
		ZEPHIR_CALL_METHOD(NULL, _0, "__construct", &_2, _1);
		zephir_check_temp_parameter(_1);
		zephir_check_call_status_or_jump(try_end_1);
		zephir_throw_exception_debug(_0, "test/trytest.zep", 111 TSRMLS_CC);
		goto try_end_1;


	try_end_1:

	zend_clear_exception(TSRMLS_C);
	ZEPHIR_THROW_EXCEPTION_DEBUG_STR(zend_exception_get_default(TSRMLS_C), "error 2!", "test/trytest.zep", 113);
	return;

}
예제 #4
0
PHP_METHOD(Test_Exceptions, issue1325) {

	zval e, status, _0;
	zend_long ZEPHIR_LAST_CALL_STATUS;
	zval *this_ptr = getThis();

	ZVAL_UNDEF(&e);
	ZVAL_UNDEF(&status);
	ZVAL_UNDEF(&_0);

	ZEPHIR_MM_GROW();


	/* try_start_1: */

		ZEPHIR_CALL_METHOD(&status, this_ptr, "donoopexception", NULL, 27);
		zephir_check_call_status_or_jump(try_end_1);

	try_end_1:

	if (EG(exception)) {
		ZEPHIR_INIT_VAR(&_0);
		ZVAL_OBJ(&_0, EG(exception));
		Z_ADDREF_P(&_0);
		if (zephir_instance_of_ev(&_0, zend_exception_get_default(TSRMLS_C) TSRMLS_CC)) {
			zend_clear_exception(TSRMLS_C);
			ZEPHIR_CPY_WRT(&e, &_0);
			ZEPHIR_INIT_NVAR(&status);
			ZVAL_STRING(&status, "woop");
		}
	}
	RETURN_MM_LONG(1);

}
예제 #5
0
파일: trytest.zep.c 프로젝트: Mrhjx2/zephir
PHP_METHOD(Test_TryTest, testTry2) {

	zval _0$$3, _1$$3;
	int ZEPHIR_LAST_CALL_STATUS;
		zval this_zv;
	zval *this_ptr = getThis();
	if (EXPECTED(this_ptr)) {
		ZVAL_OBJ(&this_zv, Z_OBJ_P(this_ptr));
		this_ptr = &this_zv;
	} else this_ptr = NULL;
	
	ZVAL_UNDEF(&_0$$3);
	ZVAL_UNDEF(&_1$$3);

	ZEPHIR_MM_GROW();


	/* try_start_1: */

		ZEPHIR_INIT_VAR(&_0$$3);
		object_init_ex(&_0$$3, zend_exception_get_default(TSRMLS_C));
		ZEPHIR_INIT_VAR(&_1$$3);
		ZVAL_STRING(&_1$$3, "error!");
		ZEPHIR_CALL_METHOD(NULL, &_0$$3, "__construct", NULL, 24, &_1$$3);
		zephir_check_call_status_or_jump(try_end_1);
		zephir_throw_exception_debug(&_0$$3, "test/trytest.zep", 27 TSRMLS_CC);
		goto try_end_1;


	try_end_1:

	zend_clear_exception(TSRMLS_C);

}
예제 #6
0
/**
 * Dispatches a handle action taking into account the routing parameters
 *
 * @return object
 */
PHP_METHOD(Phalcon_Dispatcher, dispatch) {

	zval *handler = NULL, *e = NULL, *_0$$4 = NULL;
	int ZEPHIR_LAST_CALL_STATUS;

	ZEPHIR_MM_GROW();


	/* try_start_1: */

		ZEPHIR_CALL_METHOD(&handler, this_ptr, "_dispatch", NULL, 0);
		zephir_check_call_status_or_jump(try_end_1);

	try_end_1:

	if (EG(exception)) {
		ZEPHIR_CPY_WRT(e, EG(exception));
		if (zephir_instance_of_ev(e, zend_exception_get_default(TSRMLS_C) TSRMLS_CC)) {
			zend_clear_exception(TSRMLS_C);
			ZEPHIR_CALL_METHOD(&_0$$4, this_ptr, "_handleexception", NULL, 0, e);
			zephir_check_call_status();
			if (ZEPHIR_IS_FALSE_IDENTICAL(_0$$4)) {
				RETURN_MM_BOOL(0);
			}
			zephir_throw_exception_debug(e, "phalcon/dispatcher.zep", 348 TSRMLS_CC);
			ZEPHIR_MM_RESTORE();
			return;
		}
	}
	RETURN_CCTOR(handler);

}
예제 #7
0
파일: trytest.zep.c 프로젝트: Mrhjx2/zephir
PHP_METHOD(Test_TryTest, testTry10) {

	zval e;
	int ZEPHIR_LAST_CALL_STATUS;
		zval this_zv;
	zval *this_ptr = getThis();
	if (EXPECTED(this_ptr)) {
		ZVAL_OBJ(&this_zv, Z_OBJ_P(this_ptr));
		this_ptr = &this_zv;
	} else this_ptr = NULL;
	
	ZVAL_UNDEF(&e);

	ZEPHIR_MM_GROW();


	/* try_start_1: */

		ZEPHIR_CALL_METHOD(NULL, this_ptr, "somemethod2", NULL, 77);
		zephir_check_call_status_or_jump(try_end_1);
		RETURN_MM_STRING("not catched");

	try_end_1:

	if (EG(exception)) {
		ZVAL_OBJ(&e, EG(exception));
		Z_ADDREF_P(&e);
		if (zephir_instance_of_ev(&e, spl_ce_RuntimeException TSRMLS_CC)) {
			zend_clear_exception(TSRMLS_C);
			RETURN_MM_STRING("domain error");
		}
	}
	RETURN_MM_BOOL(0);

}
예제 #8
0
PHP_METHOD(Test_Exceptions, testExceptionRethrow) {

	int ZEPHIR_LAST_CALL_STATUS;
	zval *e = NULL;

	ZEPHIR_MM_GROW();


	/* try_start_1: */

		ZEPHIR_CALL_METHOD(NULL, this_ptr, "testexception1", NULL, 0);
		zephir_check_call_status_or_jump(try_end_1);

	try_end_1:

	if (EG(exception)) {
		ZEPHIR_CPY_WRT(e, EG(exception));
		if (zephir_instance_of_ev(e, zend_exception_get_default(TSRMLS_C) TSRMLS_CC)) {
			zend_clear_exception(TSRMLS_C);
			zephir_throw_exception_debug(e, "test/exceptions.zep", 80 TSRMLS_CC);
			ZEPHIR_MM_RESTORE();
			return;
		}
	}
	ZEPHIR_MM_RESTORE();

}
예제 #9
0
PHP_METHOD(Test_TryTest, testTry3) {

	int ZEPHIR_LAST_CALL_STATUS;
	zval *_0, *_1 = NULL;

	ZEPHIR_MM_GROW();


	/* try_start_1: */

		ZEPHIR_INIT_VAR(_0);
		object_init_ex(_0, zend_exception_get_default(TSRMLS_C));
		ZEPHIR_INIT_VAR(_1);
		ZVAL_STRING(_1, "error!", 0);
		ZEPHIR_CALL_METHOD(NULL, _0, "__construct", NULL, _1);
		zephir_check_temp_parameter(_1);
		zephir_check_call_status_or_jump(try_end_1);
		zephir_throw_exception_debug(_0, "test/trytest.zep", 34 TSRMLS_CC);
		goto try_end_1;


	try_end_1:

	if (EG(exception)) {
		ZEPHIR_INIT_NVAR(_1);
		ZEPHIR_CPY_WRT(_1, EG(exception));
		if (zephir_instance_of_ev(_1, zend_exception_get_default(TSRMLS_C) TSRMLS_CC)) {
			zend_clear_exception(TSRMLS_C);
			RETURN_MM_STRING("error", 1);
		}
	}
	RETURN_MM_BOOL(0);

}
예제 #10
0
PHP_METHOD(Test_Exceptions, testExceptionRethrow) {

	zval e;
	int ZEPHIR_LAST_CALL_STATUS;
	ZEPHIR_INIT_THIS();

	ZVAL_UNDEF(&e);

	ZEPHIR_MM_GROW();


	/* try_start_1: */

		ZEPHIR_CALL_METHOD(NULL, this_ptr, "testexception1", NULL, 0);
		zephir_check_call_status_or_jump(try_end_1);

	try_end_1:

	if (EG(exception)) {
		ZVAL_OBJ(&e, EG(exception));
		Z_ADDREF_P(&e);
		if (zephir_instance_of_ev(&e, zend_exception_get_default(TSRMLS_C) TSRMLS_CC)) {
			zend_clear_exception(TSRMLS_C);
			zephir_throw_exception_debug(&e, "test/exceptions.zep", 80 TSRMLS_CC);
			ZEPHIR_MM_RESTORE();
			return;
		}
	}
	ZEPHIR_MM_RESTORE();

}
예제 #11
0
PHP_METHOD(Test_TryTest, testTry10) {

	zephir_nts_static zephir_fcall_cache_entry *_0 = NULL;
	int ZEPHIR_LAST_CALL_STATUS;
	zval *e = NULL;

	ZEPHIR_MM_GROW();


	/* try_start_1: */

		ZEPHIR_CALL_METHOD(NULL, this_ptr, "somemethod2", &_0);
		zephir_check_call_status_or_jump(try_end_1);
		RETURN_MM_STRING("not catched", 1);

	try_end_1:

	if (EG(exception)) {
		ZEPHIR_CPY_WRT(e, EG(exception));
		if (zephir_instance_of_ev(e, spl_ce_RuntimeException TSRMLS_CC)) {
			zend_clear_exception(TSRMLS_C);
			RETURN_MM_STRING("domain error", 1);
		}
	}
	RETURN_MM_BOOL(0);

}
예제 #12
0
PHP_METHOD(Test_TryTest, testTry2) {

	int ZEPHIR_LAST_CALL_STATUS;
	zval *_0, *_1;

	ZEPHIR_MM_GROW();


	/* try_start_1: */

		ZEPHIR_INIT_VAR(_0);
		object_init_ex(_0, zend_exception_get_default(TSRMLS_C));
		ZEPHIR_INIT_VAR(_1);
		ZVAL_STRING(_1, "error!", 0);
		ZEPHIR_CALL_METHOD(NULL, _0, "__construct", NULL, _1);
		zephir_check_temp_parameter(_1);
		zephir_check_call_status_or_jump(try_end_1);
		zephir_throw_exception_debug(_0, "test/trytest.zep", 27 TSRMLS_CC);
		goto try_end_1;


	try_end_1:

	zend_clear_exception(TSRMLS_C);

}
예제 #13
0
파일: pgsql.zep.c 프로젝트: Green-Cat/lynx
PHP_METHOD(Lynx_DBAL_Driver_PgSQL, prepare) {

	int ZEPHIR_LAST_CALL_STATUS;
	zval *statement, *e = NULL, *_0, *_1 = NULL;

	ZEPHIR_MM_GROW();
	zephir_fetch_params(1, 1, 0, &statement);



	ZEPHIR_CALL_METHOD(NULL, this_ptr, "connect", NULL);
	zephir_check_call_status();

	/* try_start_1: */

		_0 = zephir_fetch_nproperty_this(this_ptr, SL("connection"), PH_NOISY_CC);
		ZEPHIR_RETURN_CALL_METHOD(_0, "prepare", NULL, statement);
		zephir_check_call_status_or_jump(try_end_1);
		RETURN_MM();

	try_end_1:

	if (EG(exception)) {
		ZEPHIR_CPY_WRT(e, EG(exception));
		if (zephir_instance_of_ev(e, zend_exception_get_default(TSRMLS_C) TSRMLS_CC)) {
			zend_clear_exception(TSRMLS_C);
			ZEPHIR_CALL_METHOD(&_1, e, "getmessage", NULL);
			zephir_check_call_status();
			zephir_var_dump(&_1 TSRMLS_CC);
			zephir_exit_empty();
			ZEPHIR_MM_RESTORE();
		}
	}

}
예제 #14
0
파일: std.zep.c 프로젝트: VergilTang/yb
PHP_METHOD(Yb_Std, renderScript) {

	int ZEPHIR_LAST_CALL_STATUS;
	zval *data = NULL;
	zval *path_param = NULL, *data_param = NULL, *ex = NULL;
	zval *path = NULL;

	ZEPHIR_MM_GROW();
	zephir_fetch_params(1, 2, 0, &path_param, &data_param);

	zephir_get_strval(path, path_param);
	zephir_get_arrval(data, data_param);


	ZEPHIR_CALL_FUNCTION(NULL, "ob_start", NULL, 23);
	zephir_check_call_status();
	ZEPHIR_CALL_FUNCTION(NULL, "ob_implicit_flush", NULL, 24, ZEPHIR_GLOBAL(global_false));
	zephir_check_call_status();

	/* try_start_1: */

		ZEPHIR_CALL_SELF(NULL, "outputscript", NULL, 0, path, data);
		zephir_check_call_status_or_jump(try_end_1);
		ZEPHIR_RETURN_CALL_FUNCTION("ob_get_clean", NULL, 25);
		zephir_check_call_status_or_jump(try_end_1);
		RETURN_MM();

	try_end_1:

	if (EG(exception)) {
		ZEPHIR_CPY_WRT(ex, EG(exception));
		if (zephir_instance_of_ev(ex, zend_exception_get_default(TSRMLS_C) TSRMLS_CC)) {
			zend_clear_exception(TSRMLS_C);
			ZEPHIR_CALL_FUNCTION(NULL, "ob_end_clean", NULL, 26);
			zephir_check_call_status();
			zephir_throw_exception_debug(ex, "yb/std.zep", 442 TSRMLS_CC);
			ZEPHIR_MM_RESTORE();
			return;
		}
	}
	RETURN_MM_STRING("", 1);

}
예제 #15
0
PHP_METHOD(Yb_Task_TaskManagerAbstract, runTask) {

	int ZEPHIR_LAST_CALL_STATUS;
	zval *task_param = NULL, *re = NULL, *ex = NULL, *_0, *_1$$4, *_2$$4, *_3$$5;
	zval *task = NULL;

	ZEPHIR_MM_GROW();
	zephir_fetch_params(1, 1, 0, &task_param);

	zephir_get_arrval(task, task_param);


	_0 = zephir_fetch_nproperty_this(this_ptr, SL("taskExecutor"), PH_NOISY_CC);
	if (unlikely(!zephir_is_true(_0))) {
		ZEPHIR_THROW_EXCEPTION_DEBUG_STR(yb_task_exception_ce, "Missing task executor", "yb/task/taskmanagerabstract.zep", 76);
		return;
	}

	/* try_start_1: */

		_1$$4 = zephir_fetch_nproperty_this(this_ptr, SL("taskExecutor"), PH_NOISY_CC);
		ZEPHIR_CALL_METHOD(&re, _1$$4, "executetask", NULL, 0, task);
		zephir_check_call_status_or_jump(try_end_1);
		_2$$4 = zephir_fetch_nproperty_this(this_ptr, SL("taskExecutor"), PH_NOISY_CC);
		ZEPHIR_CALL_METHOD(NULL, _2$$4, "ontaskreturn", NULL, 0, task, re);
		zephir_check_call_status_or_jump(try_end_1);

	try_end_1:

	if (EG(exception)) {
		ZEPHIR_CPY_WRT(ex, EG(exception));
		if (zephir_instance_of_ev(ex, zend_exception_get_default(TSRMLS_C) TSRMLS_CC)) {
			zend_clear_exception(TSRMLS_C);
			_3$$5 = zephir_fetch_nproperty_this(this_ptr, SL("taskExecutor"), PH_NOISY_CC);
			ZEPHIR_CALL_METHOD(NULL, _3$$5, "ontaskexception", NULL, 0, task, ex);
			zephir_check_call_status();
		}
	}
	ZEPHIR_MM_RESTORE();

}
예제 #16
0
파일: pgsql.zep.c 프로젝트: Green-Cat/lynx
/**
 * Execute query and return result
 */
PHP_METHOD(Lynx_DBAL_Driver_PgSQL, execute) {

	int ZEPHIR_LAST_CALL_STATUS;
	zval *query_param = NULL, *e = NULL, *_0, *_1 = NULL;
	zval *query = NULL;

	ZEPHIR_MM_GROW();
	zephir_fetch_params(1, 1, 0, &query_param);

	if (unlikely(Z_TYPE_P(query_param) != IS_STRING && Z_TYPE_P(query_param) != IS_NULL)) {
		zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'query' must be a string") TSRMLS_CC);
		RETURN_MM_NULL();
	}

	if (likely(Z_TYPE_P(query_param) == IS_STRING)) {
		zephir_get_strval(query, query_param);
	} else {
		ZEPHIR_INIT_VAR(query);
		ZVAL_EMPTY_STRING(query);
	}


	ZEPHIR_CALL_METHOD(NULL, this_ptr, "connect", NULL);
	zephir_check_call_status();

	/* try_start_1: */

		_0 = zephir_fetch_nproperty_this(this_ptr, SL("connection"), PH_NOISY_CC);
		ZEPHIR_RETURN_CALL_METHOD(_0, "exec", NULL, query);
		zephir_check_call_status_or_jump(try_end_1);
		RETURN_MM();

	try_end_1:

	if (EG(exception)) {
		ZEPHIR_CPY_WRT(e, EG(exception));
		if (zephir_instance_of_ev(e, zend_exception_get_default(TSRMLS_C) TSRMLS_CC)) {
			zend_clear_exception(TSRMLS_C);
			ZEPHIR_CALL_METHOD(&_1, e, "getmessage", NULL);
			zephir_check_call_status();
			zephir_var_dump(&_1 TSRMLS_CC);
			zephir_exit_empty();
			ZEPHIR_MM_RESTORE();
		}
	}

}
예제 #17
0
PHP_METHOD(Fox_MsgCrypt, decrypt) {

	zephir_fcall_cache_entry *_6 = NULL;
	int ZEPHIR_LAST_CALL_STATUS;
	zval *encrypted, *ciphertext_dec = NULL, *module = NULL, *iv = NULL, *decrypted = NULL, *e = NULL, *pkc_encoder = NULL, *result = NULL, *content = NULL, *len_list = NULL, *xml_len = NULL, *xml_content = NULL, *from_appid = NULL, *_18, *_21, *_22, _0$$3 = zval_used_for_init, _1$$3 = zval_used_for_init, _2$$3, _3$$3, *_4$$3, *_5$$3, *_7$$4, *_8$$4, _9$$5, _10$$5, _11$$5, _12$$5, *_13$$5, _14$$5 = zval_used_for_init, _15$$5, *_16$$7, *_17$$7, *_19$$8, *_20$$8;

	ZEPHIR_MM_GROW();
	zephir_fetch_params(1, 1, 0, &encrypted);




	/* try_start_1: */

		ZEPHIR_CALL_FUNCTION(&ciphertext_dec, "base64_decode", NULL, 12, encrypted);
		zephir_check_call_status_or_jump(try_end_1);
		ZEPHIR_SINIT_VAR(_0$$3);
		ZVAL_STRING(&_0$$3, "rijndael-128", 0);
		ZEPHIR_SINIT_VAR(_1$$3);
		ZVAL_STRING(&_1$$3, "", 0);
		ZEPHIR_SINIT_VAR(_2$$3);
		ZVAL_STRING(&_2$$3, "cbc", 0);
		ZEPHIR_SINIT_VAR(_3$$3);
		ZVAL_STRING(&_3$$3, "", 0);
		ZEPHIR_CALL_FUNCTION(&module, "mcrypt_module_open", NULL, 4, &_0$$3, &_1$$3, &_2$$3, &_3$$3);
		zephir_check_call_status_or_jump(try_end_1);
		_4$$3 = zephir_fetch_nproperty_this(this_ptr, SL("appkey"), PH_NOISY_CC);
		ZEPHIR_SINIT_NVAR(_0$$3);
		ZVAL_LONG(&_0$$3, 0);
		ZEPHIR_SINIT_NVAR(_1$$3);
		ZVAL_LONG(&_1$$3, 16);
		ZEPHIR_INIT_VAR(iv);
		zephir_substr(iv, _4$$3, 0 , 16 , 0);
		_5$$3 = zephir_fetch_nproperty_this(this_ptr, SL("appkey"), PH_NOISY_CC);
		ZEPHIR_CALL_FUNCTION(NULL, "mcrypt_generic_init", NULL, 6, module, _5$$3, iv);
		zephir_check_call_status_or_jump(try_end_1);
		ZEPHIR_CALL_FUNCTION(&decrypted, "mdecrypt_generic", NULL, 13, module, ciphertext_dec);
		zephir_check_call_status_or_jump(try_end_1);
		ZEPHIR_CALL_FUNCTION(NULL, "mcrypt_generic_deinit", NULL, 8, module);
		zephir_check_call_status_or_jump(try_end_1);
		ZEPHIR_CALL_FUNCTION(NULL, "mcrypt_module_close", NULL, 9, module);
		zephir_check_call_status_or_jump(try_end_1);

	try_end_1:

	if (EG(exception)) {
		ZEPHIR_CPY_WRT(e, EG(exception));
		if (zephir_instance_of_ev(e, zend_exception_get_default(TSRMLS_C) TSRMLS_CC)) {
			zend_clear_exception(TSRMLS_C);
			ZEPHIR_INIT_VAR(_7$$4);
			ZVAL_BOOL(_7$$4, 0);
			ZEPHIR_INIT_VAR(_8$$4);
			ZVAL_STRING(_8$$4, "DecryptAESError", ZEPHIR_TEMP_PARAM_COPY);
			ZEPHIR_RETURN_CALL_CE_STATIC(fox_common_ce, "rtn", &_6, 10, _7$$4, _8$$4);
			zephir_check_temp_parameter(_8$$4);
			zephir_check_call_status();
			RETURN_MM();
		}
	}

	/* try_start_2: */

		ZEPHIR_INIT_VAR(pkc_encoder);
		object_init_ex(pkc_encoder, fox_pkcs7encoder_ce);
		if (zephir_has_constructor(pkc_encoder TSRMLS_CC)) {
			ZEPHIR_CALL_METHOD(NULL, pkc_encoder, "__construct", NULL, 0);
			zephir_check_call_status_or_jump(try_end_1);
		}
		ZEPHIR_CALL_METHOD(&result, pkc_encoder, "decode", NULL, 14, decrypted);
		zephir_check_call_status_or_jump(try_end_1);
		if (zephir_fast_strlen_ev(result) < 16) {
			RETURN_MM_STRING("", 1);
		}
		ZEPHIR_SINIT_VAR(_9$$5);
		ZVAL_LONG(&_9$$5, 16);
		ZEPHIR_SINIT_VAR(_10$$5);
		ZVAL_LONG(&_10$$5, zephir_fast_strlen_ev(result));
		ZEPHIR_INIT_VAR(content);
		zephir_substr(content, result, 16 , zephir_get_intval(&_10$$5), 0);
		ZEPHIR_SINIT_VAR(_11$$5);
		ZVAL_LONG(&_11$$5, 0);
		ZEPHIR_SINIT_VAR(_12$$5);
		ZVAL_LONG(&_12$$5, 4);
		ZEPHIR_INIT_VAR(_13$$5);
		zephir_substr(_13$$5, content, 0 , 4 , 0);
		ZEPHIR_SINIT_VAR(_14$$5);
		ZVAL_STRING(&_14$$5, "N", 0);
		ZEPHIR_CALL_FUNCTION(&len_list, "unpack", NULL, 15, &_14$$5, _13$$5);
		zephir_check_call_status_or_jump(try_end_1);
		ZEPHIR_OBS_VAR(xml_len);
		zephir_array_fetch_long(&xml_len, len_list, 1, PH_NOISY, "fox/MsgCrypt.zep", 86 TSRMLS_CC);
		ZEPHIR_SINIT_NVAR(_14$$5);
		ZVAL_LONG(&_14$$5, 4);
		ZEPHIR_INIT_VAR(xml_content);
		zephir_substr(xml_content, content, 4 , zephir_get_intval(xml_len), 0);
		ZEPHIR_SINIT_VAR(_15$$5);
		ZVAL_LONG(&_15$$5, (zephir_get_numberval(xml_len) + 4));
		ZEPHIR_INIT_VAR(from_appid);
		zephir_substr(from_appid, content, zephir_get_intval(&_15$$5), 0, ZEPHIR_SUBSTR_NO_LENGTH);

	try_end_2:

	if (EG(exception)) {
		ZEPHIR_CPY_WRT(e, EG(exception));
		if (zephir_instance_of_ev(e, zend_exception_get_default(TSRMLS_C) TSRMLS_CC)) {
			zend_clear_exception(TSRMLS_C);
			ZEPHIR_INIT_VAR(_16$$7);
			ZVAL_BOOL(_16$$7, 0);
			ZEPHIR_INIT_VAR(_17$$7);
			ZVAL_STRING(_17$$7, "IllegalBuffer", ZEPHIR_TEMP_PARAM_COPY);
			ZEPHIR_RETURN_CALL_CE_STATIC(fox_common_ce, "rtn", &_6, 10, _16$$7, _17$$7);
			zephir_check_temp_parameter(_17$$7);
			zephir_check_call_status();
			RETURN_MM();
		}
	}
	_18 = zephir_fetch_nproperty_this(this_ptr, SL("appid"), PH_NOISY_CC);
	if (!ZEPHIR_IS_EQUAL(from_appid, _18)) {
		ZEPHIR_INIT_VAR(_19$$8);
		ZVAL_BOOL(_19$$8, 0);
		ZEPHIR_INIT_VAR(_20$$8);
		ZVAL_STRING(_20$$8, "ValidateAppidError", ZEPHIR_TEMP_PARAM_COPY);
		ZEPHIR_RETURN_CALL_CE_STATIC(fox_common_ce, "rtn", &_6, 10, _19$$8, _20$$8);
		zephir_check_temp_parameter(_20$$8);
		zephir_check_call_status();
		RETURN_MM();
	}
	ZEPHIR_INIT_VAR(_21);
	ZVAL_BOOL(_21, 1);
	ZEPHIR_INIT_VAR(_22);
	ZVAL_STRING(_22, "OK", ZEPHIR_TEMP_PARAM_COPY);
	ZEPHIR_RETURN_CALL_CE_STATIC(fox_common_ce, "rtn", &_6, 10, _21, _22, xml_content);
	zephir_check_temp_parameter(_22);
	zephir_check_call_status();
	RETURN_MM();

}
예제 #18
0
/**
 * Modifies a table column based on a definition
 */
PHP_METHOD(Phalcon_Db_Adapter_Pdo_Postgresql, modifyColumn) {

	HashTable *_2$$4;
	HashPosition _1$$4;
	zephir_fcall_cache_entry *_5 = NULL;
	int ZEPHIR_LAST_CALL_STATUS;
	zval *tableName_param = NULL, *schemaName_param = NULL, *column, *currentColumn = NULL, *sql = NULL, *queries = NULL, *query = NULL, *exception = NULL, *_0, **_3$$4, *_4$$5 = NULL, *_6$$3, *_7$$8 = NULL, *_8$$8, *_9$$8;
	zval *tableName = NULL, *schemaName = NULL;

	ZEPHIR_MM_GROW();
	zephir_fetch_params(1, 3, 1, &tableName_param, &schemaName_param, &column, &currentColumn);

	if (UNEXPECTED(Z_TYPE_P(tableName_param) != IS_STRING && Z_TYPE_P(tableName_param) != IS_NULL)) {
		zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'tableName' must be a string") TSRMLS_CC);
		RETURN_MM_NULL();
	}
	if (EXPECTED(Z_TYPE_P(tableName_param) == IS_STRING)) {
		zephir_get_strval(tableName, tableName_param);
	} else {
		ZEPHIR_INIT_VAR(tableName);
		ZVAL_EMPTY_STRING(tableName);
	}
	if (UNEXPECTED(Z_TYPE_P(schemaName_param) != IS_STRING && Z_TYPE_P(schemaName_param) != IS_NULL)) {
		zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'schemaName' must be a string") TSRMLS_CC);
		RETURN_MM_NULL();
	}
	if (EXPECTED(Z_TYPE_P(schemaName_param) == IS_STRING)) {
		zephir_get_strval(schemaName, schemaName_param);
	} else {
		ZEPHIR_INIT_VAR(schemaName);
		ZVAL_EMPTY_STRING(schemaName);
	}
	if (!currentColumn) {
		currentColumn = ZEPHIR_GLOBAL(global_null);
	}


	_0 = zephir_fetch_nproperty_this(this_ptr, SL("_dialect"), PH_NOISY_CC);
	ZEPHIR_CALL_METHOD(&sql, _0, "modifycolumn", NULL, 0, tableName, schemaName, column, currentColumn);
	zephir_check_call_status();
	ZEPHIR_INIT_VAR(queries);
	zephir_fast_explode_str(queries, SL(";"), sql, LONG_MAX TSRMLS_CC);
	if (zephir_fast_count_int(queries TSRMLS_CC) > 1) {

		/* try_start_1: */

			ZEPHIR_CALL_METHOD(NULL, this_ptr, "begin", NULL, 0);
			zephir_check_call_status_or_jump(try_end_1);
			zephir_is_iterable(queries, &_2$$4, &_1$$4, 0, 0, "phalcon/db/adapter/pdo/postgresql.zep", 344);
			for (
			  ; zend_hash_get_current_data_ex(_2$$4, (void**) &_3$$4, &_1$$4) == SUCCESS
			  ; zend_hash_move_forward_ex(_2$$4, &_1$$4)
			) {
				ZEPHIR_GET_HVALUE(query, _3$$4);
				if (ZEPHIR_IS_EMPTY(query)) {
					continue;
				}
				ZEPHIR_INIT_LNVAR(_4$$5);
				ZEPHIR_CONCAT_VS(_4$$5, query, ";");
				ZEPHIR_CALL_METHOD(NULL, this_ptr, "query", &_5, 0, _4$$5);
				zephir_check_call_status_or_jump(try_end_1);
			}
			ZEPHIR_RETURN_CALL_METHOD(this_ptr, "commit", NULL, 0);
			zephir_check_call_status_or_jump(try_end_1);
			RETURN_MM();

		try_end_1:

		if (EG(exception)) {
			ZEPHIR_INIT_VAR(_6$$3);
			ZEPHIR_CPY_WRT(_6$$3, EG(exception));
			if (zephir_instance_of_ev(_6$$3, zend_exception_get_default(TSRMLS_C) TSRMLS_CC)) {
				zend_clear_exception(TSRMLS_C);
				ZEPHIR_CPY_WRT(exception, _6$$3);
				ZEPHIR_CALL_METHOD(NULL, this_ptr, "rollback", NULL, 0);
				zephir_check_call_status();
				zephir_throw_exception_debug(exception, "phalcon/db/adapter/pdo/postgresql.zep", 349 TSRMLS_CC);
				ZEPHIR_MM_RESTORE();
				return;
			}
		}
	} else {
		ZEPHIR_INIT_VAR(_7$$8);
		if (!(ZEPHIR_IS_EMPTY(sql))) {
			zephir_array_fetch_long(&_8$$8, queries, 0, PH_NOISY | PH_READONLY, "phalcon/db/adapter/pdo/postgresql.zep", 353 TSRMLS_CC);
			ZEPHIR_INIT_VAR(_9$$8);
			ZEPHIR_CONCAT_VS(_9$$8, _8$$8, ";");
			ZEPHIR_CALL_METHOD(&_7$$8, this_ptr, "execute", NULL, 0, _9$$8);
			zephir_check_call_status();
		} else {
			ZVAL_BOOL(_7$$8, 1);
		}
		RETURN_CCTOR(_7$$8);
	}
	RETURN_MM_BOOL(1);

}
예제 #19
0
PHP_METHOD(Fox_MsgCrypt, encrypt) {

	zephir_fcall_cache_entry *_10 = NULL;
	int ZEPHIR_LAST_CALL_STATUS;
	zval *text = NULL, *random = NULL, *module = NULL, *size = NULL, *iv = NULL, *pkc_encoder = NULL, *encrypted = NULL, *e = NULL, _0$$3 = zval_used_for_init, _1$$3 = zval_used_for_init, *_2$$3 = NULL, *_3$$3, *_4$$3, _5$$3, _6$$3, *_7$$3, *_8$$3 = NULL, *_9$$3, *_11$$3, *_12$$3, *_13$$4, *_14$$4;

	ZEPHIR_MM_GROW();
	zephir_fetch_params(1, 1, 0, &text);

	ZEPHIR_SEPARATE_PARAM(text);



	/* try_start_1: */

		ZEPHIR_CALL_METHOD(&random, this_ptr, "_getrandomstr", NULL, 1);
		zephir_check_call_status_or_jump(try_end_1);
		ZEPHIR_SINIT_VAR(_0$$3);
		ZVAL_STRING(&_0$$3, "N", 0);
		ZEPHIR_SINIT_VAR(_1$$3);
		ZVAL_LONG(&_1$$3, zephir_fast_strlen_ev(text));
		ZEPHIR_CALL_FUNCTION(&_2$$3, "pack", NULL, 2, &_0$$3, &_1$$3);
		zephir_check_call_status_or_jump(try_end_1);
		_3$$3 = zephir_fetch_nproperty_this(this_ptr, SL("appid"), PH_NOISY_CC);
		ZEPHIR_INIT_VAR(_4$$3);
		ZEPHIR_CONCAT_VVVV(_4$$3, random, _2$$3, text, _3$$3);
		ZEPHIR_CPY_WRT(text, _4$$3);
		ZEPHIR_SINIT_NVAR(_0$$3);
		ZVAL_STRING(&_0$$3, "rijndael-128", 0);
		ZEPHIR_SINIT_NVAR(_1$$3);
		ZVAL_STRING(&_1$$3, "cbc", 0);
		ZEPHIR_CALL_FUNCTION(&size, "mcrypt_get_block_size", NULL, 3, &_0$$3, &_1$$3);
		zephir_check_call_status_or_jump(try_end_1);
		ZEPHIR_SINIT_NVAR(_0$$3);
		ZVAL_STRING(&_0$$3, "rijndael-128", 0);
		ZEPHIR_SINIT_NVAR(_1$$3);
		ZVAL_STRING(&_1$$3, "", 0);
		ZEPHIR_SINIT_VAR(_5$$3);
		ZVAL_STRING(&_5$$3, "cbc", 0);
		ZEPHIR_SINIT_VAR(_6$$3);
		ZVAL_STRING(&_6$$3, "", 0);
		ZEPHIR_CALL_FUNCTION(&module, "mcrypt_module_open", NULL, 4, &_0$$3, &_1$$3, &_5$$3, &_6$$3);
		zephir_check_call_status_or_jump(try_end_1);
		_7$$3 = zephir_fetch_nproperty_this(this_ptr, SL("appkey"), PH_NOISY_CC);
		ZEPHIR_SINIT_NVAR(_0$$3);
		ZVAL_LONG(&_0$$3, 0);
		ZEPHIR_SINIT_NVAR(_1$$3);
		ZVAL_LONG(&_1$$3, 16);
		ZEPHIR_INIT_VAR(iv);
		zephir_substr(iv, _7$$3, 0 , 16 , 0);
		ZEPHIR_INIT_VAR(pkc_encoder);
		object_init_ex(pkc_encoder, fox_pkcs7encoder_ce);
		if (zephir_has_constructor(pkc_encoder TSRMLS_CC)) {
			ZEPHIR_CALL_METHOD(NULL, pkc_encoder, "__construct", NULL, 0);
			zephir_check_call_status_or_jump(try_end_1);
		}
		ZEPHIR_CALL_METHOD(&_8$$3, pkc_encoder, "encode", NULL, 5, text);
		zephir_check_call_status_or_jump(try_end_1);
		ZEPHIR_CPY_WRT(text, _8$$3);
		_9$$3 = zephir_fetch_nproperty_this(this_ptr, SL("appkey"), PH_NOISY_CC);
		ZEPHIR_CALL_FUNCTION(NULL, "mcrypt_generic_init", NULL, 6, module, _9$$3, iv);
		zephir_check_call_status_or_jump(try_end_1);
		ZEPHIR_CALL_FUNCTION(&encrypted, "mcrypt_generic", NULL, 7, module, text);
		zephir_check_call_status_or_jump(try_end_1);
		ZEPHIR_CALL_FUNCTION(NULL, "mcrypt_generic_deinit", NULL, 8, module);
		zephir_check_call_status_or_jump(try_end_1);
		ZEPHIR_CALL_FUNCTION(NULL, "mcrypt_module_close", NULL, 9, module);
		zephir_check_call_status_or_jump(try_end_1);
		ZEPHIR_CALL_FUNCTION(&_8$$3, "base64_encode", NULL, 11, encrypted);
		zephir_check_call_status_or_jump(try_end_1);
		ZEPHIR_INIT_VAR(_11$$3);
		ZVAL_BOOL(_11$$3, 1);
		ZEPHIR_INIT_VAR(_12$$3);
		ZVAL_STRING(_12$$3, "OK", ZEPHIR_TEMP_PARAM_COPY);
		ZEPHIR_RETURN_CALL_CE_STATIC(fox_common_ce, "rtn", &_10, 10, _11$$3, _12$$3, _8$$3);
		zephir_check_temp_parameter(_12$$3);
		zephir_check_call_status_or_jump(try_end_1);
		RETURN_MM();

	try_end_1:

	if (EG(exception)) {
		ZEPHIR_CPY_WRT(e, EG(exception));
		if (zephir_instance_of_ev(e, zend_exception_get_default(TSRMLS_C) TSRMLS_CC)) {
			zend_clear_exception(TSRMLS_C);
			ZEPHIR_INIT_VAR(_13$$4);
			ZVAL_BOOL(_13$$4, 0);
			ZEPHIR_INIT_VAR(_14$$4);
			ZVAL_STRING(_14$$4, "EncryptAESError", ZEPHIR_TEMP_PARAM_COPY);
			ZEPHIR_RETURN_CALL_CE_STATIC(fox_common_ce, "rtn", &_10, 10, _13$$4, _14$$4);
			zephir_check_temp_parameter(_14$$4);
			zephir_check_call_status();
			RETURN_MM();
		}
	}
	ZEPHIR_MM_RESTORE();

}
예제 #20
0
PHP_METHOD(PhalconPlus_RPC_Server_AbstractServer, callByParams) {

	zend_class_entry *_10, *_17;
	zephir_nts_static zephir_fcall_cache_entry *_5 = NULL, *_7 = NULL, *_13 = NULL;
	int ZEPHIR_LAST_CALL_STATUS;
	zval *_3 = NULL, *_18, *_19;
	zend_bool _2;
	zval *service_param = NULL, *method_param = NULL, *request = NULL, *rawData, *serviceClass = NULL, *_0 = NULL, *_1, *tmp = NULL, *param, *paramClass = NULL, *_4 = NULL, *_6 = NULL, *_8 = NULL, *_9 = NULL, *_11 = NULL, *_12 = NULL, *_14, *_15, *serviceObj, *response = NULL, *e = NULL, *_16 = NULL, *_20;
	zval *service = NULL, *method = NULL, *_21;

	ZEPHIR_MM_GROW();
	zephir_fetch_params(1, 4, 0, &service_param, &method_param, &request, &rawData);

	if (unlikely(Z_TYPE_P(service_param) != IS_STRING && Z_TYPE_P(service_param) != IS_NULL)) {
		zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'service' must be a string") TSRMLS_CC);
		RETURN_MM_NULL();
	}

	if (likely(Z_TYPE_P(service_param) == IS_STRING)) {
		zephir_get_strval(service, service_param);
	} else {
		ZEPHIR_INIT_VAR(service);
		ZVAL_EMPTY_STRING(service);
	}
	if (unlikely(Z_TYPE_P(method_param) != IS_STRING && Z_TYPE_P(method_param) != IS_NULL)) {
		zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'method' must be a string") TSRMLS_CC);
		RETURN_MM_NULL();
	}

	if (likely(Z_TYPE_P(method_param) == IS_STRING)) {
		zephir_get_strval(method, method_param);
	} else {
		ZEPHIR_INIT_VAR(method);
		ZVAL_EMPTY_STRING(method);
	}
	ZEPHIR_INIT_VAR(serviceClass);
	ZVAL_STRING(serviceClass, "", 1);
	ZEPHIR_INIT_VAR(tmp);
	array_init(tmp);


	ZEPHIR_INIT_VAR(_1);
	zephir_ucfirst(_1, service);
	ZEPHIR_INIT_NVAR(serviceClass);
	ZEPHIR_CONCAT_VS(serviceClass, _1, "Service");
	_2 = Z_TYPE_P(request) == IS_OBJECT;
	if (_2) {
		_2 = zephir_instance_of_ev(request, phalconplus_base_protobuffer_ce TSRMLS_CC);
	}
	if (_2) {
		zephir_update_property_this(this_ptr, SL("phpOnly"), (1) ? ZEPHIR_GLOBAL(global_true) : ZEPHIR_GLOBAL(global_false) TSRMLS_CC);
	} else if (Z_TYPE_P(request) == IS_ARRAY) {
		ZEPHIR_CPY_WRT(tmp, request);
		ZEPHIR_INIT_VAR(param);
		object_init_ex(param, zephir_get_internal_ce(SS("reflectionparameter") TSRMLS_CC));
		ZEPHIR_INIT_VAR(_3);
		zephir_create_array(_3, 2, 0 TSRMLS_CC);
		zephir_array_fast_append(_3, serviceClass);
		zephir_array_fast_append(_3, method);
		ZEPHIR_INIT_VAR(_4);
		ZVAL_LONG(_4, 0);
		ZEPHIR_CALL_METHOD(NULL, param, "__construct", &_5, _3, _4);
		zephir_check_call_status();
		ZEPHIR_CALL_METHOD(&_6, param, "getclass", &_7);
		zephir_check_call_status();
		if (zephir_is_true(_6)) {
			ZEPHIR_CALL_METHOD(&_8, param, "getclass", &_7);
			zephir_check_call_status();
			ZEPHIR_CALL_METHOD(&paramClass, _8, "getname", NULL);
			zephir_check_call_status();
			ZEPHIR_INIT_NVAR(request);
			zephir_fetch_safe_class(_9, paramClass);
			_10 = zend_fetch_class(Z_STRVAL_P(_9), Z_STRLEN_P(_9), ZEND_FETCH_CLASS_AUTO TSRMLS_CC);
			object_init_ex(request, _10);
			if (zephir_has_constructor(request TSRMLS_CC)) {
				ZEPHIR_CALL_METHOD(NULL, request, "__construct", NULL);
				zephir_check_call_status();
			}
			ZEPHIR_CALL_METHOD(NULL, request, "softclone", NULL, tmp);
			zephir_check_call_status();
		} else {
			ZEPHIR_INIT_NVAR(_4);
			object_init_ex(_4, zend_exception_get_default(TSRMLS_C));
			ZEPHIR_INIT_VAR(_11);
			zephir_json_encode(_11, &(_11), request, 0  TSRMLS_CC);
			ZEPHIR_INIT_VAR(_12);
			ZEPHIR_CONCAT_SVSVSV(_12, "Service class:method definition is invalid. Detail: ", service, " : ", method, ". Request: ", _11);
			ZEPHIR_CALL_METHOD(NULL, _4, "__construct", &_13, _12);
			zephir_check_call_status();
			zephir_throw_exception_debug(_4, "phalconplus/RPC/Server/AbstractServer.zep", 36 TSRMLS_CC);
			ZEPHIR_MM_RESTORE();
			return;
		}
	} else {
		ZEPHIR_INIT_NVAR(_4);
		object_init_ex(_4, zend_exception_get_default(TSRMLS_C));
		ZEPHIR_INIT_NVAR(_11);
		zephir_json_encode(_11, &(_11), request, 0  TSRMLS_CC);
		ZEPHIR_INIT_LNVAR(_12);
		ZEPHIR_CONCAT_SV(_12, "Your input is not allowed. Request: ", _11);
		ZEPHIR_CALL_METHOD(NULL, _4, "__construct", &_13, _12);
		zephir_check_call_status();
		zephir_throw_exception_debug(_4, "phalconplus/RPC/Server/AbstractServer.zep", 39 TSRMLS_CC);
		ZEPHIR_MM_RESTORE();
		return;
	}
	_14 = zephir_fetch_nproperty_this(this_ptr, SL("di"), PH_NOISY_CC);
	ZEPHIR_INIT_NVAR(_4);
	ZVAL_STRING(_4, "requestCheck", ZEPHIR_TEMP_PARAM_COPY);
	ZEPHIR_CALL_METHOD(&_6, _14, "has", NULL, _4);
	zephir_check_temp_parameter(_4);
	zephir_check_call_status();
	if (zephir_is_true(_6)) {
		_15 = zephir_fetch_nproperty_this(this_ptr, SL("di"), PH_NOISY_CC);
		ZEPHIR_INIT_NVAR(_3);
		zephir_create_array(_3, 3, 0 TSRMLS_CC);
		zephir_array_fast_append(_3, serviceClass);
		zephir_array_fast_append(_3, method);
		zephir_array_fast_append(_3, rawData);
		ZEPHIR_INIT_NVAR(_4);
		ZVAL_STRING(_4, "requestCheck", ZEPHIR_TEMP_PARAM_COPY);
		ZEPHIR_CALL_METHOD(NULL, _15, "get", NULL, _4, _3);
		zephir_check_temp_parameter(_4);
		zephir_check_call_status();
	} else {
		ZEPHIR_CALL_METHOD(NULL, this_ptr, "requestcheck", NULL, serviceClass, method, request);
		zephir_check_call_status();
	}
	ZEPHIR_INIT_VAR(serviceObj);
	zephir_fetch_safe_class(_16, serviceClass);
	_17 = zend_fetch_class(Z_STRVAL_P(_16), Z_STRLEN_P(_16), ZEND_FETCH_CLASS_AUTO TSRMLS_CC);
	object_init_ex(serviceObj, _17);
	if (zephir_has_constructor(serviceObj TSRMLS_CC)) {
		_15 = zephir_fetch_nproperty_this(this_ptr, SL("di"), PH_NOISY_CC);
		ZEPHIR_CALL_METHOD(NULL, serviceObj, "__construct", NULL, _15);
		zephir_check_call_status();
	}
	ZEPHIR_INIT_NVAR(_3);
	zephir_create_array(_3, 2, 0 TSRMLS_CC);
	zephir_array_fast_append(_3, serviceObj);
	zephir_array_fast_append(_3, method);
	if (zephir_is_callable(_3 TSRMLS_CC)) {

		/* try_start_1: */

			ZEPHIR_INIT_NVAR(_4);
			ZEPHIR_INIT_VAR(_18);
			zephir_create_array(_18, 2, 0 TSRMLS_CC);
			zephir_array_fast_append(_18, serviceObj);
			zephir_array_fast_append(_18, method);
			ZEPHIR_INIT_VAR(_19);
			zephir_create_array(_19, 1, 0 TSRMLS_CC);
			zephir_array_fast_append(_19, request);
			ZEPHIR_CALL_USER_FUNC_ARRAY(_4, _18, _19);
			zephir_check_call_status_or_jump(try_end_1);
			ZEPHIR_CPY_WRT(response, _4);

		try_end_1:

		if (EG(exception)) {
			ZEPHIR_CPY_WRT(e, EG(exception));
			if (zephir_instance_of_ev(e, zend_exception_get_default(TSRMLS_C) TSRMLS_CC)) {
				zend_clear_exception(TSRMLS_C);
				zephir_throw_exception_debug(e, "phalconplus/RPC/Server/AbstractServer.zep", 55 TSRMLS_CC);
				ZEPHIR_MM_RESTORE();
				return;
			}
		}
		ZEPHIR_INIT_NVAR(_4);
		_20 = zephir_fetch_nproperty_this(this_ptr, SL("phpOnly"), PH_NOISY_CC);
		if (ZEPHIR_IS_TRUE(_20)) {
			ZEPHIR_CPY_WRT(_4, response);
		} else {
			ZEPHIR_CALL_METHOD(&_4, response, "toarray", NULL);
			zephir_check_call_status();
		}
		RETURN_CCTOR(_4);
	} else {
		object_init_ex(_4, zend_exception_get_default(TSRMLS_C));
		ZEPHIR_INIT_VAR(_21);
		ZEPHIR_CONCAT_SVSV(_21, "Service:method not found. Detail: ", service, " : ", method);
		ZEPHIR_CALL_METHOD(NULL, _4, "__construct", &_13, _21);
		zephir_check_call_status();
		zephir_throw_exception_debug(_4, "phalconplus/RPC/Server/AbstractServer.zep", 59 TSRMLS_CC);
		ZEPHIR_MM_RESTORE();
		return;
	}

}
예제 #21
0
/**
 * @todo cas argument is inconsistent here
 *
 * @param \Ouchbase\Entity entity
 * @param string|null cas
 * @throws \Ouchbase\Exception\EntityLogicException
 * @throws \Ouchbase\Exception\EntityModifiedException
 * @return this
 */
PHP_METHOD(Ouchbase_Repository, update) {

	zend_class_entry *_8;
	zval *_5 = NULL;
	int ZEPHIR_LAST_CALL_STATUS;
	zval *entity = NULL, *cas = NULL, *_0 = NULL, *data = NULL, *originalData = NULL, *_1, *_2 = NULL, *_3 = NULL, *_4, *_6 = NULL, *e = NULL, *_7 = NULL, *ex;

	ZEPHIR_MM_GROW();
	zephir_fetch_params(1, 1, 1, &entity, &cas);

	ZEPHIR_SEPARATE_PARAM(entity);
	if (!cas) {
		cas = ZEPHIR_GLOBAL(global_null);
	}


	if (!(zephir_instance_of_ev(entity, ouchbase_entity_ce TSRMLS_CC))) {
		ZEPHIR_THROW_EXCEPTION_DEBUG_STR(spl_ce_InvalidArgumentException, "Parameter 'entity' must be an instance of 'Ouchbase\\Entity'", "", 0);
		return;
	}
	if (zephir_instance_of_ev(entity, ouchbase_entityproxy_ce TSRMLS_CC)) {
		ZEPHIR_CALL_METHOD(&_0, entity, "isproxied",  NULL);
		zephir_check_call_status();
		if (!(zephir_is_true(_0))) {
			RETURN_THIS();
		}
		ZEPHIR_CALL_METHOD(&entity, entity, "_getobject",  NULL);
		zephir_check_call_status();
	}
	ZEPHIR_CALL_METHOD(&data, this_ptr, "toarray", NULL, entity);
	zephir_check_call_status();
	_1 = zephir_fetch_nproperty_this(this_ptr, SL("im"), PH_NOISY_CC);
	ZEPHIR_CALL_METHOD(&originalData, _1, "getoriginaldata", NULL, entity);
	zephir_check_call_status();
	if (!(zephir_is_true(originalData))) {
		ZEPHIR_INIT_VAR(_2);
		object_init_ex(_2, ouchbase_exception_entitylogicexception_ce);
		ZEPHIR_INIT_VAR(_3);
		ZVAL_STRING(_3, "was not registered in the identity map", 0);
		ZEPHIR_CALL_METHOD(NULL, _2, "__construct", NULL, entity, _3);
		zephir_check_temp_parameter(_3);
		zephir_check_call_status();
		zephir_throw_exception_debug(_2, "ouchbase/Repository.zep", 215 TSRMLS_CC);
		ZEPHIR_MM_RESTORE();
		return;
	}
	if (ZEPHIR_IS_EQUAL(data, originalData)) {
		RETURN_THIS();
	}
	_4 = zephir_fetch_nproperty_this(this_ptr, SL("im"), PH_NOISY_CC);
	ZEPHIR_CALL_METHOD(NULL, _4, "updateoriginaldata", NULL, entity, data);
	zephir_check_call_status();
	if (!(zephir_is_true(cas))) {
		ZEPHIR_INIT_VAR(_5);
		array_init_size(_5, 3);
		ZEPHIR_CALL_METHOD(&_6, entity, "getid",  NULL);
		zephir_check_call_status();
		ZEPHIR_CALL_METHOD(&_0, this_ptr, "getkey", NULL, _6);
		zephir_check_call_status();
		zephir_array_fast_append(_5, _0);
		ZEPHIR_INIT_NVAR(_3);
		zephir_json_encode(_3, &(_3), data, 0  TSRMLS_CC);
		zephir_array_fast_append(_5, _3);
		ZEPHIR_INIT_NVAR(_3);
		ZVAL_STRING(_3, "replace", 0);
		ZEPHIR_CALL_METHOD(NULL, this_ptr, "executewithouttimeouts", NULL, _3, _5);
		zephir_check_temp_parameter(_3);
		zephir_check_call_status();
		RETURN_THIS();
	}

	/* try_start_1: */

		ZEPHIR_INIT_NVAR(_5);
		array_init_size(_5, 6);
		ZEPHIR_CALL_METHOD(&_7, entity, "getid",  NULL);
		zephir_check_call_status_or_jump(try_end_1);
		ZEPHIR_CALL_METHOD(&_6, this_ptr, "getkey", NULL, _7);
		zephir_check_call_status_or_jump(try_end_1);
		zephir_array_fast_append(_5, _6);
		ZEPHIR_INIT_NVAR(_3);
		zephir_json_encode(_3, &(_3), data, 0  TSRMLS_CC);
		zephir_array_fast_append(_5, _3);
		ZEPHIR_INIT_NVAR(_3);
		ZVAL_LONG(_3, 0);
		zephir_array_fast_append(_5, _3);
		zephir_array_fast_append(_5, cas);
		ZEPHIR_INIT_NVAR(_3);
		ZVAL_STRING(_3, "replace", 0);
		ZEPHIR_CALL_METHOD(&_0, this_ptr, "executewithouttimeouts", NULL, _3, _5);
		zephir_check_temp_parameter(_3);
		zephir_check_call_status_or_jump(try_end_1);
		if (!(zephir_is_true(_0))) {
			ZEPHIR_INIT_LNVAR(_2);
			_8 = zend_fetch_class(SL("CouchbaseKeyMutatedException"), ZEND_FETCH_CLASS_AUTO TSRMLS_CC);
			object_init_ex(_2, _8);
			ZEPHIR_CALL_METHOD(NULL, _2, "__construct", NULL);
			zephir_check_call_status_or_jump(try_end_1);
			zephir_throw_exception_debug(_2, "ouchbase/Repository.zep", 233 TSRMLS_CC);
			goto try_end_1;

		}
		RETURN_THIS();

	try_end_1:

	ZEPHIR_CPY_WRT(e, EG(exception));
	if (zephir_is_instance_of(e, SL("CouchbaseKeyMutatedException") TSRMLS_CC)) {
		zend_clear_exception(TSRMLS_C);
		ZEPHIR_INIT_VAR(ex);
		object_init_ex(ex, ouchbase_exception_entitymodifiedexception_ce);
		ZEPHIR_INIT_NVAR(_3);
		ZVAL_STRING(_3, "was modified", 0);
		ZEPHIR_CALL_METHOD(NULL, ex, "__construct", NULL, entity, _3);
		zephir_check_temp_parameter(_3);
		zephir_check_call_status();
		ZEPHIR_INIT_NVAR(_3);
		ZVAL_STRING(_3, "update", 0);
		ZEPHIR_CALL_METHOD(NULL, ex, "setaction", NULL, _3);
		zephir_check_temp_parameter(_3);
		zephir_check_call_status();
		zephir_throw_exception_debug(ex, "ouchbase/Repository.zep", 242 TSRMLS_CC);
		ZEPHIR_MM_RESTORE();
		return;
	}
	RETURN_THIS();

}
예제 #22
0
/**
 * Dispatches a handle action taking into account the routing parameters
 *
 * @return object
 */
PHP_METHOD(Phalcon_Dispatcher, _dispatch) {

	HashTable *_53$$39;
	HashPosition _52$$39;
	zval *_30$$6 = NULL, *_60$$44 = NULL, *_62$$44 = NULL, *_63$$44 = NULL, *_68$$45 = NULL, *_70$$45 = NULL;
	zval *value = NULL, *handler = NULL, *dependencyInjector = NULL, *namespaceName = NULL, *handlerName = NULL, *actionName = NULL, *params = NULL, *eventsManager = NULL, *actionSuffix = NULL, *handlerClass = NULL, *status = NULL, *actionMethod = NULL, *reflectionMethod = NULL, *methodParams = NULL, *className = NULL, *paramKey = NULL, *methodParam = NULL, *modelName = NULL, *bindModel = NULL, *e = NULL, *_0, *_1$$3, *_2$$3, *_3$$4 = NULL, *_4$$4, *_5$$7 = NULL, *_6$$7 = NULL, *_10$$8 = NULL, *_11$$8 = NULL, *_13$$8, *_14$$6 = NULL, *_49$$6, *_16$$12 = NULL, *_17$$12 = NULL, *_19$$13, *_22$$16 = NULL, *_23$$16 = NULL, *_25$$17, *_26$$19 = NULL, *_27$$19 = NULL, *_29$$20, *_31$$23 = NULL, *_32$$23 = NULL, *_34$$23, *_35$$22 = NULL, *_36$$22 = NULL, *_38$$26, *_39$$28 = NULL, *_40$$28 = NULL, *_42$$28, *_43$$31 = NULL, *_44$$31, *_45$$36 = NULL, *_46$$36 = NULL, *_48$$36, **_54$$39, *_55$$40 = NULL, *_56$$41 = NULL, *_57$$43 = NULL, _59$$43 = zval_used_for_init, *_61$$44 = NULL, *_64$$44 = NULL, _65$$42 = zval_used_for_init, *_66$$42 = NULL, *_69$$45 = NULL, *_71$$45 = NULL, *_72$$46 = NULL, *_74$$47 = NULL, *_76$$48, *_77$$51 = NULL, *_78$$51 = NULL, *_80$$51, *_82$$54 = NULL, *_83$$54, *_84$$57;
	zend_bool hasService = 0, wasFresh;
	zephir_fcall_cache_entry *_7 = NULL, *_8 = NULL, *_9 = NULL, *_12 = NULL, *_15 = NULL, *_18 = NULL, *_20 = NULL, *_21 = NULL, *_24 = NULL, *_28 = NULL, *_33 = NULL, *_37 = NULL, *_41 = NULL, *_47 = NULL, *_50 = NULL, *_51 = NULL, *_58 = NULL, *_67 = NULL, *_73 = NULL, *_75 = NULL, *_79 = NULL, *_81 = NULL;
	int ZEPHIR_LAST_CALL_STATUS, numberDispatches = 0;

	ZEPHIR_MM_GROW();

	wasFresh = 0;
	_0 = zephir_fetch_nproperty_this(this_ptr, SL("_dependencyInjector"), PH_NOISY_CC);
	ZEPHIR_CPY_WRT(dependencyInjector, _0);
	if (Z_TYPE_P(dependencyInjector) != IS_OBJECT) {
		ZEPHIR_INIT_VAR(_1$$3);
		ZVAL_STRING(_1$$3, "A dependency injection container is required to access related dispatching services", ZEPHIR_TEMP_PARAM_COPY);
		ZEPHIR_INIT_VAR(_2$$3);
		ZVAL_LONG(_2$$3, 0);
		ZEPHIR_CALL_METHOD(NULL, this_ptr, "_throwdispatchexception", NULL, 0, _1$$3, _2$$3);
		zephir_check_temp_parameter(_1$$3);
		zephir_check_call_status();
		RETURN_MM_BOOL(0);
	}
	_0 = zephir_fetch_nproperty_this(this_ptr, SL("_eventsManager"), PH_NOISY_CC);
	ZEPHIR_CPY_WRT(eventsManager, _0);
	if (Z_TYPE_P(eventsManager) == IS_OBJECT) {
		ZEPHIR_INIT_VAR(_4$$4);
		ZVAL_STRING(_4$$4, "dispatch:beforeDispatchLoop", ZEPHIR_TEMP_PARAM_COPY);
		ZEPHIR_CALL_METHOD(&_3$$4, eventsManager, "fire", NULL, 0, _4$$4, this_ptr);
		zephir_check_temp_parameter(_4$$4);
		zephir_check_call_status();
		if (ZEPHIR_IS_FALSE_IDENTICAL(_3$$4)) {
			RETURN_MM_BOOL(0);
		}
	}
	ZEPHIR_INIT_VAR(value);
	ZVAL_NULL(value);
	ZEPHIR_INIT_VAR(handler);
	ZVAL_NULL(handler);
	numberDispatches = 0;
	ZEPHIR_OBS_VAR(actionSuffix);
	zephir_read_property_this(&actionSuffix, this_ptr, SL("_actionSuffix"), PH_NOISY_CC);
	if (0) {
		zephir_update_property_this(this_ptr, SL("_finished"), ZEPHIR_GLOBAL(global_true) TSRMLS_CC);
	} else {
		zephir_update_property_this(this_ptr, SL("_finished"), ZEPHIR_GLOBAL(global_false) TSRMLS_CC);
	}
	while (1) {
		_0 = zephir_fetch_nproperty_this(this_ptr, SL("_finished"), PH_NOISY_CC);
		if (!(!(zephir_is_true(_0)))) {
			break;
		}
		numberDispatches++;
		if (numberDispatches == 256) {
			ZEPHIR_INIT_NVAR(_5$$7);
			ZVAL_STRING(_5$$7, "Dispatcher has detected a cyclic routing causing stability problems", ZEPHIR_TEMP_PARAM_COPY);
			ZEPHIR_INIT_NVAR(_6$$7);
			ZVAL_LONG(_6$$7, 1);
			ZEPHIR_CALL_METHOD(NULL, this_ptr, "_throwdispatchexception", &_7, 0, _5$$7, _6$$7);
			zephir_check_temp_parameter(_5$$7);
			zephir_check_call_status();
			break;
		}
		if (1) {
			zephir_update_property_this(this_ptr, SL("_finished"), ZEPHIR_GLOBAL(global_true) TSRMLS_CC);
		} else {
			zephir_update_property_this(this_ptr, SL("_finished"), ZEPHIR_GLOBAL(global_false) TSRMLS_CC);
		}
		ZEPHIR_CALL_METHOD(NULL, this_ptr, "_resolveemptyproperties", &_8, 0);
		zephir_check_call_status();
		ZEPHIR_OBS_NVAR(namespaceName);
		zephir_read_property_this(&namespaceName, this_ptr, SL("_namespaceName"), PH_NOISY_CC);
		ZEPHIR_OBS_NVAR(handlerName);
		zephir_read_property_this(&handlerName, this_ptr, SL("_handlerName"), PH_NOISY_CC);
		ZEPHIR_OBS_NVAR(actionName);
		zephir_read_property_this(&actionName, this_ptr, SL("_actionName"), PH_NOISY_CC);
		ZEPHIR_CALL_METHOD(&handlerClass, this_ptr, "gethandlerclass", &_9, 0);
		zephir_check_call_status();
		if (Z_TYPE_P(eventsManager) == IS_OBJECT) {
			ZEPHIR_INIT_NVAR(_11$$8);
			ZVAL_STRING(_11$$8, "dispatch:beforeDispatch", ZEPHIR_TEMP_PARAM_COPY);
			ZEPHIR_CALL_METHOD(&_10$$8, eventsManager, "fire", &_12, 0, _11$$8, this_ptr);
			zephir_check_temp_parameter(_11$$8);
			zephir_check_call_status();
			if (ZEPHIR_IS_FALSE_IDENTICAL(_10$$8)) {
				continue;
			}
			_13$$8 = zephir_fetch_nproperty_this(this_ptr, SL("_finished"), PH_NOISY_CC);
			if (ZEPHIR_IS_FALSE_IDENTICAL(_13$$8)) {
				continue;
			}
		}
		ZEPHIR_CALL_METHOD(&_14$$6, dependencyInjector, "has", &_15, 0, handlerClass);
		zephir_check_call_status();
		hasService = zephir_get_boolval(_14$$6);
		if (!(hasService)) {
			hasService = zephir_class_exists(handlerClass, 1 TSRMLS_CC);
		}
		if (!(hasService)) {
			ZEPHIR_INIT_LNVAR(_16$$12);
			ZEPHIR_CONCAT_VS(_16$$12, handlerClass, " handler class cannot be loaded");
			ZEPHIR_INIT_NVAR(_17$$12);
			ZVAL_LONG(_17$$12, 2);
			ZEPHIR_CALL_METHOD(&status, this_ptr, "_throwdispatchexception", &_18, 0, _16$$12, _17$$12);
			zephir_check_call_status();
			if (ZEPHIR_IS_FALSE_IDENTICAL(status)) {
				_19$$13 = zephir_fetch_nproperty_this(this_ptr, SL("_finished"), PH_NOISY_CC);
				if (ZEPHIR_IS_FALSE_IDENTICAL(_19$$13)) {
					continue;
				}
			}
			break;
		}
		ZEPHIR_CALL_METHOD(&handler, dependencyInjector, "getshared", &_20, 0, handlerClass);
		zephir_check_call_status();
		ZEPHIR_CALL_METHOD(&_14$$6, dependencyInjector, "wasfreshinstance", &_21, 0);
		zephir_check_call_status();
		if (ZEPHIR_IS_TRUE_IDENTICAL(_14$$6)) {
			wasFresh = 1;
		}
		if (Z_TYPE_P(handler) != IS_OBJECT) {
			ZEPHIR_INIT_NVAR(_22$$16);
			ZVAL_STRING(_22$$16, "Invalid handler returned from the services container", ZEPHIR_TEMP_PARAM_COPY);
			ZEPHIR_INIT_NVAR(_23$$16);
			ZVAL_LONG(_23$$16, 3);
			ZEPHIR_CALL_METHOD(&status, this_ptr, "_throwdispatchexception", &_24, 0, _22$$16, _23$$16);
			zephir_check_temp_parameter(_22$$16);
			zephir_check_call_status();
			if (ZEPHIR_IS_FALSE_IDENTICAL(status)) {
				_25$$17 = zephir_fetch_nproperty_this(this_ptr, SL("_finished"), PH_NOISY_CC);
				if (ZEPHIR_IS_FALSE_IDENTICAL(_25$$17)) {
					continue;
				}
			}
			break;
		}
		zephir_update_property_this(this_ptr, SL("_activeHandler"), handler TSRMLS_CC);
		ZEPHIR_OBS_NVAR(params);
		zephir_read_property_this(&params, this_ptr, SL("_params"), PH_NOISY_CC);
		if (Z_TYPE_P(params) != IS_ARRAY) {
			ZEPHIR_INIT_NVAR(_26$$19);
			ZVAL_STRING(_26$$19, "Action parameters must be an Array", ZEPHIR_TEMP_PARAM_COPY);
			ZEPHIR_INIT_NVAR(_27$$19);
			ZVAL_LONG(_27$$19, 4);
			ZEPHIR_CALL_METHOD(&status, this_ptr, "_throwdispatchexception", &_28, 0, _26$$19, _27$$19);
			zephir_check_temp_parameter(_26$$19);
			zephir_check_call_status();
			if (ZEPHIR_IS_FALSE_IDENTICAL(status)) {
				_29$$20 = zephir_fetch_nproperty_this(this_ptr, SL("_finished"), PH_NOISY_CC);
				if (ZEPHIR_IS_FALSE_IDENTICAL(_29$$20)) {
					continue;
				}
			}
			break;
		}
		ZEPHIR_INIT_NVAR(actionMethod);
		ZEPHIR_CONCAT_VV(actionMethod, actionName, actionSuffix);
		ZEPHIR_INIT_NVAR(_30$$6);
		zephir_create_array(_30$$6, 2, 0 TSRMLS_CC);
		zephir_array_fast_append(_30$$6, handler);
		zephir_array_fast_append(_30$$6, actionMethod);
		if (!(zephir_is_callable(_30$$6 TSRMLS_CC))) {
			if (Z_TYPE_P(eventsManager) == IS_OBJECT) {
				ZEPHIR_INIT_NVAR(_32$$23);
				ZVAL_STRING(_32$$23, "dispatch:beforeNotFoundAction", ZEPHIR_TEMP_PARAM_COPY);
				ZEPHIR_CALL_METHOD(&_31$$23, eventsManager, "fire", &_33, 0, _32$$23, this_ptr);
				zephir_check_temp_parameter(_32$$23);
				zephir_check_call_status();
				if (ZEPHIR_IS_FALSE_IDENTICAL(_31$$23)) {
					continue;
				}
				_34$$23 = zephir_fetch_nproperty_this(this_ptr, SL("_finished"), PH_NOISY_CC);
				if (ZEPHIR_IS_FALSE_IDENTICAL(_34$$23)) {
					continue;
				}
			}
			ZEPHIR_INIT_LNVAR(_35$$22);
			ZEPHIR_CONCAT_SVSVS(_35$$22, "Action '", actionName, "' was not found on handler '", handlerName, "'");
			ZEPHIR_INIT_NVAR(_36$$22);
			ZVAL_LONG(_36$$22, 5);
			ZEPHIR_CALL_METHOD(&status, this_ptr, "_throwdispatchexception", &_37, 0, _35$$22, _36$$22);
			zephir_check_call_status();
			if (ZEPHIR_IS_FALSE_IDENTICAL(status)) {
				_38$$26 = zephir_fetch_nproperty_this(this_ptr, SL("_finished"), PH_NOISY_CC);
				if (ZEPHIR_IS_FALSE_IDENTICAL(_38$$26)) {
					continue;
				}
			}
			break;
		}
		if (Z_TYPE_P(eventsManager) == IS_OBJECT) {
			ZEPHIR_INIT_NVAR(_40$$28);
			ZVAL_STRING(_40$$28, "dispatch:beforeExecuteRoute", ZEPHIR_TEMP_PARAM_COPY);
			ZEPHIR_CALL_METHOD(&_39$$28, eventsManager, "fire", &_41, 0, _40$$28, this_ptr);
			zephir_check_temp_parameter(_40$$28);
			zephir_check_call_status();
			if (ZEPHIR_IS_FALSE_IDENTICAL(_39$$28)) {
				continue;
			}
			_42$$28 = zephir_fetch_nproperty_this(this_ptr, SL("_finished"), PH_NOISY_CC);
			if (ZEPHIR_IS_FALSE_IDENTICAL(_42$$28)) {
				continue;
			}
		}
		if ((zephir_method_exists_ex(handler, SS("beforeexecuteroute") TSRMLS_CC) == SUCCESS)) {
			ZEPHIR_CALL_METHOD(&_43$$31, handler, "beforeexecuteroute", NULL, 0, this_ptr);
			zephir_check_call_status();
			if (ZEPHIR_IS_FALSE_IDENTICAL(_43$$31)) {
				continue;
			}
			_44$$31 = zephir_fetch_nproperty_this(this_ptr, SL("_finished"), PH_NOISY_CC);
			if (ZEPHIR_IS_FALSE_IDENTICAL(_44$$31)) {
				continue;
			}
		}
		if (wasFresh == 1) {
			if ((zephir_method_exists_ex(handler, SS("initialize") TSRMLS_CC) == SUCCESS)) {
				ZEPHIR_CALL_METHOD(NULL, handler, "initialize", NULL, 0);
				zephir_check_call_status();
			}
			if (zephir_is_true(eventsManager)) {
				ZEPHIR_INIT_NVAR(_46$$36);
				ZVAL_STRING(_46$$36, "dispatch:afterInitialize", ZEPHIR_TEMP_PARAM_COPY);
				ZEPHIR_CALL_METHOD(&_45$$36, eventsManager, "fire", &_47, 0, _46$$36, this_ptr);
				zephir_check_temp_parameter(_46$$36);
				zephir_check_call_status();
				if (ZEPHIR_IS_FALSE_IDENTICAL(_45$$36)) {
					continue;
				}
				_48$$36 = zephir_fetch_nproperty_this(this_ptr, SL("_finished"), PH_NOISY_CC);
				if (ZEPHIR_IS_FALSE_IDENTICAL(_48$$36)) {
					continue;
				}
			}
		}
		_49$$6 = zephir_fetch_nproperty_this(this_ptr, SL("_modelBinding"), PH_NOISY_CC);
		if (ZEPHIR_IS_TRUE_IDENTICAL(_49$$6)) {
			ZEPHIR_INIT_NVAR(reflectionMethod);
			object_init_ex(reflectionMethod, zephir_get_internal_ce(SS("reflectionmethod") TSRMLS_CC));
			ZEPHIR_CALL_METHOD(NULL, reflectionMethod, "__construct", &_50, 69, handlerClass, actionMethod);
			zephir_check_call_status();
			ZEPHIR_CALL_METHOD(&methodParams, reflectionMethod, "getparameters", &_51, 70);
			zephir_check_call_status();
			zephir_is_iterable(methodParams, &_53$$39, &_52$$39, 0, 0, "phalcon/dispatcher.zep", 582);
			for (
			  ; zephir_hash_get_current_data_ex(_53$$39, (void**) &_54$$39, &_52$$39) == SUCCESS
			  ; zephir_hash_move_forward_ex(_53$$39, &_52$$39)
			) {
				ZEPHIR_GET_HMKEY(paramKey, _53$$39, _52$$39);
				ZEPHIR_GET_HVALUE(methodParam, _54$$39);
				ZEPHIR_CALL_METHOD(&_55$$40, methodParam, "getclass", NULL, 0);
				zephir_check_call_status();
				if (zephir_is_true(_55$$40)) {
					ZEPHIR_CALL_METHOD(&_56$$41, methodParam, "getclass", NULL, 0);
					zephir_check_call_status();
					ZEPHIR_CALL_METHOD(&className, _56$$41, "getname", NULL, 0);
					zephir_check_call_status();
					if (Z_TYPE_P(className) == IS_STRING) {
						if (ZEPHIR_IS_STRING(className, "Phalcon\\Mvc\\Model")) {
							ZEPHIR_CALL_FUNCTION(&_57$$43, "class_implements", &_58, 71, handlerClass);
							zephir_check_call_status();
							ZEPHIR_SINIT_NVAR(_59$$43);
							ZVAL_STRING(&_59$$43, "Phalcon\\Mvc\\Controller\\BindModelInterface", 0);
							if (zephir_fast_in_array(&_59$$43, _57$$43 TSRMLS_CC)) {
								ZEPHIR_INIT_NVAR(_60$$44);
								zephir_create_array(_60$$44, 2, 0 TSRMLS_CC);
								zephir_array_fast_append(_60$$44, handlerClass);
								ZEPHIR_INIT_NVAR(_61$$44);
								ZVAL_STRING(_61$$44, "getModelName", 1);
								zephir_array_fast_append(_60$$44, _61$$44);
								ZEPHIR_INIT_NVAR(modelName);
								ZEPHIR_CALL_USER_FUNC(modelName, _60$$44);
								zephir_check_call_status();
								ZEPHIR_INIT_NVAR(_62$$44);
								zephir_create_array(_62$$44, 2, 0 TSRMLS_CC);
								zephir_array_fast_append(_62$$44, modelName);
								ZEPHIR_INIT_NVAR(_61$$44);
								ZVAL_STRING(_61$$44, "findFirst", 1);
								zephir_array_fast_append(_62$$44, _61$$44);
								ZEPHIR_INIT_NVAR(_63$$44);
								zephir_create_array(_63$$44, 1, 0 TSRMLS_CC);
								ZEPHIR_OBS_NVAR(_64$$44);
								zephir_array_fetch(&_64$$44, params, paramKey, PH_NOISY, "phalcon/dispatcher.zep", 567 TSRMLS_CC);
								zephir_array_fast_append(_63$$44, _64$$44);
								ZEPHIR_INIT_NVAR(bindModel);
								ZEPHIR_CALL_USER_FUNC_ARRAY(bindModel, _62$$44, _63$$44);
								zephir_check_call_status();
								zephir_array_update_zval(&params, paramKey, &bindModel, PH_COPY | PH_SEPARATE);
								break;
							}
						}
						ZEPHIR_SINIT_NVAR(_65$$42);
						ZVAL_STRING(&_65$$42, "Phalcon\\Mvc\\Model", 0);
						ZEPHIR_CALL_FUNCTION(&_66$$42, "is_subclass_of", &_67, 72, className, &_65$$42);
						zephir_check_call_status();
						if (zephir_is_true(_66$$42)) {
							ZEPHIR_INIT_NVAR(_68$$45);
							zephir_create_array(_68$$45, 2, 0 TSRMLS_CC);
							zephir_array_fast_append(_68$$45, className);
							ZEPHIR_INIT_NVAR(_69$$45);
							ZVAL_STRING(_69$$45, "findFirst", 1);
							zephir_array_fast_append(_68$$45, _69$$45);
							ZEPHIR_INIT_NVAR(_70$$45);
							zephir_create_array(_70$$45, 1, 0 TSRMLS_CC);
							ZEPHIR_OBS_NVAR(_71$$45);
							zephir_array_fetch(&_71$$45, params, paramKey, PH_NOISY, "phalcon/dispatcher.zep", 575 TSRMLS_CC);
							zephir_array_fast_append(_70$$45, _71$$45);
							ZEPHIR_INIT_NVAR(bindModel);
							ZEPHIR_CALL_USER_FUNC_ARRAY(bindModel, _68$$45, _70$$45);
							zephir_check_call_status();
							zephir_array_update_zval(&params, paramKey, &bindModel, PH_COPY | PH_SEPARATE);
							break;
						}
					}
				}
			}
		}
		zephir_update_property_this(this_ptr, SL("_lastHandler"), handler TSRMLS_CC);

		/* try_start_1: */

			ZEPHIR_CALL_METHOD(&_72$$46, this_ptr, "callactionmethod", &_73, 0, handler, actionMethod, params);
			zephir_check_call_status_or_jump(try_end_1);
			zephir_update_property_this(this_ptr, SL("_returnedValue"), _72$$46 TSRMLS_CC);

		try_end_1:

		if (EG(exception)) {
			ZEPHIR_CPY_WRT(e, EG(exception));
			if (zephir_instance_of_ev(e, zend_exception_get_default(TSRMLS_C) TSRMLS_CC)) {
				zend_clear_exception(TSRMLS_C);
				ZEPHIR_CALL_METHOD(&_74$$47, this_ptr, "_handleexception", &_75, 0, e);
				zephir_check_call_status();
				if (ZEPHIR_IS_FALSE_IDENTICAL(_74$$47)) {
					_76$$48 = zephir_fetch_nproperty_this(this_ptr, SL("_finished"), PH_NOISY_CC);
					if (ZEPHIR_IS_FALSE_IDENTICAL(_76$$48)) {
						continue;
					}
				} else {
					zephir_throw_exception_debug(e, "phalcon/dispatcher.zep", 595 TSRMLS_CC);
					ZEPHIR_MM_RESTORE();
					return;
				}
			}
		}
		if (Z_TYPE_P(eventsManager) == IS_OBJECT) {
			ZEPHIR_INIT_NVAR(_78$$51);
			ZVAL_STRING(_78$$51, "dispatch:afterExecuteRoute", ZEPHIR_TEMP_PARAM_COPY);
			ZEPHIR_CALL_METHOD(&_77$$51, eventsManager, "fire", &_79, 0, _78$$51, this_ptr, value);
			zephir_check_temp_parameter(_78$$51);
			zephir_check_call_status();
			if (ZEPHIR_IS_FALSE_IDENTICAL(_77$$51)) {
				continue;
			}
			_80$$51 = zephir_fetch_nproperty_this(this_ptr, SL("_finished"), PH_NOISY_CC);
			if (ZEPHIR_IS_FALSE_IDENTICAL(_80$$51)) {
				continue;
			}
			ZEPHIR_INIT_NVAR(_78$$51);
			ZVAL_STRING(_78$$51, "dispatch:afterDispatch", ZEPHIR_TEMP_PARAM_COPY);
			ZEPHIR_CALL_METHOD(NULL, eventsManager, "fire", &_81, 0, _78$$51, this_ptr);
			zephir_check_temp_parameter(_78$$51);
			zephir_check_call_status();
		}
		if ((zephir_method_exists_ex(handler, SS("afterexecuteroute") TSRMLS_CC) == SUCCESS)) {
			ZEPHIR_CALL_METHOD(&_82$$54, handler, "afterexecuteroute", NULL, 0, this_ptr, value);
			zephir_check_call_status();
			if (ZEPHIR_IS_FALSE_IDENTICAL(_82$$54)) {
				continue;
			}
			_83$$54 = zephir_fetch_nproperty_this(this_ptr, SL("_finished"), PH_NOISY_CC);
			if (ZEPHIR_IS_FALSE_IDENTICAL(_83$$54)) {
				continue;
			}
		}
	}
	if (Z_TYPE_P(eventsManager) == IS_OBJECT) {
		ZEPHIR_INIT_VAR(_84$$57);
		ZVAL_STRING(_84$$57, "dispatch:afterDispatchLoop", ZEPHIR_TEMP_PARAM_COPY);
		ZEPHIR_CALL_METHOD(NULL, eventsManager, "fire", NULL, 0, _84$$57, this_ptr);
		zephir_check_temp_parameter(_84$$57);
		zephir_check_call_status();
	}
	RETURN_CCTOR(handler);

}
예제 #23
0
PHP_METHOD(PhalconPlus_Db_Mysql, getConnection) {

	zephir_nts_static zephir_fcall_cache_entry *_4 = NULL, *_7 = NULL;
	zephir_fcall_cache_entry *_1 = NULL;
	int ZEPHIR_LAST_CALL_STATUS, _5;
	zval *connection = NULL, *tryTimes = NULL, *e = NULL, *_0, *_2 = NULL, *_3 = NULL, _6 = zval_used_for_init;

	ZEPHIR_MM_GROW();
	ZEPHIR_INIT_VAR(connection);
	ZVAL_NULL(connection);

	ZEPHIR_INIT_VAR(tryTimes);
	ZVAL_LONG(tryTimes, 5);
	while (1) {
		if (!(!(Z_TYPE_P(connection) == IS_OBJECT))) {
			break;
		}

		/* try_start_1: */

			ZEPHIR_INIT_NVAR(connection);
			object_init_ex(connection, zephir_get_internal_ce(SS("phalcon\\db\\adapter\\pdo\\mysql") TSRMLS_CC));
			_0 = zephir_fetch_nproperty_this(this_ptr, SL("descriptor"), PH_NOISY_CC);
			ZEPHIR_CALL_METHOD(NULL, connection, "__construct", &_1, _0);
			zephir_check_call_status_or_jump(try_end_1);

		try_end_1:

		if (EG(exception)) {
			ZEPHIR_CPY_WRT(e, EG(exception));
			if (zephir_is_instance_of(e, SL("PhalconPlus\\Db\\Exception") TSRMLS_CC)) {
				zend_clear_exception(TSRMLS_C);
				ZEPHIR_INIT_NVAR(_2);
				_0 = zephir_fetch_nproperty_this(this_ptr, SL("descriptor"), PH_NOISY_CC);
				zephir_json_encode(_2, &(_2), _0, 0  TSRMLS_CC);
				ZEPHIR_INIT_LNVAR(_3);
				ZEPHIR_CONCAT_SV(_3, "PHP Fatal error:  PhalconPlus::Db::MySQL::connect() failed to connect to MySQL. Detail: ", _2);
				ZEPHIR_CALL_FUNCTION(NULL, "error_log", &_4, _3);
				zephir_check_call_status();
				_5 = (zephir_get_numberval(tryTimes) - 1);
				ZEPHIR_INIT_NVAR(tryTimes);
				ZVAL_LONG(tryTimes, _5);
				if (ZEPHIR_GT_LONG(tryTimes, 0)) {
					ZEPHIR_SINIT_NVAR(_6);
					ZVAL_LONG(&_6, 100000);
					ZEPHIR_CALL_FUNCTION(NULL, "usleep", &_7, &_6);
					zephir_check_call_status();
					ZEPHIR_SINIT_NVAR(_6);
					ZVAL_STRING(&_6, "PHP Notice:  PhalconPlus::Db::MySQL::connnect() retry to connect to MySQL for the time ... ", 0);
					ZEPHIR_CALL_FUNCTION(NULL, "error_log", &_4, &_6);
					zephir_check_call_status();
				} else {
					ZEPHIR_SINIT_NVAR(_6);
					ZVAL_STRING(&_6, "PHP Fatal error:  PhalconPlus::Db::MySQL::connect() finally failed to connect to MySQL", 0);
					ZEPHIR_CALL_FUNCTION(NULL, "error_log", &_4, &_6);
					zephir_check_call_status();
					zephir_throw_exception_debug(e, "phalconplus/Db/Mysql.zep", 52 TSRMLS_CC);
					ZEPHIR_MM_RESTORE();
					return;
				}
			}
		}
	}
	RETURN_CCTOR(connection);

}
예제 #24
0
/**
 * Creates a table
 */
PHP_METHOD(Phalcon_Db_Adapter_Pdo_Postgresql, createTable) {

	HashTable *_2$$6;
	HashPosition _1$$6;
	zephir_fcall_cache_entry *_5 = NULL;
	int ZEPHIR_LAST_CALL_STATUS;
	zval *definition = NULL;
	zval *tableName_param = NULL, *schemaName_param = NULL, *definition_param = NULL, *sql = NULL, *queries = NULL, *query = NULL, *exception = NULL, *columns = NULL, *_0, **_3$$6, *_4$$7 = NULL, *_6$$5, *_7$$10, *_8$$10;
	zval *tableName = NULL, *schemaName = NULL;

	ZEPHIR_MM_GROW();
	zephir_fetch_params(1, 3, 0, &tableName_param, &schemaName_param, &definition_param);

	if (UNEXPECTED(Z_TYPE_P(tableName_param) != IS_STRING && Z_TYPE_P(tableName_param) != IS_NULL)) {
		zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'tableName' must be a string") TSRMLS_CC);
		RETURN_MM_NULL();
	}
	if (EXPECTED(Z_TYPE_P(tableName_param) == IS_STRING)) {
		zephir_get_strval(tableName, tableName_param);
	} else {
		ZEPHIR_INIT_VAR(tableName);
		ZVAL_EMPTY_STRING(tableName);
	}
	if (UNEXPECTED(Z_TYPE_P(schemaName_param) != IS_STRING && Z_TYPE_P(schemaName_param) != IS_NULL)) {
		zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'schemaName' must be a string") TSRMLS_CC);
		RETURN_MM_NULL();
	}
	if (EXPECTED(Z_TYPE_P(schemaName_param) == IS_STRING)) {
		zephir_get_strval(schemaName, schemaName_param);
	} else {
		ZEPHIR_INIT_VAR(schemaName);
		ZVAL_EMPTY_STRING(schemaName);
	}
	definition = definition_param;


	ZEPHIR_OBS_VAR(columns);
	if (!(zephir_array_isset_string_fetch(&columns, definition, SS("columns"), 0 TSRMLS_CC))) {
		ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_db_exception_ce, "The table must contain at least one column", "phalcon/db/adapter/pdo/postgresql.zep", 292);
		return;
	}
	if (!(zephir_fast_count_int(columns TSRMLS_CC))) {
		ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_db_exception_ce, "The table must contain at least one column", "phalcon/db/adapter/pdo/postgresql.zep", 296);
		return;
	}
	_0 = zephir_fetch_nproperty_this(this_ptr, SL("_dialect"), PH_NOISY_CC);
	ZEPHIR_CALL_METHOD(&sql, _0, "createtable", NULL, 0, tableName, schemaName, definition);
	zephir_check_call_status();
	ZEPHIR_INIT_VAR(queries);
	zephir_fast_explode_str(queries, SL(";"), sql, LONG_MAX TSRMLS_CC);
	if (zephir_fast_count_int(queries TSRMLS_CC) > 1) {

		/* try_start_1: */

			ZEPHIR_CALL_METHOD(NULL, this_ptr, "begin", NULL, 0);
			zephir_check_call_status_or_jump(try_end_1);
			zephir_is_iterable(queries, &_2$$6, &_1$$6, 0, 0, "phalcon/db/adapter/pdo/postgresql.zep", 312);
			for (
			  ; zend_hash_get_current_data_ex(_2$$6, (void**) &_3$$6, &_1$$6) == SUCCESS
			  ; zend_hash_move_forward_ex(_2$$6, &_1$$6)
			) {
				ZEPHIR_GET_HVALUE(query, _3$$6);
				if (ZEPHIR_IS_EMPTY(query)) {
					continue;
				}
				ZEPHIR_INIT_LNVAR(_4$$7);
				ZEPHIR_CONCAT_VS(_4$$7, query, ";");
				ZEPHIR_CALL_METHOD(NULL, this_ptr, "query", &_5, 0, _4$$7);
				zephir_check_call_status_or_jump(try_end_1);
			}
			ZEPHIR_RETURN_CALL_METHOD(this_ptr, "commit", NULL, 0);
			zephir_check_call_status_or_jump(try_end_1);
			RETURN_MM();

		try_end_1:

		if (EG(exception)) {
			ZEPHIR_INIT_VAR(_6$$5);
			ZEPHIR_CPY_WRT(_6$$5, EG(exception));
			if (zephir_instance_of_ev(_6$$5, zend_exception_get_default(TSRMLS_C) TSRMLS_CC)) {
				zend_clear_exception(TSRMLS_C);
				ZEPHIR_CPY_WRT(exception, _6$$5);
				ZEPHIR_CALL_METHOD(NULL, this_ptr, "rollback", NULL, 0);
				zephir_check_call_status();
				zephir_throw_exception_debug(exception, "phalcon/db/adapter/pdo/postgresql.zep", 316 TSRMLS_CC);
				ZEPHIR_MM_RESTORE();
				return;
			}
		}
	} else {
		zephir_array_fetch_long(&_7$$10, queries, 0, PH_NOISY | PH_READONLY, "phalcon/db/adapter/pdo/postgresql.zep", 319 TSRMLS_CC);
		ZEPHIR_INIT_VAR(_8$$10);
		ZEPHIR_CONCAT_VS(_8$$10, _7$$10, ";");
		ZEPHIR_RETURN_CALL_METHOD(this_ptr, "execute", NULL, 0, _8$$10);
		zephir_check_call_status();
		RETURN_MM();
	}
	RETURN_MM_BOOL(1);

}
예제 #25
0
파일: trytest.zep.c 프로젝트: Mrhjx2/zephir
PHP_METHOD(Test_TryTest, testTry7) {

	int ZEPHIR_LAST_CALL_STATUS;
	zval *a_param = NULL, e, _0$$4, _1$$4, _2$$5, _3$$5;
	zend_bool a;
		zval this_zv;
	zval *this_ptr = getThis();
	if (EXPECTED(this_ptr)) {
		ZVAL_OBJ(&this_zv, Z_OBJ_P(this_ptr));
		this_ptr = &this_zv;
	} else this_ptr = NULL;
	
	ZVAL_UNDEF(&e);
	ZVAL_UNDEF(&_0$$4);
	ZVAL_UNDEF(&_1$$4);
	ZVAL_UNDEF(&_2$$5);
	ZVAL_UNDEF(&_3$$5);

	ZEPHIR_MM_GROW();
	zephir_fetch_params(1, 1, 0, &a_param);

	a = zephir_get_boolval(a_param);



	/* try_start_1: */

		if (a) {
			ZEPHIR_INIT_VAR(&_0$$4);
			object_init_ex(&_0$$4, zend_exception_get_default(TSRMLS_C));
			ZEPHIR_INIT_VAR(&_1$$4);
			ZVAL_STRING(&_1$$4, "error!");
			ZEPHIR_CALL_METHOD(NULL, &_0$$4, "__construct", NULL, 24, &_1$$4);
			zephir_check_call_status_or_jump(try_end_1);
			zephir_throw_exception_debug(&_0$$4, "test/trytest.zep", 99 TSRMLS_CC);
			goto try_end_1;

		} else {
			ZEPHIR_INIT_VAR(&_2$$5);
			object_init_ex(&_2$$5, spl_ce_RuntimeException);
			ZEPHIR_INIT_VAR(&_3$$5);
			ZVAL_STRING(&_3$$5, "error!");
			ZEPHIR_CALL_METHOD(NULL, &_2$$5, "__construct", NULL, 75, &_3$$5);
			zephir_check_call_status_or_jump(try_end_1);
			zephir_throw_exception_debug(&_2$$5, "test/trytest.zep", 101 TSRMLS_CC);
			goto try_end_1;

		}

	try_end_1:

	if (EG(exception)) {
		ZVAL_OBJ(&e, EG(exception));
		Z_ADDREF_P(&e);
		if (zephir_instance_of_ev(&e, spl_ce_RuntimeException TSRMLS_CC)) {
			zend_clear_exception(TSRMLS_C);
			RETURN_MM_STRING("any error");
		}
		if (zephir_instance_of_ev(&e, zend_exception_get_default(TSRMLS_C) TSRMLS_CC)) {
			zend_clear_exception(TSRMLS_C);
			RETURN_MM_STRING("any error");
		}
	}

}
예제 #26
0
/**
 * Dispatches a handle action taking into account the routing parameters
 *
 * @return object
 */
PHP_METHOD(Phalcon_Dispatcher, dispatch) {

	zval *_30$$6 = NULL, *_50$$39 = NULL;
	zval *value = NULL, *handler = NULL, *dependencyInjector = NULL, *namespaceName = NULL, *handlerName = NULL, *actionName = NULL, *params = NULL, *eventsManager = NULL, *actionSuffix = NULL, *handlerClass = NULL, *status = NULL, *actionMethod = NULL, *e = NULL, *_0, *_1$$3, *_2$$3, *_3$$4 = NULL, *_4$$4, *_5$$7 = NULL, *_6$$7 = NULL, *_10$$8 = NULL, *_11$$8 = NULL, *_13$$8, *_14$$6 = NULL, *_16$$12 = NULL, *_17$$12 = NULL, *_19$$13, *_22$$16 = NULL, *_23$$16 = NULL, *_25$$17, *_26$$19 = NULL, *_27$$19 = NULL, *_29$$20, *_31$$23 = NULL, *_32$$23 = NULL, *_34$$23, *_35$$22 = NULL, *_36$$22 = NULL, *_38$$26, *_39$$28 = NULL, *_40$$28 = NULL, *_42$$28, *_43$$31 = NULL, *_44$$31, *_45$$36 = NULL, *_46$$36 = NULL, *_48$$36, *_49$$39 = NULL, *_51$$40 = NULL, *_53$$41, *_54$$44 = NULL, *_55$$44 = NULL, *_57$$44, *_59$$47 = NULL, *_60$$47, *_61$$50;
	zend_bool hasService = 0, wasFresh;
	zephir_fcall_cache_entry *_7 = NULL, *_8 = NULL, *_9 = NULL, *_12 = NULL, *_15 = NULL, *_18 = NULL, *_20 = NULL, *_21 = NULL, *_24 = NULL, *_28 = NULL, *_33 = NULL, *_37 = NULL, *_41 = NULL, *_47 = NULL, *_52 = NULL, *_56 = NULL, *_58 = NULL;
	int ZEPHIR_LAST_CALL_STATUS, numberDispatches = 0;

	ZEPHIR_MM_GROW();

	wasFresh = 0;
	_0 = zephir_fetch_nproperty_this(this_ptr, SL("_dependencyInjector"), PH_NOISY_CC);
	ZEPHIR_CPY_WRT(dependencyInjector, _0);
	if (Z_TYPE_P(dependencyInjector) != IS_OBJECT) {
		ZEPHIR_INIT_VAR(_1$$3);
		ZVAL_STRING(_1$$3, "A dependency injection container is required to access related dispatching services", ZEPHIR_TEMP_PARAM_COPY);
		ZEPHIR_INIT_VAR(_2$$3);
		ZVAL_LONG(_2$$3, 0);
		ZEPHIR_CALL_METHOD(NULL, this_ptr, "_throwdispatchexception", NULL, 0, _1$$3, _2$$3);
		zephir_check_temp_parameter(_1$$3);
		zephir_check_call_status();
		RETURN_MM_BOOL(0);
	}
	_0 = zephir_fetch_nproperty_this(this_ptr, SL("_eventsManager"), PH_NOISY_CC);
	ZEPHIR_CPY_WRT(eventsManager, _0);
	if (Z_TYPE_P(eventsManager) == IS_OBJECT) {
		ZEPHIR_INIT_VAR(_4$$4);
		ZVAL_STRING(_4$$4, "dispatch:beforeDispatchLoop", ZEPHIR_TEMP_PARAM_COPY);
		ZEPHIR_CALL_METHOD(&_3$$4, eventsManager, "fire", NULL, 0, _4$$4, this_ptr);
		zephir_check_temp_parameter(_4$$4);
		zephir_check_call_status();
		if (ZEPHIR_IS_FALSE_IDENTICAL(_3$$4)) {
			RETURN_MM_BOOL(0);
		}
	}
	ZEPHIR_INIT_VAR(value);
	ZVAL_NULL(value);
	ZEPHIR_INIT_VAR(handler);
	ZVAL_NULL(handler);
	numberDispatches = 0;
	ZEPHIR_OBS_VAR(actionSuffix);
	zephir_read_property_this(&actionSuffix, this_ptr, SL("_actionSuffix"), PH_NOISY_CC);
	if (0) {
		zephir_update_property_this(this_ptr, SL("_finished"), ZEPHIR_GLOBAL(global_true) TSRMLS_CC);
	} else {
		zephir_update_property_this(this_ptr, SL("_finished"), ZEPHIR_GLOBAL(global_false) TSRMLS_CC);
	}
	while (1) {
		_0 = zephir_fetch_nproperty_this(this_ptr, SL("_finished"), PH_NOISY_CC);
		if (!(!(zephir_is_true(_0)))) {
			break;
		}
		numberDispatches++;
		if (numberDispatches == 256) {
			ZEPHIR_INIT_NVAR(_5$$7);
			ZVAL_STRING(_5$$7, "Dispatcher has detected a cyclic routing causing stability problems", ZEPHIR_TEMP_PARAM_COPY);
			ZEPHIR_INIT_NVAR(_6$$7);
			ZVAL_LONG(_6$$7, 1);
			ZEPHIR_CALL_METHOD(NULL, this_ptr, "_throwdispatchexception", &_7, 0, _5$$7, _6$$7);
			zephir_check_temp_parameter(_5$$7);
			zephir_check_call_status();
			break;
		}
		if (1) {
			zephir_update_property_this(this_ptr, SL("_finished"), ZEPHIR_GLOBAL(global_true) TSRMLS_CC);
		} else {
			zephir_update_property_this(this_ptr, SL("_finished"), ZEPHIR_GLOBAL(global_false) TSRMLS_CC);
		}
		ZEPHIR_CALL_METHOD(NULL, this_ptr, "_resolveemptyproperties", &_8, 0);
		zephir_check_call_status();
		ZEPHIR_OBS_NVAR(namespaceName);
		zephir_read_property_this(&namespaceName, this_ptr, SL("_namespaceName"), PH_NOISY_CC);
		ZEPHIR_OBS_NVAR(handlerName);
		zephir_read_property_this(&handlerName, this_ptr, SL("_handlerName"), PH_NOISY_CC);
		ZEPHIR_OBS_NVAR(actionName);
		zephir_read_property_this(&actionName, this_ptr, SL("_actionName"), PH_NOISY_CC);
		ZEPHIR_CALL_METHOD(&handlerClass, this_ptr, "gethandlerclass", &_9, 0);
		zephir_check_call_status();
		if (Z_TYPE_P(eventsManager) == IS_OBJECT) {
			ZEPHIR_INIT_NVAR(_11$$8);
			ZVAL_STRING(_11$$8, "dispatch:beforeDispatch", ZEPHIR_TEMP_PARAM_COPY);
			ZEPHIR_CALL_METHOD(&_10$$8, eventsManager, "fire", &_12, 0, _11$$8, this_ptr);
			zephir_check_temp_parameter(_11$$8);
			zephir_check_call_status();
			if (ZEPHIR_IS_FALSE_IDENTICAL(_10$$8)) {
				continue;
			}
			_13$$8 = zephir_fetch_nproperty_this(this_ptr, SL("_finished"), PH_NOISY_CC);
			if (ZEPHIR_IS_FALSE_IDENTICAL(_13$$8)) {
				continue;
			}
		}
		ZEPHIR_CALL_METHOD(&_14$$6, dependencyInjector, "has", &_15, 0, handlerClass);
		zephir_check_call_status();
		hasService = zephir_get_boolval(_14$$6);
		if (!(hasService)) {
			hasService = zephir_class_exists(handlerClass, 1 TSRMLS_CC);
		}
		if (!(hasService)) {
			ZEPHIR_INIT_LNVAR(_16$$12);
			ZEPHIR_CONCAT_VS(_16$$12, handlerClass, " handler class cannot be loaded");
			ZEPHIR_INIT_NVAR(_17$$12);
			ZVAL_LONG(_17$$12, 2);
			ZEPHIR_CALL_METHOD(&status, this_ptr, "_throwdispatchexception", &_18, 0, _16$$12, _17$$12);
			zephir_check_call_status();
			if (ZEPHIR_IS_FALSE_IDENTICAL(status)) {
				_19$$13 = zephir_fetch_nproperty_this(this_ptr, SL("_finished"), PH_NOISY_CC);
				if (ZEPHIR_IS_FALSE_IDENTICAL(_19$$13)) {
					continue;
				}
			}
			break;
		}
		ZEPHIR_CALL_METHOD(&handler, dependencyInjector, "getshared", &_20, 0, handlerClass);
		zephir_check_call_status();
		ZEPHIR_CALL_METHOD(&_14$$6, dependencyInjector, "wasfreshinstance", &_21, 0);
		zephir_check_call_status();
		if (ZEPHIR_IS_TRUE_IDENTICAL(_14$$6)) {
			wasFresh = 1;
		}
		if (Z_TYPE_P(handler) != IS_OBJECT) {
			ZEPHIR_INIT_NVAR(_22$$16);
			ZVAL_STRING(_22$$16, "Invalid handler returned from the services container", ZEPHIR_TEMP_PARAM_COPY);
			ZEPHIR_INIT_NVAR(_23$$16);
			ZVAL_LONG(_23$$16, 3);
			ZEPHIR_CALL_METHOD(&status, this_ptr, "_throwdispatchexception", &_24, 0, _22$$16, _23$$16);
			zephir_check_temp_parameter(_22$$16);
			zephir_check_call_status();
			if (ZEPHIR_IS_FALSE_IDENTICAL(status)) {
				_25$$17 = zephir_fetch_nproperty_this(this_ptr, SL("_finished"), PH_NOISY_CC);
				if (ZEPHIR_IS_FALSE_IDENTICAL(_25$$17)) {
					continue;
				}
			}
			break;
		}
		zephir_update_property_this(this_ptr, SL("_activeHandler"), handler TSRMLS_CC);
		ZEPHIR_OBS_NVAR(params);
		zephir_read_property_this(&params, this_ptr, SL("_params"), PH_NOISY_CC);
		if (Z_TYPE_P(params) != IS_ARRAY) {
			ZEPHIR_INIT_NVAR(_26$$19);
			ZVAL_STRING(_26$$19, "Action parameters must be an Array", ZEPHIR_TEMP_PARAM_COPY);
			ZEPHIR_INIT_NVAR(_27$$19);
			ZVAL_LONG(_27$$19, 4);
			ZEPHIR_CALL_METHOD(&status, this_ptr, "_throwdispatchexception", &_28, 0, _26$$19, _27$$19);
			zephir_check_temp_parameter(_26$$19);
			zephir_check_call_status();
			if (ZEPHIR_IS_FALSE_IDENTICAL(status)) {
				_29$$20 = zephir_fetch_nproperty_this(this_ptr, SL("_finished"), PH_NOISY_CC);
				if (ZEPHIR_IS_FALSE_IDENTICAL(_29$$20)) {
					continue;
				}
			}
			break;
		}
		ZEPHIR_INIT_NVAR(actionMethod);
		ZEPHIR_CONCAT_VV(actionMethod, actionName, actionSuffix);
		ZEPHIR_INIT_NVAR(_30$$6);
		zephir_create_array(_30$$6, 2, 0 TSRMLS_CC);
		zephir_array_fast_append(_30$$6, handler);
		zephir_array_fast_append(_30$$6, actionMethod);
		if (!(zephir_is_callable(_30$$6 TSRMLS_CC))) {
			if (Z_TYPE_P(eventsManager) == IS_OBJECT) {
				ZEPHIR_INIT_NVAR(_32$$23);
				ZVAL_STRING(_32$$23, "dispatch:beforeNotFoundAction", ZEPHIR_TEMP_PARAM_COPY);
				ZEPHIR_CALL_METHOD(&_31$$23, eventsManager, "fire", &_33, 0, _32$$23, this_ptr);
				zephir_check_temp_parameter(_32$$23);
				zephir_check_call_status();
				if (ZEPHIR_IS_FALSE_IDENTICAL(_31$$23)) {
					continue;
				}
				_34$$23 = zephir_fetch_nproperty_this(this_ptr, SL("_finished"), PH_NOISY_CC);
				if (ZEPHIR_IS_FALSE_IDENTICAL(_34$$23)) {
					continue;
				}
			}
			ZEPHIR_INIT_LNVAR(_35$$22);
			ZEPHIR_CONCAT_SVSVS(_35$$22, "Action '", actionName, "' was not found on handler '", handlerName, "'");
			ZEPHIR_INIT_NVAR(_36$$22);
			ZVAL_LONG(_36$$22, 5);
			ZEPHIR_CALL_METHOD(&status, this_ptr, "_throwdispatchexception", &_37, 0, _35$$22, _36$$22);
			zephir_check_call_status();
			if (ZEPHIR_IS_FALSE_IDENTICAL(status)) {
				_38$$26 = zephir_fetch_nproperty_this(this_ptr, SL("_finished"), PH_NOISY_CC);
				if (ZEPHIR_IS_FALSE_IDENTICAL(_38$$26)) {
					continue;
				}
			}
			break;
		}
		if (Z_TYPE_P(eventsManager) == IS_OBJECT) {
			ZEPHIR_INIT_NVAR(_40$$28);
			ZVAL_STRING(_40$$28, "dispatch:beforeExecuteRoute", ZEPHIR_TEMP_PARAM_COPY);
			ZEPHIR_CALL_METHOD(&_39$$28, eventsManager, "fire", &_41, 0, _40$$28, this_ptr);
			zephir_check_temp_parameter(_40$$28);
			zephir_check_call_status();
			if (ZEPHIR_IS_FALSE_IDENTICAL(_39$$28)) {
				continue;
			}
			_42$$28 = zephir_fetch_nproperty_this(this_ptr, SL("_finished"), PH_NOISY_CC);
			if (ZEPHIR_IS_FALSE_IDENTICAL(_42$$28)) {
				continue;
			}
		}
		if ((zephir_method_exists_ex(handler, SS("beforeexecuteroute") TSRMLS_CC) == SUCCESS)) {
			ZEPHIR_CALL_METHOD(&_43$$31, handler, "beforeexecuteroute", NULL, 0, this_ptr);
			zephir_check_call_status();
			if (ZEPHIR_IS_FALSE_IDENTICAL(_43$$31)) {
				continue;
			}
			_44$$31 = zephir_fetch_nproperty_this(this_ptr, SL("_finished"), PH_NOISY_CC);
			if (ZEPHIR_IS_FALSE_IDENTICAL(_44$$31)) {
				continue;
			}
		}
		if (wasFresh == 1) {
			if ((zephir_method_exists_ex(handler, SS("initialize") TSRMLS_CC) == SUCCESS)) {
				ZEPHIR_CALL_METHOD(NULL, handler, "initialize", NULL, 0);
				zephir_check_call_status();
			}
			if (zephir_is_true(eventsManager)) {
				ZEPHIR_INIT_NVAR(_46$$36);
				ZVAL_STRING(_46$$36, "dispatch:afterInitialize", ZEPHIR_TEMP_PARAM_COPY);
				ZEPHIR_CALL_METHOD(&_45$$36, eventsManager, "fire", &_47, 0, _46$$36, this_ptr);
				zephir_check_temp_parameter(_46$$36);
				zephir_check_call_status();
				if (ZEPHIR_IS_FALSE_IDENTICAL(_45$$36)) {
					continue;
				}
				_48$$36 = zephir_fetch_nproperty_this(this_ptr, SL("_finished"), PH_NOISY_CC);
				if (ZEPHIR_IS_FALSE_IDENTICAL(_48$$36)) {
					continue;
				}
			}
		}
		zephir_update_property_this(this_ptr, SL("_lastHandler"), handler TSRMLS_CC);

		/* try_start_1: */

			ZEPHIR_INIT_NVAR(_49$$39);
			ZEPHIR_INIT_NVAR(_50$$39);
			zephir_create_array(_50$$39, 2, 0 TSRMLS_CC);
			zephir_array_fast_append(_50$$39, handler);
			zephir_array_fast_append(_50$$39, actionMethod);
			ZEPHIR_CALL_USER_FUNC_ARRAY(_49$$39, _50$$39, params);
			zephir_check_call_status_or_jump(try_end_1);
			zephir_update_property_this(this_ptr, SL("_returnedValue"), _49$$39 TSRMLS_CC);

		try_end_1:

		if (EG(exception)) {
			ZEPHIR_CPY_WRT(e, EG(exception));
			if (zephir_instance_of_ev(e, zend_exception_get_default(TSRMLS_C) TSRMLS_CC)) {
				zend_clear_exception(TSRMLS_C);
				zephir_update_property_this(this_ptr, SL("_lastHandler"), handler TSRMLS_CC);
				ZEPHIR_CALL_METHOD(&_51$$40, this_ptr, "_handleexception", &_52, 0, e);
				zephir_check_call_status();
				if (ZEPHIR_IS_FALSE_IDENTICAL(_51$$40)) {
					_53$$41 = zephir_fetch_nproperty_this(this_ptr, SL("_finished"), PH_NOISY_CC);
					if (ZEPHIR_IS_FALSE_IDENTICAL(_53$$41)) {
						continue;
					}
				} else {
					zephir_throw_exception_debug(e, "phalcon/dispatcher.zep", 522 TSRMLS_CC);
					ZEPHIR_MM_RESTORE();
					return;
				}
			}
		}
		if (Z_TYPE_P(eventsManager) == IS_OBJECT) {
			ZEPHIR_INIT_NVAR(_55$$44);
			ZVAL_STRING(_55$$44, "dispatch:afterExecuteRoute", ZEPHIR_TEMP_PARAM_COPY);
			ZEPHIR_CALL_METHOD(&_54$$44, eventsManager, "fire", &_56, 0, _55$$44, this_ptr, value);
			zephir_check_temp_parameter(_55$$44);
			zephir_check_call_status();
			if (ZEPHIR_IS_FALSE_IDENTICAL(_54$$44)) {
				continue;
			}
			_57$$44 = zephir_fetch_nproperty_this(this_ptr, SL("_finished"), PH_NOISY_CC);
			if (ZEPHIR_IS_FALSE_IDENTICAL(_57$$44)) {
				continue;
			}
			ZEPHIR_INIT_NVAR(_55$$44);
			ZVAL_STRING(_55$$44, "dispatch:afterDispatch", ZEPHIR_TEMP_PARAM_COPY);
			ZEPHIR_CALL_METHOD(NULL, eventsManager, "fire", &_58, 0, _55$$44, this_ptr);
			zephir_check_temp_parameter(_55$$44);
			zephir_check_call_status();
		}
		if ((zephir_method_exists_ex(handler, SS("afterexecuteroute") TSRMLS_CC) == SUCCESS)) {
			ZEPHIR_CALL_METHOD(&_59$$47, handler, "afterexecuteroute", NULL, 0, this_ptr, value);
			zephir_check_call_status();
			if (ZEPHIR_IS_FALSE_IDENTICAL(_59$$47)) {
				continue;
			}
			_60$$47 = zephir_fetch_nproperty_this(this_ptr, SL("_finished"), PH_NOISY_CC);
			if (ZEPHIR_IS_FALSE_IDENTICAL(_60$$47)) {
				continue;
			}
		}
	}
	if (Z_TYPE_P(eventsManager) == IS_OBJECT) {
		ZEPHIR_INIT_VAR(_61$$50);
		ZVAL_STRING(_61$$50, "dispatch:afterDispatchLoop", ZEPHIR_TEMP_PARAM_COPY);
		ZEPHIR_CALL_METHOD(NULL, eventsManager, "fire", NULL, 0, _61$$50, this_ptr);
		zephir_check_temp_parameter(_61$$50);
		zephir_check_call_status();
	}
	RETURN_CCTOR(handler);

}
예제 #27
0
/**
 * Dispatches a handle action taking into account the routing parameters
 *
 * @return object
 */
PHP_METHOD(Phalcon_Dispatcher, dispatch) {

	zval *_18 = NULL;
	zephir_fcall_cache_entry *_4 = NULL, *_5 = NULL, *_8 = NULL, *_10 = NULL, *_11 = NULL, *_12 = NULL, *_13 = NULL, *_14 = NULL, *_16 = NULL, *_19 = NULL;
	zval *value, *handler = NULL, *dependencyInjector = NULL, *namespaceName = NULL, *handlerName = NULL, *actionName = NULL, *camelizedClass = NULL, *params = NULL, *eventsManager = NULL, *handlerSuffix, *actionSuffix, *handlerClass = NULL, *status = NULL, *actionMethod = NULL, *e = NULL, *_0, *_1 = NULL, *_2 = NULL, *_3 = NULL, *_6, *_7 = NULL, *_9 = NULL, *_15 = NULL, *_17;
	int numberDispatches, ZEPHIR_LAST_CALL_STATUS;
	zend_bool hasService, wasFresh = 0;

	ZEPHIR_MM_GROW();

	_0 = zephir_fetch_nproperty_this(this_ptr, SL("_dependencyInjector"), PH_NOISY_CC);
	ZEPHIR_CPY_WRT(dependencyInjector, _0);
	if (Z_TYPE_P(dependencyInjector) != IS_OBJECT) {
		ZEPHIR_INIT_VAR(_1);
		ZVAL_STRING(_1, "A dependency injection container is required to access related dispatching services", ZEPHIR_TEMP_PARAM_COPY);
		ZEPHIR_INIT_VAR(_2);
		ZVAL_LONG(_2, 0);
		ZEPHIR_CALL_METHOD(NULL, this_ptr, "_throwdispatchexception", NULL, _1, _2);
		zephir_check_temp_parameter(_1);
		zephir_check_call_status();
		RETURN_MM_BOOL(0);
	}
	_0 = zephir_fetch_nproperty_this(this_ptr, SL("_eventsManager"), PH_NOISY_CC);
	ZEPHIR_CPY_WRT(eventsManager, _0);
	if (Z_TYPE_P(eventsManager) == IS_OBJECT) {
		ZEPHIR_INIT_NVAR(_1);
		ZVAL_STRING(_1, "dispatch:beforeDispatchLoop", ZEPHIR_TEMP_PARAM_COPY);
		ZEPHIR_CALL_METHOD(&_3, eventsManager, "fire", NULL, _1, this_ptr);
		zephir_check_temp_parameter(_1);
		zephir_check_call_status();
		if (ZEPHIR_IS_FALSE_IDENTICAL(_3)) {
			RETURN_MM_BOOL(0);
		}
	}
	ZEPHIR_INIT_VAR(value);
	ZVAL_NULL(value);
	ZEPHIR_INIT_VAR(handler);
	ZVAL_NULL(handler);
	numberDispatches = 0;
	ZEPHIR_OBS_VAR(handlerSuffix);
	zephir_read_property_this(&handlerSuffix, this_ptr, SL("_handlerSuffix"), PH_NOISY_CC);
	ZEPHIR_OBS_VAR(actionSuffix);
	zephir_read_property_this(&actionSuffix, this_ptr, SL("_actionSuffix"), PH_NOISY_CC);
	zephir_update_property_this(this_ptr, SL("_finished"), (0) ? ZEPHIR_GLOBAL(global_true) : ZEPHIR_GLOBAL(global_false) TSRMLS_CC);
	while (1) {
		_0 = zephir_fetch_nproperty_this(this_ptr, SL("_finished"), PH_NOISY_CC);
		if (!(!(zephir_is_true(_0)))) {
			break;
		}
		numberDispatches++;
		if (numberDispatches == 256) {
			ZEPHIR_INIT_NVAR(_1);
			ZVAL_STRING(_1, "Dispatcher has detected a cyclic routing causing stability problems", ZEPHIR_TEMP_PARAM_COPY);
			ZEPHIR_INIT_NVAR(_2);
			ZVAL_LONG(_2, 1);
			ZEPHIR_CALL_METHOD(NULL, this_ptr, "_throwdispatchexception", &_4, _1, _2);
			zephir_check_temp_parameter(_1);
			zephir_check_call_status();
			break;
		}
		zephir_update_property_this(this_ptr, SL("_finished"), (1) ? ZEPHIR_GLOBAL(global_true) : ZEPHIR_GLOBAL(global_false) TSRMLS_CC);
		ZEPHIR_OBS_NVAR(namespaceName);
		zephir_read_property_this(&namespaceName, this_ptr, SL("_namespaceName"), PH_NOISY_CC);
		if (!(zephir_is_true(namespaceName))) {
			ZEPHIR_OBS_NVAR(namespaceName);
			zephir_read_property_this(&namespaceName, this_ptr, SL("_defaultNamespace"), PH_NOISY_CC);
			zephir_update_property_this(this_ptr, SL("_namespaceName"), namespaceName TSRMLS_CC);
		}
		ZEPHIR_OBS_NVAR(handlerName);
		zephir_read_property_this(&handlerName, this_ptr, SL("_handlerName"), PH_NOISY_CC);
		if (!(zephir_is_true(handlerName))) {
			ZEPHIR_OBS_NVAR(handlerName);
			zephir_read_property_this(&handlerName, this_ptr, SL("_defaultHandler"), PH_NOISY_CC);
			zephir_update_property_this(this_ptr, SL("_handlerName"), handlerName TSRMLS_CC);
		}
		ZEPHIR_OBS_NVAR(actionName);
		zephir_read_property_this(&actionName, this_ptr, SL("_actionName"), PH_NOISY_CC);
		if (!(zephir_is_true(actionName))) {
			ZEPHIR_OBS_NVAR(actionName);
			zephir_read_property_this(&actionName, this_ptr, SL("_defaultAction"), PH_NOISY_CC);
			zephir_update_property_this(this_ptr, SL("_actionName"), actionName TSRMLS_CC);
		}
		if (Z_TYPE_P(eventsManager) == IS_OBJECT) {
			ZEPHIR_INIT_NVAR(_1);
			ZVAL_STRING(_1, "dispatch:beforeDispatch", ZEPHIR_TEMP_PARAM_COPY);
			ZEPHIR_CALL_METHOD(&_3, eventsManager, "fire", &_5, _1, this_ptr);
			zephir_check_temp_parameter(_1);
			zephir_check_call_status();
			if (ZEPHIR_IS_FALSE_IDENTICAL(_3)) {
				continue;
			}
			_6 = zephir_fetch_nproperty_this(this_ptr, SL("_finished"), PH_NOISY_CC);
			if (ZEPHIR_IS_FALSE_IDENTICAL(_6)) {
				continue;
			}
		}
		if (!(zephir_memnstr_str(handlerName, SL("\\"), "phalcon/dispatcher.zep", 390))) {
			ZEPHIR_INIT_NVAR(camelizedClass);
			zephir_camelize(camelizedClass, handlerName);
		} else {
			ZEPHIR_CPY_WRT(camelizedClass, handlerName);
		}
		if (zephir_is_true(namespaceName)) {
			ZEPHIR_INIT_NVAR(handlerClass);
			if (zephir_end_with_str(namespaceName, SL("\\"))) {
				ZEPHIR_CONCAT_VVV(handlerClass, namespaceName, camelizedClass, handlerSuffix);
			} else {
				ZEPHIR_CONCAT_VSVV(handlerClass, namespaceName, "\\", camelizedClass, handlerSuffix);
			}
		} else {
			ZEPHIR_INIT_NVAR(handlerClass);
			ZEPHIR_CONCAT_VV(handlerClass, camelizedClass, handlerSuffix);
		}
		ZEPHIR_CALL_METHOD(&_7, dependencyInjector, "has", &_8, handlerClass);
		zephir_check_call_status();
		hasService = zephir_get_boolval(_7);
		if (!(hasService)) {
			hasService = zephir_class_exists(handlerClass, 1 TSRMLS_CC);
		}
		if (!(hasService)) {
			ZEPHIR_INIT_LNVAR(_9);
			ZEPHIR_CONCAT_VS(_9, handlerClass, " handler class cannot be loaded");
			ZEPHIR_INIT_NVAR(_1);
			ZVAL_LONG(_1, 2);
			ZEPHIR_CALL_METHOD(&status, this_ptr, "_throwdispatchexception", &_10, _9, _1);
			zephir_check_call_status();
			if (ZEPHIR_IS_FALSE_IDENTICAL(status)) {
				_6 = zephir_fetch_nproperty_this(this_ptr, SL("_finished"), PH_NOISY_CC);
				if (ZEPHIR_IS_FALSE_IDENTICAL(_6)) {
					continue;
				}
			}
			break;
		}
		ZEPHIR_CALL_METHOD(&handler, dependencyInjector, "getshared", &_11, handlerClass);
		zephir_check_call_status();
		ZEPHIR_CALL_METHOD(&_7, dependencyInjector, "wasfreshinstance", &_12);
		zephir_check_call_status();
		if (ZEPHIR_IS_TRUE_IDENTICAL(_7)) {
			wasFresh = 1;
		}
		if (Z_TYPE_P(handler) != IS_OBJECT) {
			ZEPHIR_INIT_NVAR(_1);
			ZVAL_STRING(_1, "Invalid handler returned from the services container", ZEPHIR_TEMP_PARAM_COPY);
			ZEPHIR_INIT_NVAR(_2);
			ZVAL_LONG(_2, 3);
			ZEPHIR_CALL_METHOD(&status, this_ptr, "_throwdispatchexception", &_13, _1, _2);
			zephir_check_temp_parameter(_1);
			zephir_check_call_status();
			if (ZEPHIR_IS_FALSE_IDENTICAL(status)) {
				_6 = zephir_fetch_nproperty_this(this_ptr, SL("_finished"), PH_NOISY_CC);
				if (ZEPHIR_IS_FALSE_IDENTICAL(_6)) {
					continue;
				}
			}
			break;
		}
		zephir_update_property_this(this_ptr, SL("_activeHandler"), handler TSRMLS_CC);
		ZEPHIR_OBS_NVAR(params);
		zephir_read_property_this(&params, this_ptr, SL("_params"), PH_NOISY_CC);
		if (Z_TYPE_P(params) != IS_ARRAY) {
			ZEPHIR_INIT_NVAR(_1);
			ZVAL_STRING(_1, "Action parameters must be an Array", ZEPHIR_TEMP_PARAM_COPY);
			ZEPHIR_INIT_NVAR(_2);
			ZVAL_LONG(_2, 4);
			ZEPHIR_CALL_METHOD(&status, this_ptr, "_throwdispatchexception", &_14, _1, _2);
			zephir_check_temp_parameter(_1);
			zephir_check_call_status();
			if (ZEPHIR_IS_FALSE_IDENTICAL(status)) {
				_6 = zephir_fetch_nproperty_this(this_ptr, SL("_finished"), PH_NOISY_CC);
				if (ZEPHIR_IS_FALSE_IDENTICAL(_6)) {
					continue;
				}
			}
			break;
		}
		ZEPHIR_INIT_NVAR(actionMethod);
		ZEPHIR_CONCAT_VV(actionMethod, actionName, actionSuffix);
		if (!((zephir_method_exists(handler, actionMethod TSRMLS_CC)  == SUCCESS))) {
			if (Z_TYPE_P(eventsManager) == IS_OBJECT) {
				ZEPHIR_INIT_NVAR(_1);
				ZVAL_STRING(_1, "dispatch:beforeNotFoundAction", ZEPHIR_TEMP_PARAM_COPY);
				ZEPHIR_CALL_METHOD(&_15, eventsManager, "fire", &_5, _1, this_ptr);
				zephir_check_temp_parameter(_1);
				zephir_check_call_status();
				if (ZEPHIR_IS_FALSE_IDENTICAL(_15)) {
					continue;
				}
				_6 = zephir_fetch_nproperty_this(this_ptr, SL("_finished"), PH_NOISY_CC);
				if (ZEPHIR_IS_FALSE_IDENTICAL(_6)) {
					continue;
				}
			}
			ZEPHIR_INIT_LNVAR(_9);
			ZEPHIR_CONCAT_SVSVS(_9, "Action '", actionName, "' was not found on handler '", handlerName, "'");
			ZEPHIR_INIT_NVAR(_1);
			ZVAL_LONG(_1, 5);
			ZEPHIR_CALL_METHOD(&status, this_ptr, "_throwdispatchexception", &_16, _9, _1);
			zephir_check_call_status();
			if (ZEPHIR_IS_FALSE_IDENTICAL(status)) {
				_17 = zephir_fetch_nproperty_this(this_ptr, SL("_finished"), PH_NOISY_CC);
				if (ZEPHIR_IS_FALSE_IDENTICAL(_17)) {
					continue;
				}
			}
			break;
		}
		if (Z_TYPE_P(eventsManager) == IS_OBJECT) {
			ZEPHIR_INIT_NVAR(_1);
			ZVAL_STRING(_1, "dispatch:beforeExecuteRoute", ZEPHIR_TEMP_PARAM_COPY);
			ZEPHIR_CALL_METHOD(&_15, eventsManager, "fire", &_5, _1, this_ptr);
			zephir_check_temp_parameter(_1);
			zephir_check_call_status();
			if (ZEPHIR_IS_FALSE_IDENTICAL(_15)) {
				continue;
			}
			_6 = zephir_fetch_nproperty_this(this_ptr, SL("_finished"), PH_NOISY_CC);
			if (ZEPHIR_IS_FALSE_IDENTICAL(_6)) {
				continue;
			}
		}
		if ((zephir_method_exists_ex(handler, SS("beforeexecuteroute") TSRMLS_CC) == SUCCESS)) {
			ZEPHIR_CALL_METHOD(&_15, handler, "beforeexecuteroute", NULL, this_ptr);
			zephir_check_call_status();
			if (ZEPHIR_IS_FALSE_IDENTICAL(_15)) {
				continue;
			}
			_6 = zephir_fetch_nproperty_this(this_ptr, SL("_finished"), PH_NOISY_CC);
			if (ZEPHIR_IS_FALSE_IDENTICAL(_6)) {
				continue;
			}
		}
		if (wasFresh == 1) {
			if ((zephir_method_exists_ex(handler, SS("initialize") TSRMLS_CC) == SUCCESS)) {
				ZEPHIR_CALL_METHOD(NULL, handler, "initialize", NULL);
				zephir_check_call_status();
			}
			if (zephir_is_true(eventsManager)) {
				ZEPHIR_INIT_NVAR(_1);
				ZVAL_STRING(_1, "dispatch:afterInitialize", ZEPHIR_TEMP_PARAM_COPY);
				ZEPHIR_CALL_METHOD(&_15, eventsManager, "fire", &_5, _1, this_ptr);
				zephir_check_temp_parameter(_1);
				zephir_check_call_status();
				if (ZEPHIR_IS_FALSE_IDENTICAL(_15)) {
					continue;
				}
				_6 = zephir_fetch_nproperty_this(this_ptr, SL("_finished"), PH_NOISY_CC);
				if (ZEPHIR_IS_FALSE_IDENTICAL(_6)) {
					continue;
				}
			}
		}

		/* try_start_1: */

			ZEPHIR_INIT_NVAR(_1);
			ZEPHIR_INIT_NVAR(_18);
			zephir_create_array(_18, 2, 0 TSRMLS_CC);
			zephir_array_fast_append(_18, handler);
			zephir_array_fast_append(_18, actionMethod);
			ZEPHIR_CALL_USER_FUNC_ARRAY(_1, _18, params);
			zephir_check_call_status_or_jump(try_end_1);
			zephir_update_property_this(this_ptr, SL("_returnedValue"), _1 TSRMLS_CC);
			zephir_update_property_this(this_ptr, SL("_lastHandler"), handler TSRMLS_CC);

		try_end_1:

		if (EG(exception)) {
			ZEPHIR_CPY_WRT(e, EG(exception));
			if (zephir_instance_of_ev(e, zend_exception_get_default(TSRMLS_C) TSRMLS_CC)) {
				zend_clear_exception(TSRMLS_C);
				ZEPHIR_CALL_METHOD(&_15, this_ptr, "_handleexception", &_19, e);
				zephir_check_call_status();
				if (ZEPHIR_IS_FALSE_IDENTICAL(_15)) {
					_6 = zephir_fetch_nproperty_this(this_ptr, SL("_finished"), PH_NOISY_CC);
					if (ZEPHIR_IS_FALSE_IDENTICAL(_6)) {
						continue;
					}
				} else {
					zephir_throw_exception_debug(e, "phalcon/dispatcher.zep", 550 TSRMLS_CC);
					ZEPHIR_MM_RESTORE();
					return;
				}
			}
		}
		if (Z_TYPE_P(eventsManager) == IS_OBJECT) {
			ZEPHIR_INIT_NVAR(_2);
			ZVAL_STRING(_2, "dispatch:afterExecuteRoute", ZEPHIR_TEMP_PARAM_COPY);
			ZEPHIR_CALL_METHOD(&_15, eventsManager, "fire", &_5, _2, this_ptr, value);
			zephir_check_temp_parameter(_2);
			zephir_check_call_status();
			if (ZEPHIR_IS_FALSE_IDENTICAL(_15)) {
				continue;
			}
			_6 = zephir_fetch_nproperty_this(this_ptr, SL("_finished"), PH_NOISY_CC);
			if (ZEPHIR_IS_FALSE_IDENTICAL(_6)) {
				continue;
			}
			ZEPHIR_INIT_NVAR(_2);
			ZVAL_STRING(_2, "dispatch:afterDispatch", ZEPHIR_TEMP_PARAM_COPY);
			ZEPHIR_CALL_METHOD(NULL, eventsManager, "fire", &_5, _2, this_ptr);
			zephir_check_temp_parameter(_2);
			zephir_check_call_status();
		}
		if ((zephir_method_exists_ex(handler, SS("afterexecuteroute") TSRMLS_CC) == SUCCESS)) {
			ZEPHIR_CALL_METHOD(&_15, handler, "afterexecuteroute", NULL, this_ptr, value);
			zephir_check_call_status();
			if (ZEPHIR_IS_FALSE_IDENTICAL(_15)) {
				continue;
			}
			_6 = zephir_fetch_nproperty_this(this_ptr, SL("_finished"), PH_NOISY_CC);
			if (ZEPHIR_IS_FALSE_IDENTICAL(_6)) {
				continue;
			}
		}
	}
	if (Z_TYPE_P(eventsManager) == IS_OBJECT) {
		ZEPHIR_INIT_NVAR(_1);
		ZVAL_STRING(_1, "dispatch:afterDispatchLoop", ZEPHIR_TEMP_PARAM_COPY);
		ZEPHIR_CALL_METHOD(NULL, eventsManager, "fire", &_5, _1, this_ptr);
		zephir_check_temp_parameter(_1);
		zephir_check_call_status();
	}
	RETURN_CCTOR(handler);

}
예제 #28
0
PHP_METHOD(PhalconPlus_Db_Mysql, getConnection) {

	zval __$true, __$false, tryTimes, e, _0, _1$$4, _2$$4, _4$$3, _5$$5, _6$$5, _7$$5, _9$$5, _12$$6, _14$$6, _15$$6, _16$$6, _17$$6, _18$$7, _19$$7, _20$$7;
	zephir_fcall_cache_entry *_3 = NULL, *_8 = NULL, *_10 = NULL, *_13 = NULL;
	zend_long ZEPHIR_LAST_CALL_STATUS, _11$$5;
	zval *this_ptr = getThis();

	ZVAL_BOOL(&__$true, 1);
	ZVAL_BOOL(&__$false, 0);
	ZVAL_UNDEF(&tryTimes);
	ZVAL_UNDEF(&e);
	ZVAL_UNDEF(&_0);
	ZVAL_UNDEF(&_1$$4);
	ZVAL_UNDEF(&_2$$4);
	ZVAL_UNDEF(&_4$$3);
	ZVAL_UNDEF(&_5$$5);
	ZVAL_UNDEF(&_6$$5);
	ZVAL_UNDEF(&_7$$5);
	ZVAL_UNDEF(&_9$$5);
	ZVAL_UNDEF(&_12$$6);
	ZVAL_UNDEF(&_14$$6);
	ZVAL_UNDEF(&_15$$6);
	ZVAL_UNDEF(&_16$$6);
	ZVAL_UNDEF(&_17$$6);
	ZVAL_UNDEF(&_18$$7);
	ZVAL_UNDEF(&_19$$7);
	ZVAL_UNDEF(&_20$$7);

	ZEPHIR_MM_GROW();

	ZEPHIR_OBS_VAR(&tryTimes);
	zephir_read_property(&tryTimes, this_ptr, SL("retryTimes"), PH_NOISY_CC);
	while (1) {
		zephir_read_property(&_0, this_ptr, SL("connected"), PH_NOISY_CC | PH_READONLY);
		if (!(!(zephir_is_true(&_0)))) {
			break;
		}

		/* try_start_1: */

			ZEPHIR_INIT_NVAR(&_1$$4);
			object_init_ex(&_1$$4, zephir_get_internal_ce(SL("phalcon\\db\\adapter\\pdo\\mysql")));
			zephir_read_property(&_2$$4, this_ptr, SL("descriptor"), PH_NOISY_CC | PH_READONLY);
			ZEPHIR_CALL_METHOD(NULL, &_1$$4, "__construct", &_3, 0, &_2$$4);
			zephir_check_call_status_or_jump(try_end_1);
			zephir_update_property_zval(this_ptr, SL("connection"), &_1$$4);
			if (1) {
				zephir_update_property_zval(this_ptr, SL("connected"), &__$true);
			} else {
				zephir_update_property_zval(this_ptr, SL("connected"), &__$false);
			}

		try_end_1:

		if (EG(exception)) {
			ZEPHIR_INIT_NVAR(&_4$$3);
			ZVAL_OBJ(&_4$$3, EG(exception));
			Z_ADDREF_P(&_4$$3);
			if (zephir_instance_of_ev(&_4$$3, zend_exception_get_default(TSRMLS_C) TSRMLS_CC)) {
				zend_clear_exception(TSRMLS_C);
				ZEPHIR_CPY_WRT(&e, &_4$$3);
				ZEPHIR_INIT_NVAR(&_5$$5);
				zephir_read_property(&_6$$5, this_ptr, SL("descriptor"), PH_NOISY_CC | PH_READONLY);
				zephir_json_encode(&_5$$5, &_6$$5, 0 );
				ZEPHIR_CALL_FUNCTION(&_7$$5, "strval", &_8, 27, &tryTimes);
				zephir_check_call_status();
				ZEPHIR_INIT_LNVAR(_9$$5);
				ZEPHIR_CONCAT_SVSVS(&_9$$5, "PHP Fatal error:  PhalconPlus::Db::MySQL::connect() failed to connect to MySQL. Detail: ", &_5$$5, ". We will try ", &_7$$5, " times for you.");
				ZEPHIR_CALL_FUNCTION(NULL, "error_log", &_10, 50, &_9$$5);
				zephir_check_call_status();
				_11$$5 = (zephir_get_numberval(&tryTimes) - 1);
				ZEPHIR_INIT_NVAR(&tryTimes);
				ZVAL_LONG(&tryTimes, _11$$5);
				if (ZEPHIR_GT_LONG(&tryTimes, 0)) {
					zephir_read_property(&_12$$6, this_ptr, SL("retryInterval"), PH_NOISY_CC | PH_READONLY);
					ZEPHIR_CALL_FUNCTION(NULL, "usleep", &_13, 57, &_12$$6);
					zephir_check_call_status();
					zephir_read_property(&_14$$6, this_ptr, SL("retryTimes"), PH_NOISY_CC | PH_READONLY);
					ZEPHIR_SINIT_NVAR(_15$$6);
					zephir_sub_function(&_15$$6, &_14$$6, &tryTimes);
					ZEPHIR_CALL_FUNCTION(&_16$$6, "strval", &_8, 27, &_15$$6);
					zephir_check_call_status();
					ZEPHIR_INIT_LNVAR(_17$$6);
					ZEPHIR_CONCAT_SVS(&_17$$6, "PHP Notice:  PhalconPlus::Db::MySQL::connnect() retry to connect to MySQL for the ", &_16$$6, " time ... ");
					ZEPHIR_CALL_FUNCTION(NULL, "error_log", &_10, 50, &_17$$6);
					zephir_check_call_status();
				} else {
					ZEPHIR_INIT_NVAR(&_18$$7);
					zephir_read_property(&_19$$7, this_ptr, SL("descriptor"), PH_NOISY_CC | PH_READONLY);
					zephir_json_encode(&_18$$7, &_19$$7, 0 );
					ZEPHIR_INIT_LNVAR(_20$$7);
					ZEPHIR_CONCAT_SV(&_20$$7, "PHP Fatal error:  PhalconPlus::Db::MySQL::connect() finally failed to connect to MySQL. Detail: ", &_18$$7);
					ZEPHIR_CALL_FUNCTION(NULL, "error_log", &_10, 50, &_20$$7);
					zephir_check_call_status();
					zephir_throw_exception_debug(&e, "phalconplus/Db/Mysql.zep", 77 TSRMLS_CC);
					ZEPHIR_MM_RESTORE();
					return;
				}
			}
		}
	}
	RETURN_MM_MEMBER(getThis(), "connection");

}