예제 #1
0
/**
 * Magic function so that $obj->value will work.
 *
 * @param string $name
 * @return mixed
 */
PHP_METHOD(Yaf_Session, __get) {

    zval *name_param = NULL, *result = NULL, *_0, *_1, *_SESSION;
    zval *name = NULL;

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

    zephir_get_strval(name, name_param);


    ZEPHIR_INIT_VAR(result);
    ZVAL_NULL(result);
    if (ZEPHIR_IS_STRING(name, "")) {
        RETURN_MM_NULL();
    }
    _0 = zephir_fetch_nproperty_this(this_ptr, SL("session"), PH_NOISY_CC);
    if (zephir_array_key_exists(_0, name TSRMLS_CC)) {
        _1 = zephir_fetch_nproperty_this(this_ptr, SL("session"), PH_NOISY_CC);
        ZEPHIR_OBS_NVAR(result);
        zephir_array_fetch(&result, _1, name, PH_NOISY, "yaf/session.zep", 81 TSRMLS_CC);
    } else {
        zephir_get_global(&_SESSION, SS("_SESSION") TSRMLS_CC);
        if (zephir_array_key_exists(_SESSION, name TSRMLS_CC)) {
            zephir_get_global(&_SESSION, SS("_SESSION") TSRMLS_CC);
            ZEPHIR_OBS_NVAR(result);
            zephir_array_fetch(&result, _SESSION, name, PH_NOISY, "yaf/session.zep", 85 TSRMLS_CC);
        }
    }
    RETURN_CCTOR(result);

}
예제 #2
0
/**
 * @param string id
 */
PHP_METHOD(Dgafka_BookStore_Application_InMemory_Repository_Command_BookRepository, findById) {

	zval *id_param = NULL, *_0, *_1, *_2;
	zval *id = NULL;

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

	zephir_get_strval(id, id_param);


	_0 = zephir_fetch_static_property_ce(dgafka_bookstore_application_inmemory_repository_command_bookrepository_ce, SL("books") TSRMLS_CC);
	if (!(zephir_array_key_exists(_0, id TSRMLS_CC))) {
		RETURN_MM_NULL();
	}
	_1 = zephir_fetch_static_property_ce(dgafka_bookstore_application_inmemory_repository_command_bookrepository_ce, SL("books") TSRMLS_CC);
	zephir_array_fetch(&_2, _1, id, PH_NOISY | PH_READONLY, "dgafka/bookStore/application/inMemory/repository/command/bookRepository.zep", 44 TSRMLS_CC);
	RETURN_CTOR(_2);

}
예제 #3
0
/**
 * Get the protocol used by the app - http|https
 *
 * @return string
 */
PHP_METHOD(Phady_Util_Tools, getRequestProtocol) {

	zval *_SERVER, *_1, _2, *_4, _6, *_8, _10, *_12, *_14, *_15;
	zend_bool isSecure = 0, _0, _3, _5, _7, _9, _11, _13;

	ZEPHIR_MM_GROW();
	zephir_get_global(&_SERVER, SS("_SERVER") TSRMLS_CC);

	_0 = zephir_array_isset_string(_SERVER, SS("HTTPS"));
	if (_0) {
		zephir_array_fetch_string(&_1, _SERVER, SL("HTTPS"), PH_NOISY | PH_READONLY, "phady/util/tools.zep", 66 TSRMLS_CC);
		_0 = ZEPHIR_IS_STRING(_1, "on");
	}
	ZEPHIR_SINIT_VAR(_2);
	ZVAL_STRING(&_2, "HTTP_X_FORWARDED_PROTO", 0);
	_3 = zephir_array_key_exists(_SERVER, &_2 TSRMLS_CC);
	if (_3) {
		ZEPHIR_OBS_VAR(_4);
		zephir_array_fetch_string(&_4, _SERVER, SL("HTTP_X_FORWARDED_PROTO"), PH_NOISY, "phady/util/tools.zep", 68 TSRMLS_CC);
		_3 = !(ZEPHIR_IS_EMPTY(_4));
	}
	_5 = _3;
	if (_5) {
		ZEPHIR_SINIT_VAR(_6);
		ZVAL_STRING(&_6, "HTTP_X_FORWARDED_PROTO", 0);
		_7 = zephir_array_key_exists(_SERVER, &_6 TSRMLS_CC);
		if (_7) {
			zephir_array_fetch_string(&_8, _SERVER, SL("HTTP_X_FORWARDED_PROTO"), PH_NOISY | PH_READONLY, "phady/util/tools.zep", 69 TSRMLS_CC);
			_7 = ZEPHIR_IS_STRING(_8, "https");
		}
		_5 = _7;
	}
	_9 = _5;
	if (!(_9)) {
		ZEPHIR_SINIT_VAR(_10);
		ZVAL_STRING(&_10, "HTTP_X_FORWARDED_SSL", 0);
		_11 = zephir_array_key_exists(_SERVER, &_10 TSRMLS_CC);
		if (_11) {
			ZEPHIR_OBS_VAR(_12);
			zephir_array_fetch_string(&_12, _SERVER, SL("HTTP_X_FORWARDED_SSL"), PH_NOISY, "phady/util/tools.zep", 70 TSRMLS_CC);
			_11 = !(ZEPHIR_IS_EMPTY(_12));
		}
		_13 = _11;
		if (_13) {
			zephir_array_fetch_string(&_14, _SERVER, SL("HTTP_X_FORWARDED_SSL"), PH_NOISY | PH_READONLY, "phady/util/tools.zep", 71 TSRMLS_CC);
			_13 = ZEPHIR_IS_STRING(_14, "on");
		}
		_9 = _13;
	}
	if (_0) {
		isSecure = 1;
	} else if (_9) {
		isSecure = 1;
	}
	ZEPHIR_INIT_VAR(_15);
	if (isSecure) {
		ZVAL_STRING(_15, "http", 1);
	} else {
		ZVAL_STRING(_15, "https", 1);
	}
	RETURN_CCTOR(_15);

}
예제 #4
0
/**
 * @todo this method can be write differently with (P< style match
 * Matches a user submitted path with parts defined by a map. Assigns and
 * returns an array of variables on a successful match.
 *
 * @param string $path Path used to match against this routing map
 * @return array|false An array of assigned values or a false on a mismatch
 */
PHP_METHOD(Yaf_Route_Rewrite, _match) {

	zephir_nts_static zephir_fcall_cache_entry *_27 = NULL, *_33 = NULL;
	zend_bool _12, _28, _32;
	HashTable *_7, *_22, *_35;
	HashPosition _6, _21, _34;
	int staticCount, pathStaticCount, ZEPHIR_LAST_CALL_STATUS;
	zval *path_param = NULL, *values, *matchedPath = NULL, *parts, *variables, *wildcardData, *name = NULL, *part = NULL, *pos = NULL, *pathMatch, *count = NULL, *i = NULL, *varr = NULL, *pathPart = NULL, *tmpReturn = NULL, *_0, *_1 = NULL, *_2 = NULL, *_3, _4 = zval_used_for_init, _5 = zval_used_for_init, **_8, _9 = zval_used_for_init, _10 = zval_used_for_init, *_11 = NULL, _13 = zval_used_for_init, _14 = zval_used_for_init, *_15 = NULL, _16 = zval_used_for_init, _17 = zval_used_for_init, *_18 = NULL, _19 = zval_used_for_init, *_20 = NULL, **_23, *_24 = NULL, *_25, *_26, *_29 = NULL, *_30, *_31 = NULL, **_36;
	zval *path = NULL;

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

	zephir_get_strval(path, path_param);


	staticCount = 0;
	pathStaticCount = 0;
	ZEPHIR_INIT_VAR(values);
	array_init(values);
	ZEPHIR_INIT_VAR(matchedPath);
	ZVAL_STRING(matchedPath, "", 1);
	ZEPHIR_INIT_VAR(parts);
	array_init(parts);
	ZEPHIR_INIT_VAR(variables);
	array_init(variables);
	ZEPHIR_INIT_VAR(wildcardData);
	array_init(wildcardData);
	_0 = zephir_fetch_nproperty_this(this_ptr, SL("_route"), PH_NOISY_CC);
	if (!ZEPHIR_IS_STRING_IDENTICAL(_0, "")) {
		ZEPHIR_INIT_VAR(_1);
		ZEPHIR_INIT_VAR(_2);
		_3 = zephir_fetch_nproperty_this(this_ptr, SL("_route"), PH_NOISY_CC);
		ZEPHIR_SINIT_VAR(_4);
		ZVAL_STRING(&_4, "/", 0);
		zephir_fast_trim(_2, _3, &_4, ZEPHIR_TRIM_BOTH TSRMLS_CC);
		ZEPHIR_SINIT_VAR(_5);
		ZVAL_STRING(&_5, "/", 0);
		zephir_fast_explode(_1, &_5, _2, LONG_MAX TSRMLS_CC);
		zephir_is_iterable(_1, &_7, &_6, 0, 0, "yaf/Route/rewrite.zep", 135);
		for (
		  ; zephir_hash_get_current_data_ex(_7, (void**) &_8, &_6) == SUCCESS
		  ; zephir_hash_move_forward_ex(_7, &_6)
		) {
			ZEPHIR_GET_HMKEY(pos, _7, _6);
			ZEPHIR_GET_HVALUE(part, _8);
			ZEPHIR_SINIT_NVAR(_9);
			ZVAL_LONG(&_9, 0);
			ZEPHIR_SINIT_NVAR(_10);
			ZVAL_LONG(&_10, 1);
			ZEPHIR_INIT_NVAR(_11);
			zephir_substr(_11, part, 0 , 1 , 0);
			_12 = ZEPHIR_IS_STRING(_11, ":");
			if (_12) {
				ZEPHIR_SINIT_NVAR(_13);
				ZVAL_LONG(&_13, 1);
				ZEPHIR_SINIT_NVAR(_14);
				ZVAL_LONG(&_14, 1);
				ZEPHIR_INIT_NVAR(_15);
				zephir_substr(_15, part, 1 , 1 , 0);
				_12 = !ZEPHIR_IS_STRING(_15, ":");
			}
			if (_12) {
				ZEPHIR_SINIT_NVAR(_16);
				ZVAL_LONG(&_16, 1);
				ZEPHIR_INIT_NVAR(name);
				zephir_substr(name, part, 1 , 0, ZEPHIR_SUBSTR_NO_LENGTH);
				zephir_array_update_zval(&parts, pos, &ZEPHIR_GLOBAL(global_null), PH_COPY | PH_SEPARATE);
				zephir_array_update_zval(&variables, pos, &name, PH_COPY | PH_SEPARATE);
			} else {
				ZEPHIR_SINIT_NVAR(_16);
				ZVAL_LONG(&_16, 0);
				ZEPHIR_SINIT_NVAR(_17);
				ZVAL_LONG(&_17, 1);
				ZEPHIR_INIT_NVAR(_18);
				zephir_substr(_18, part, 0 , 1 , 0);
				if (ZEPHIR_IS_STRING(_18, ":")) {
					ZEPHIR_SINIT_NVAR(_19);
					ZVAL_LONG(&_19, 1);
					ZEPHIR_INIT_NVAR(_20);
					zephir_substr(_20, part, 1 , 0, ZEPHIR_SUBSTR_NO_LENGTH);
					ZEPHIR_CPY_WRT(part, _20);
				}
				zephir_array_update_zval(&parts, pos, &part, PH_COPY | PH_SEPARATE);
				if (!ZEPHIR_IS_STRING_IDENTICAL(part, "*")) {
					staticCount++;
				}
			}
		}
	}
	if (!ZEPHIR_IS_STRING_IDENTICAL(path, "")) {
		ZEPHIR_INIT_VAR(pathMatch);
		ZEPHIR_SINIT_NVAR(_4);
		ZVAL_STRING(&_4, "/", 0);
		zephir_fast_explode(pathMatch, &_4, path, LONG_MAX TSRMLS_CC);
		zephir_is_iterable(pathMatch, &_22, &_21, 0, 0, "yaf/Route/rewrite.zep", 193);
		for (
		  ; zephir_hash_get_current_data_ex(_22, (void**) &_23, &_21) == SUCCESS
		  ; zephir_hash_move_forward_ex(_22, &_21)
		) {
			ZEPHIR_GET_HMKEY(pos, _22, _21);
			ZEPHIR_GET_HVALUE(pathPart, _23);
			if (!(zephir_array_key_exists(parts, pos TSRMLS_CC))) {
				RETURN_MM_BOOL(0);
			}
			ZEPHIR_INIT_LNVAR(_24);
			ZEPHIR_CONCAT_VS(_24, pathPart, "/");
			zephir_concat_self(&matchedPath, _24 TSRMLS_CC);
			zephir_array_fetch(&_25, parts, pos, PH_NOISY | PH_READONLY, "yaf/Route/rewrite.zep", 150 TSRMLS_CC);
			if (ZEPHIR_IS_STRING(_25, "*")) {
				ZEPHIR_INIT_NVAR(count);
				ZVAL_LONG(count, zephir_fast_count_int(pathMatch TSRMLS_CC));
				ZEPHIR_CPY_WRT(i, pos);
				while (1) {
					if (!(ZEPHIR_LT(i, count))) {
						break;
					}
					zephir_array_fetch(&_26, pathMatch, i, PH_NOISY | PH_READONLY, "yaf/Route/rewrite.zep", 154 TSRMLS_CC);
					ZEPHIR_CALL_FUNCTION(&varr, "urldecode", &_27, _26);
					zephir_check_call_status();
					_12 = !(zephir_array_isset(wildcardData, varr));
					if (_12) {
						_3 = zephir_fetch_nproperty_this(this_ptr, SL("_default"), PH_NOISY_CC);
						_12 = !(zephir_array_isset(_3, varr));
					}
					_28 = _12;
					if (_28) {
						_28 = !(zephir_array_isset(values, varr));
					}
					if (_28) {
						ZEPHIR_INIT_LNVAR(_29);
						if (zephir_array_isset_long(pathMatch, (zephir_get_numberval(i) + 1))) {
							zephir_array_fetch_long(&_30, pathMatch, (zephir_get_numberval(i) + 1), PH_NOISY | PH_READONLY, "yaf/Route/rewrite.zep", 157 TSRMLS_CC);
							ZEPHIR_CALL_FUNCTION(&_29, "urldecode", &_27, _30);
							zephir_check_call_status();
						} else {
							ZEPHIR_INIT_NVAR(_29);
							ZVAL_NULL(_29);
						}
						zephir_array_update_zval(&wildcardData, varr, &_29, PH_COPY | PH_SEPARATE);
					}
					ZEPHIR_INIT_NVAR(_1);
					ZVAL_LONG(_1, 2);
					ZEPHIR_ADD_ASSIGN(i, _1);
				}
				ZEPHIR_INIT_NVAR(matchedPath);
				ZEPHIR_SINIT_NVAR(_5);
				ZVAL_STRING(&_5, "/", 0);
				zephir_fast_join(matchedPath, &_5, pathMatch TSRMLS_CC);
				break;
			}
			if (zephir_array_isset(variables, pos)) {
				ZEPHIR_OBS_NVAR(name);
				zephir_array_fetch(&name, variables, pos, PH_NOISY, "yaf/Route/rewrite.zep", 165 TSRMLS_CC);
			} else {
				ZEPHIR_INIT_NVAR(name);
				ZVAL_NULL(name);
			}
			ZEPHIR_CALL_FUNCTION(&_31, "urldecode", &_27, pathPart);
			zephir_check_call_status();
			ZEPHIR_CPY_WRT(pathPart, _31);
			ZEPHIR_OBS_NVAR(part);
			zephir_array_fetch(&part, parts, pos, PH_NOISY, "yaf/Route/rewrite.zep", 167 TSRMLS_CC);
			ZEPHIR_SINIT_NVAR(_9);
			ZVAL_LONG(&_9, 0);
			ZEPHIR_SINIT_NVAR(_10);
			ZVAL_LONG(&_10, 2);
			ZEPHIR_INIT_NVAR(_2);
			zephir_substr(_2, part, 0 , 2 , 0);
			if (ZEPHIR_IS_STRING_IDENTICAL(_2, "@@")) {
				ZEPHIR_SINIT_NVAR(_13);
				ZVAL_LONG(&_13, 1);
				ZEPHIR_INIT_NVAR(_11);
				zephir_substr(_11, part, 1 , 0, ZEPHIR_SUBSTR_NO_LENGTH);
				ZEPHIR_CPY_WRT(part, _11);
			}
			_28 = Z_TYPE_P(name) == IS_NULL;
			if (_28) {
				_28 = !ZEPHIR_IS_EQUAL(part, pathPart);
			}
			if (_28) {
				RETURN_MM_BOOL(0);
			}
			_32 = Z_TYPE_P(part) != IS_NULL;
			if (_32) {
				ZEPHIR_INIT_LNVAR(_29);
				ZEPHIR_CONCAT_VSSS(_29, part, "#^", "$#", "iu");
				ZEPHIR_CALL_FUNCTION(&_31, "preg_match", &_33, _29, pathPart);
				zephir_check_call_status();
				_32 = !zephir_is_true(_31);
			}
			if (_32) {
				RETURN_MM_BOOL(0);
			}
			if (Z_TYPE_P(name) != IS_NULL) {
				zephir_array_update_zval(&values, name, &pathPart, PH_COPY | PH_SEPARATE);
			} else {
				pathStaticCount++;
			}
		}
	}
	if (staticCount != pathStaticCount) {
		RETURN_MM_BOOL(0);
	}
	ZEPHIR_INIT_VAR(tmpReturn);
	zephir_add_function_ex(tmpReturn, values, wildcardData TSRMLS_CC);
	zephir_is_iterable(variables, &_35, &_34, 0, 0, "yaf/Route/rewrite.zep", 212);
	for (
	  ; zephir_hash_get_current_data_ex(_35, (void**) &_36, &_34) == SUCCESS
	  ; zephir_hash_move_forward_ex(_35, &_34)
	) {
		ZEPHIR_GET_HVALUE(varr, _36);
		if (!(zephir_array_key_exists(tmpReturn, varr TSRMLS_CC))) {
			RETURN_MM_BOOL(0);
		}
	}
	_12 = Z_TYPE_P(values) == IS_NULL;
	if (_12) {
		_12 = Z_TYPE_P(wildcardData) == IS_NULL;
	}
	_32 = _12;
	if (_32) {
		_32 = staticCount != 0;
	}
	if (_32) {
		_3 = zephir_fetch_nproperty_this(this_ptr, SL("_default"), PH_NOISY_CC);
		ZEPHIR_INIT_LNVAR(_24);
		zephir_add_function_ex(_24, tmpReturn, _3 TSRMLS_CC);
		ZEPHIR_CPY_WRT(tmpReturn, _24);
	}
	RETURN_CCTOR(tmpReturn);

}