Пример #1
0
/**
 * Inserts jobs into the queue
 */
PHP_METHOD(Phalcon_Queue_Beanstalk, put) {

	zend_bool _2;
	zephir_fcall_cache_entry *_1 = NULL;
	int ZEPHIR_LAST_CALL_STATUS;
	zval *options = NULL;
	zval *data, *options_param = NULL, *priority = NULL, *delay = NULL, *ttr = NULL, *serialized = NULL, *response = NULL, *status = NULL, *length = NULL, *_0, *_3;

	ZEPHIR_MM_GROW();
	zephir_fetch_params(1, 1, 1, &data, &options_param);

	if (!options_param) {
		ZEPHIR_INIT_VAR(options);
		array_init(options);
	} else {
		zephir_get_arrval(options, options_param);
	}


	ZEPHIR_OBS_VAR(priority);
	if (!(zephir_array_isset_string_fetch(&priority, options, SS("priority"), 0 TSRMLS_CC))) {
		ZEPHIR_INIT_NVAR(priority);
		ZVAL_LONG(priority, 100);
	}
	ZEPHIR_OBS_VAR(delay);
	if (!(zephir_array_isset_string_fetch(&delay, options, SS("delay"), 0 TSRMLS_CC))) {
		ZEPHIR_INIT_NVAR(delay);
		ZVAL_LONG(delay, 0);
	}
	ZEPHIR_OBS_VAR(ttr);
	if (!(zephir_array_isset_string_fetch(&ttr, options, SS("ttr"), 0 TSRMLS_CC))) {
		ZEPHIR_INIT_NVAR(ttr);
		ZVAL_LONG(ttr, 86400);
	}
	ZEPHIR_CALL_FUNCTION(&serialized, "serialize", NULL, 75, data);
	zephir_check_call_status();
	ZEPHIR_INIT_VAR(length);
	ZVAL_LONG(length, zephir_fast_strlen_ev(serialized));
	ZEPHIR_INIT_VAR(_0);
	ZEPHIR_CONCAT_SVSVSVSV(_0, "put ", priority, " ", delay, " ", ttr, " ", length);
	ZEPHIR_CALL_METHOD(NULL, this_ptr, "write", &_1, 0, _0);
	zephir_check_call_status();
	ZEPHIR_CALL_METHOD(NULL, this_ptr, "write", &_1, 0, serialized);
	zephir_check_call_status();
	ZEPHIR_CALL_METHOD(&response, this_ptr, "readstatus", NULL, 382);
	zephir_check_call_status();
	zephir_array_fetch_long(&status, response, 0, PH_NOISY | PH_READONLY, "phalcon/queue/beanstalk.zep", 150 TSRMLS_CC);
	_2 = !ZEPHIR_IS_STRING(status, "INSERTED");
	if (_2) {
		_2 = !ZEPHIR_IS_STRING(status, "BURIED");
	}
	if (_2) {
		RETURN_MM_BOOL(0);
	}
	zephir_array_fetch_long(&_3, response, 1, PH_NOISY | PH_READONLY, "phalcon/queue/beanstalk.zep", 156 TSRMLS_CC);
	RETURN_CTOR(_3);

}
Пример #2
0
/**
 * Inserts jobs into the queue
 *
 * @param string data
 * @param array options
 */
PHP_METHOD(Phalcon_Queue_Beanstalk, put) {

	zend_bool _4;
	zephir_fcall_cache_entry *_2 = NULL;
	int ZEPHIR_LAST_CALL_STATUS;
	zephir_nts_static zephir_fcall_cache_entry *_0 = NULL, *_3 = NULL;
	zval *data, *options = NULL, *priority = NULL, *delay = NULL, *ttr = NULL, *serialized = NULL, *response = NULL, *status, *length, *_1, *_5;

	ZEPHIR_MM_GROW();
	zephir_fetch_params(1, 1, 1, &data, &options);

	if (!options) {
		options = ZEPHIR_GLOBAL(global_null);
	}


	ZEPHIR_OBS_VAR(priority);
	if (!(zephir_array_isset_string_fetch(&priority, options, SS("priority"), 0 TSRMLS_CC))) {
		ZEPHIR_INIT_NVAR(priority);
		ZVAL_LONG(priority, 100);
	}
	ZEPHIR_OBS_VAR(delay);
	if (!(zephir_array_isset_string_fetch(&delay, options, SS("delay"), 0 TSRMLS_CC))) {
		ZEPHIR_INIT_NVAR(delay);
		ZVAL_LONG(delay, 0);
	}
	ZEPHIR_OBS_VAR(ttr);
	if (!(zephir_array_isset_string_fetch(&ttr, options, SS("ttr"), 0 TSRMLS_CC))) {
		ZEPHIR_INIT_NVAR(ttr);
		ZVAL_LONG(ttr, 86400);
	}
	ZEPHIR_CALL_FUNCTION(&serialized, "serialize", &_0, data);
	zephir_check_call_status();
	ZEPHIR_INIT_VAR(length);
	ZVAL_LONG(length, zephir_fast_strlen_ev(serialized));
	ZEPHIR_INIT_VAR(_1);
	ZEPHIR_CONCAT_SVSVSVSV(_1, "put ", priority, " ", delay, " ", ttr, " ", length);
	ZEPHIR_CALL_METHOD(NULL, this_ptr, "write", &_2, _1);
	zephir_check_call_status();
	ZEPHIR_CALL_METHOD(NULL, this_ptr, "write", &_2, serialized);
	zephir_check_call_status();
	ZEPHIR_CALL_METHOD(&response, this_ptr, "readstatus", &_3);
	zephir_check_call_status();
	zephir_array_fetch_long(&status, response, 0, PH_NOISY | PH_READONLY, "phalcon/queue/beanstalk.zep", 128 TSRMLS_CC);
	_4 = !ZEPHIR_IS_STRING(status, "INSERTED");
	if (_4) {
		_4 = !ZEPHIR_IS_STRING(status, "BURIED");
	}
	if (_4) {
		RETURN_MM_BOOL(0);
	}
	zephir_array_fetch_long(&_5, response, 1, PH_NOISY | PH_READONLY, "phalcon/queue/beanstalk.zep", 134 TSRMLS_CC);
	RETURN_CTOR(_5);

}
/**
 *
 * @param array rawData
 * <code> 
 *     rawData = ["service":"Demo", "method":"demo", "args": <ProtoBuffer>]
 * </code>
 * @return <ProtoBuffer>
 * @throw \Exception
 *
 */
PHP_METHOD(PhalconPlus_RPC_Server_AbstractServer, callByObject) {

	zend_bool _3;
	zephir_nts_static zephir_fcall_cache_entry *_2 = NULL;
	int ZEPHIR_LAST_CALL_STATUS;
	zval *rawData_param = NULL, *service = NULL, *method = NULL, *request, *response = NULL, *logId = NULL, *message = NULL, *_0 = NULL, *_1 = NULL, *_4, *_5 = NULL, *_6, *_7 = NULL, *_8 = NULL, *_9, *_10 = NULL;
	zval *rawData = NULL;

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

	zephir_get_arrval(rawData, rawData_param);
	ZEPHIR_INIT_VAR(logId);
	ZVAL_STRING(logId, "", 1);
	ZEPHIR_INIT_VAR(message);
	ZVAL_STRING(message, "", 1);


	ZEPHIR_OBS_VAR(service);
	if (!(zephir_array_isset_string_fetch(&service, rawData, SS("service"), 0 TSRMLS_CC))) {
		ZEPHIR_INIT_VAR(_0);
		object_init_ex(_0, zend_exception_get_default(TSRMLS_C));
		ZEPHIR_INIT_VAR(_1);
		ZEPHIR_CONCAT_SVS(_1, "service ", service, " not exists");
		ZEPHIR_CALL_METHOD(NULL, _0, "__construct", &_2, _1);
		zephir_check_call_status();
		zephir_throw_exception_debug(_0, "phalconplus/RPC/Server/AbstractServer.zep", 78 TSRMLS_CC);
		ZEPHIR_MM_RESTORE();
		return;
	}
	ZEPHIR_OBS_VAR(method);
	if (!(zephir_array_isset_string_fetch(&method, rawData, SS("method"), 0 TSRMLS_CC))) {
		ZEPHIR_INIT_NVAR(_0);
		object_init_ex(_0, zend_exception_get_default(TSRMLS_C));
		ZEPHIR_INIT_LNVAR(_1);
		ZEPHIR_CONCAT_SVS(_1, "method ", method, " not exists");
		ZEPHIR_CALL_METHOD(NULL, _0, "__construct", &_2, _1);
		zephir_check_call_status();
		zephir_throw_exception_debug(_0, "phalconplus/RPC/Server/AbstractServer.zep", 82 TSRMLS_CC);
		ZEPHIR_MM_RESTORE();
		return;
	}
	ZEPHIR_OBS_VAR(request);
	if (!(zephir_array_isset_string_fetch(&request, rawData, SS("args"), 0 TSRMLS_CC))) {
		ZEPHIR_THROW_EXCEPTION_DEBUG_STR(zend_exception_get_default(TSRMLS_C), "args not exists", "phalconplus/RPC/Server/AbstractServer.zep", 86);
		return;
	}
	ZEPHIR_INIT_NVAR(_0);
	zephir_fast_trim(_0, service, NULL , ZEPHIR_TRIM_BOTH TSRMLS_CC);
	ZEPHIR_CPY_WRT(service, _0);
	ZEPHIR_INIT_NVAR(_0);
	zephir_fast_trim(_0, method, NULL , ZEPHIR_TRIM_BOTH TSRMLS_CC);
	ZEPHIR_CPY_WRT(method, _0);
	_3 = ZEPHIR_IS_EMPTY(service);
	if (!(_3)) {
		_3 = ZEPHIR_IS_EMPTY(method);
	}
	if (_3) {
		ZEPHIR_THROW_EXCEPTION_DEBUG_STR(zend_exception_get_default(TSRMLS_C), "service:method(args) must exists. All of them!!!", "phalconplus/RPC/Server/AbstractServer.zep", 93);
		return;
	}
	ZEPHIR_OBS_NVAR(logId);
	if (zephir_array_isset_string_fetch(&logId, rawData, SS("logId"), 0 TSRMLS_CC)) {
	}
	_4 = zephir_fetch_nproperty_this(this_ptr, SL("di"), PH_NOISY_CC);
	ZEPHIR_INIT_NVAR(_0);
	ZVAL_STRING(_0, "logger", ZEPHIR_TEMP_PARAM_COPY);
	ZEPHIR_CALL_METHOD(&_5, _4, "has", NULL, _0);
	zephir_check_temp_parameter(_0);
	zephir_check_call_status();
	if (zephir_is_true(_5)) {
		ZEPHIR_INIT_NVAR(_0);
		zephir_json_encode(_0, &(_0), request, 0  TSRMLS_CC);
		ZEPHIR_INIT_NVAR(message);
		ZEPHIR_CONCAT_SVSVSVSV(message, "RPC Request - logId: ", logId, ", invoke: ", service, "::", method, ", args: ", _0);
		_6 = zephir_fetch_nproperty_this(this_ptr, SL("di"), PH_NOISY_CC);
		ZEPHIR_INIT_VAR(_8);
		ZVAL_STRING(_8, "logger", ZEPHIR_TEMP_PARAM_COPY);
		ZEPHIR_CALL_METHOD(&_7, _6, "get", NULL, _8);
		zephir_check_temp_parameter(_8);
		zephir_check_call_status();
		ZEPHIR_CALL_METHOD(NULL, _7, "log", NULL, message);
		zephir_check_call_status();
	}
	ZEPHIR_CALL_METHOD(&response, this_ptr, "callbyparams", NULL, service, method, request, rawData);
	zephir_check_call_status();
	_6 = zephir_fetch_nproperty_this(this_ptr, SL("di"), PH_NOISY_CC);
	ZEPHIR_INIT_NVAR(_0);
	ZVAL_STRING(_0, "logger", ZEPHIR_TEMP_PARAM_COPY);
	ZEPHIR_CALL_METHOD(&_7, _6, "has", NULL, _0);
	zephir_check_temp_parameter(_0);
	zephir_check_call_status();
	if (zephir_is_true(_7)) {
		ZEPHIR_INIT_NVAR(_0);
		zephir_json_encode(_0, &(_0), response, 0  TSRMLS_CC);
		ZEPHIR_INIT_NVAR(message);
		ZEPHIR_CONCAT_SVSVSVSV(message, "RPC Response - logId: ", logId, ", invoke: ", service, "::", method, ", response: ", _0);
		_9 = zephir_fetch_nproperty_this(this_ptr, SL("di"), PH_NOISY_CC);
		ZEPHIR_INIT_NVAR(_8);
		ZVAL_STRING(_8, "logger", ZEPHIR_TEMP_PARAM_COPY);
		ZEPHIR_CALL_METHOD(&_10, _9, "get", NULL, _8);
		zephir_check_temp_parameter(_8);
		zephir_check_call_status();
		ZEPHIR_CALL_METHOD(NULL, _10, "log", NULL, message);
		zephir_check_call_status();
	}
	RETURN_CCTOR(response);

}
PHP_METHOD(Auryn_AbstractCachingReflector, getParamTypeHint) {

	int ZEPHIR_LAST_CALL_STATUS;
	zval *function, *param, *lowParam, *lowClass, *lowMethod, *lowFunc, *paramCacheKey = NULL, *classCacheKey, *typeHint = NULL, *reflectionClass = NULL, *_0, *_1 = NULL, *_2, *_3, *_4;

	ZEPHIR_MM_GROW();
	zephir_fetch_params(1, 2, 0, &function, &param);



	if (!(zephir_is_instance_of(function, SL("ReflectionFunctionAbstract") TSRMLS_CC))) {
		ZEPHIR_THROW_EXCEPTION_DEBUG_STR(spl_ce_InvalidArgumentException, "Parameter 'function' must be an instance of 'ReflectionFunctionAbstract'", "", 0);
		return;
	}
	if (!(zephir_is_instance_of(param, SL("ReflectionParameter") TSRMLS_CC))) {
		ZEPHIR_THROW_EXCEPTION_DEBUG_STR(spl_ce_InvalidArgumentException, "Parameter 'param' must be an instance of 'ReflectionParameter'", "", 0);
		return;
	}
	ZEPHIR_INIT_VAR(lowParam);
	ZEPHIR_OBS_VAR(_0);
	zephir_read_property(&_0, param, SL("name"), PH_NOISY_CC);
	zephir_fast_strtolower(lowParam, _0);
	if (zephir_is_instance_of(function, SL("ReflectionMethod") TSRMLS_CC)) {
		ZEPHIR_INIT_VAR(lowClass);
		ZEPHIR_OBS_VAR(_1);
		zephir_read_property(&_1, function, SL("class"), PH_NOISY_CC);
		zephir_fast_strtolower(lowClass, _1);
		ZEPHIR_INIT_VAR(lowMethod);
		ZEPHIR_OBS_VAR(_2);
		zephir_read_property(&_2, function, SL("name"), PH_NOISY_CC);
		zephir_fast_strtolower(lowMethod, _2);
		ZEPHIR_INIT_VAR(paramCacheKey);
		ZEPHIR_CONCAT_SVSVSVSV(paramCacheKey, "auryn.refls.classes.", lowClass, ".", lowMethod, ".", param, "-", lowParam);
	} else {
		ZEPHIR_INIT_VAR(lowFunc);
		ZEPHIR_OBS_NVAR(_1);
		zephir_read_property(&_1, function, SL("name"), PH_NOISY_CC);
		zephir_fast_strtolower(lowFunc, _1);
		ZEPHIR_INIT_NVAR(paramCacheKey);
		if (!ZEPHIR_IS_STRING(lowFunc, "{closure}")) {
			ZEPHIR_CONCAT_SSVSVSV(paramCacheKey, "auryn.refls.funcs.", ".", lowFunc, ".", param, "-", lowParam);
		} else {
			ZVAL_NULL(paramCacheKey);
		}
	}
	if (Z_TYPE_P(paramCacheKey) == IS_NULL) {
		ZEPHIR_INIT_VAR(typeHint);
		ZVAL_BOOL(typeHint, 0);
	} else {
		_3 = zephir_fetch_nproperty_this(this_ptr, SL("cache"), PH_NOISY_CC);
		ZEPHIR_CALL_METHOD(&typeHint, _3, "fetch", NULL, paramCacheKey);
		zephir_check_call_status();
	}
	if (!ZEPHIR_IS_FALSE(typeHint)) {
		RETURN_CCTOR(typeHint);
	}
	ZEPHIR_CALL_METHOD(&reflectionClass, param, "getclass",  NULL);
	zephir_check_call_status();
	if (zephir_is_true(reflectionClass)) {
		ZEPHIR_CALL_METHOD(&typeHint, reflectionClass, "getname",  NULL);
		zephir_check_call_status();
		ZEPHIR_INIT_VAR(_4);
		zephir_fast_strtolower(_4, typeHint);
		ZEPHIR_INIT_VAR(classCacheKey);
		ZEPHIR_CONCAT_SV(classCacheKey, "auryn.refls.classes.", _4);
		_3 = zephir_fetch_nproperty_this(this_ptr, SL("cache"), PH_NOISY_CC);
		ZEPHIR_CALL_METHOD(NULL, _3, "store", NULL, classCacheKey, reflectionClass);
		zephir_check_call_status();
	} else {
		ZEPHIR_INIT_NVAR(typeHint);
		ZVAL_NULL(typeHint);
	}
	_3 = zephir_fetch_nproperty_this(this_ptr, SL("cache"), PH_NOISY_CC);
	ZEPHIR_CALL_METHOD(NULL, _3, "store", NULL, paramCacheKey, typeHint);
	zephir_check_call_status();
	RETURN_CCTOR(typeHint);

}