Exemple #1
0
PHP_METHOD(Test_NativeArray, testArrayMultipleAccess4) {

	zval *_0, *_1;
	zval *a, *b, *_2, *_3, *_4;

	ZEPHIR_MM_GROW();

	ZEPHIR_INIT_VAR(a);
	array_init_size(a, 2);
	ZEPHIR_INIT_VAR(_0);
	array_init_size(_0, 2);
	ZEPHIR_INIT_VAR(_1);
	array_init_size(_1, 3);
	ZEPHIR_INIT_VAR(_2);
	ZVAL_STRING(_2, "a", 1);
	zephir_array_fast_append(_1, _2);
	ZEPHIR_INIT_BNVAR(_2);
	ZVAL_STRING(_2, "b", 1);
	zephir_array_fast_append(_1, _2);
	zephir_array_fast_append(_0, _1);
	zephir_array_fast_append(a, _0);
	zephir_array_fetch_long(&_3, a, 0, PH_NOISY | PH_READONLY TSRMLS_CC);
	zephir_array_fetch_long(&_4, _3, 0, PH_NOISY | PH_READONLY TSRMLS_CC);
	zephir_array_fetch_long(&b, _4, 1, PH_NOISY | PH_READONLY TSRMLS_CC);
	RETURN_CTOR(b);

}
Exemple #2
0
/**
 * Phalcon\Acl\Adapter\Memory constructor
 */
PHP_METHOD(Phalcon_Acl_Adapter_Memory, __construct){

	zval *a0 = NULL, *a1 = NULL, *a2 = NULL;

	PHALCON_MM_GROW();

	phalcon_update_property_empty_array(phalcon_acl_adapter_memory_ce, this_ptr, SL("_rolesNames") TSRMLS_CC);
	
	phalcon_update_property_empty_array(phalcon_acl_adapter_memory_ce, this_ptr, SL("_roles") TSRMLS_CC);
	
	phalcon_update_property_empty_array(phalcon_acl_adapter_memory_ce, this_ptr, SL("_resources") TSRMLS_CC);
	
	phalcon_update_property_empty_array(phalcon_acl_adapter_memory_ce, this_ptr, SL("_access") TSRMLS_CC);
	
	phalcon_update_property_empty_array(phalcon_acl_adapter_memory_ce, this_ptr, SL("_roleInherits") TSRMLS_CC);
	
	PHALCON_INIT_VAR(a0);
	array_init_size(a0, 1);
	add_assoc_bool_ex(a0, SS("*"), 1);
	zend_update_property(phalcon_acl_adapter_memory_ce, this_ptr, SL("_resourcesNames"), a0 TSRMLS_CC);
	
	PHALCON_INIT_VAR(a1);
	array_init_size(a1, 1);
	
	PHALCON_INIT_VAR(a2);
	array_init_size(a2, 1);
	add_assoc_bool_ex(a2, SS("*"), 1);
	phalcon_array_update_string(&a1, SL("*"), &a2, PH_COPY | PH_SEPARATE TSRMLS_CC);
	zend_update_property(phalcon_acl_adapter_memory_ce, this_ptr, SL("_accessList"), a1 TSRMLS_CC);
	

	PHALCON_MM_RESTORE();
}
Exemple #3
0
PHP_METHOD(Test_Oo_PropertyAccess, __construct) {

	zval *test, *test1, *_0, *_1, *_2, *_3, *_4, *_5, *_6, *_7 = NULL, *_8, *_9;

	ZEPHIR_MM_GROW();

	ZEPHIR_INIT_VAR(test);
	object_init(test);
	ZEPHIR_INIT_VAR(_0);
	array_init_size(_0, 6);
	ZEPHIR_INIT_VAR(_1);
	ZVAL_LONG(_1, 1);
	zephir_array_fast_append(_0, _1);
	ZEPHIR_INIT_BNVAR(_1);
	ZVAL_LONG(_1, 2);
	zephir_array_fast_append(_0, _1);
	ZEPHIR_INIT_BNVAR(_1);
	ZVAL_LONG(_1, 3);
	zephir_array_fast_append(_0, _1);
	ZEPHIR_INIT_BNVAR(_1);
	ZVAL_LONG(_1, 5);
	zephir_array_fast_append(_0, _1);
	ZEPHIR_INIT_BNVAR(_1);
	ZVAL_DOUBLE(_1, 6.00);
	zephir_array_fast_append(_0, _1);
	zephir_update_property_zval(test, SL("test"), _0 TSRMLS_CC);
	ZEPHIR_OBS_VAR(_2);
	zephir_read_property(&_2, test, SL("test"), PH_NOISY_CC);
	zephir_array_fetch_long(&_3, _2, 0, PH_NOISY | PH_READONLY TSRMLS_CC);
	zephir_update_property_zval(test, SL("test2"), _3 TSRMLS_CC);
	ZEPHIR_OBS_VAR(_4);
	zephir_read_property(&_4, test, SL("test"), PH_NOISY_CC);
	zephir_array_fetch_long(&_5, _4, 1, PH_NOISY | PH_READONLY TSRMLS_CC);
	zephir_update_property_zval(test, SL("test3"), _5 TSRMLS_CC);
	ZEPHIR_INIT_BNVAR(_1);
	array_init_size(_1, 5);
	ZEPHIR_OBS_VAR(_6);
	zephir_read_property(&_6, test, SL("test"), PH_NOISY_CC);
	ZEPHIR_OBS_VAR(_7);
	zephir_array_fetch_long(&_7, _6, 1, PH_NOISY TSRMLS_CC);
	zephir_array_fast_append(_1, _7);
	ZEPHIR_INIT_VAR(_8);
	ZVAL_LONG(_8, 1);
	zephir_array_fast_append(_1, _8);
	ZEPHIR_INIT_BNVAR(_8);
	ZVAL_LONG(_8, 2);
	zephir_array_fast_append(_1, _8);
	ZEPHIR_INIT_BNVAR(_8);
	ZVAL_LONG(_8, 3);
	zephir_array_fast_append(_1, _8);
	zephir_update_property_zval(test, SL("test3"), _1 TSRMLS_CC);
	zephir_update_property_this(this_ptr, SL("a"), test TSRMLS_CC);
	_9 = zephir_fetch_nproperty_this(this_ptr, SL("a"), PH_NOISY_CC);
	ZEPHIR_OBS_NVAR(_7);
	zephir_read_property(&_7, _9, SL("test2"), PH_NOISY_CC);
	zephir_update_property_this(this_ptr, SL("b"), _7 TSRMLS_CC);
	test1 = zephir_fetch_nproperty_this(this_ptr, SL("a"), PH_NOISY_CC);
	ZEPHIR_MM_RESTORE();

}
Exemple #4
0
PHP_METHOD(Test_Properties_PropertyArray, __construct) {

	zval *_1, *_3;
	zval *_0, *_2;

	ZEPHIR_MM_GROW();

	ZEPHIR_INIT_VAR(_0);
	array_init_size(_0, 7);
	ZEPHIR_INIT_VAR(_1);
	ZVAL_LONG(_1, 1);
	zephir_array_fast_append(_0, _1);
	ZEPHIR_INIT_BNVAR(_1);
	ZVAL_LONG(_1, 2);
	zephir_array_fast_append(_0, _1);
	ZEPHIR_INIT_BNVAR(_1);
	ZVAL_LONG(_1, 3);
	zephir_array_fast_append(_0, _1);
	ZEPHIR_INIT_BNVAR(_1);
	ZVAL_LONG(_1, 4);
	zephir_array_fast_append(_0, _1);
	zephir_update_property_this(this_ptr, SL("someArray"), _0 TSRMLS_CC);
	ZEPHIR_INIT_BNVAR(_1);
	array_init(_1);
	zephir_update_property_this(this_ptr, SL("someEmptyArray"), _1 TSRMLS_CC);
	ZEPHIR_INIT_VAR(_2);
	array_init_size(_2, 2);
	ZEPHIR_INIT_VAR(_3);
	ZVAL_LONG(_3, 1);
	zephir_array_fast_append(_2, _3);
	zephir_update_property_this(this_ptr, SL("someArray"), _2 TSRMLS_CC);
	ZEPHIR_MM_RESTORE();

}
Exemple #5
0
PHP_METHOD(Test_NativeArray, testArray12) {

	zval *a, *b, *c, *_0;

	ZEPHIR_MM_GROW();

	ZEPHIR_INIT_VAR(a);
	array_init_size(a, 5);
	ZEPHIR_INIT_VAR(_0);
	ZVAL_LONG(_0, 1);
	zephir_array_fast_append(a, _0);
	ZEPHIR_INIT_BNVAR(_0);
	ZVAL_LONG(_0, 2);
	zephir_array_fast_append(a, _0);
	ZEPHIR_INIT_BNVAR(_0);
	ZVAL_LONG(_0, 3);
	zephir_array_fast_append(a, _0);
	ZEPHIR_INIT_VAR(b);
	array_init_size(b, 2);
	zephir_array_fast_append(b, a);
	ZEPHIR_INIT_VAR(c);
	array_init_size(c, 2);
	zephir_array_fast_append(c, b);
	RETURN_CCTOR(c);

}
Exemple #6
0
PHP_METHOD(Test_NativeArray, testArrayUpdate5) {

	zval *_1, *_2, *_3;
	zval *a, *_0;

	ZEPHIR_MM_GROW();

	ZEPHIR_INIT_VAR(a);
	array_init_size(a, 5);
	ZEPHIR_INIT_VAR(_0);
	ZVAL_LONG(_0, 1);
	zephir_array_fast_append(a, _0);
	ZEPHIR_INIT_BNVAR(_0);
	ZVAL_LONG(_0, 2);
	zephir_array_fast_append(a, _0);
	ZEPHIR_INIT_BNVAR(_0);
	ZVAL_LONG(_0, 3);
	zephir_array_fast_append(a, _0);
	ZEPHIR_INIT_VAR(_1);
	array_init_size(_1, 5);
	ZEPHIR_INIT_BNVAR(_0);
	ZVAL_LONG(_0, 1);
	zephir_array_fast_append(_1, _0);
	ZEPHIR_INIT_BNVAR(_0);
	ZVAL_LONG(_0, 2);
	zephir_array_fast_append(_1, _0);
	ZEPHIR_INIT_BNVAR(_0);
	ZVAL_LONG(_0, 3);
	zephir_array_fast_append(_1, _0);
	zephir_array_update_long(&a, 0, &_1, PH_COPY | PH_SEPARATE, "test/nativearray.zep", 396);
	ZEPHIR_INIT_VAR(_2);
	array_init_size(_2, 5);
	ZEPHIR_INIT_BNVAR(_0);
	ZVAL_LONG(_0, 1);
	zephir_array_fast_append(_2, _0);
	ZEPHIR_INIT_BNVAR(_0);
	ZVAL_LONG(_0, 2);
	zephir_array_fast_append(_2, _0);
	ZEPHIR_INIT_BNVAR(_0);
	ZVAL_LONG(_0, 3);
	zephir_array_fast_append(_2, _0);
	zephir_array_update_long(&a, 1, &_2, PH_COPY | PH_SEPARATE, "test/nativearray.zep", 397);
	ZEPHIR_INIT_VAR(_3);
	array_init_size(_3, 5);
	ZEPHIR_INIT_BNVAR(_0);
	ZVAL_LONG(_0, 1);
	zephir_array_fast_append(_3, _0);
	ZEPHIR_INIT_BNVAR(_0);
	ZVAL_LONG(_0, 2);
	zephir_array_fast_append(_3, _0);
	ZEPHIR_INIT_BNVAR(_0);
	ZVAL_LONG(_0, 3);
	zephir_array_fast_append(_3, _0);
	zephir_array_update_long(&a, 2, &_3, PH_COPY | PH_SEPARATE, "test/nativearray.zep", 398);
	RETURN_CCTOR(a);

}
Exemple #7
0
/**
 * Adds a join to the query
 *
 *<code>
 *	$criteria->join('Robots');
 *	$criteria->join('Robots', 'r.id = RobotsParts.robots_id');
 *	$criteria->join('Robots', 'r.id = RobotsParts.robots_id', 'r');
 *	$criteria->join('Robots', 'r.id = RobotsParts.robots_id', 'r', 'LEFT');
 *</code>
 *
 * @param string $model
 * @param string $conditions
 * @param string $alias
 * @param string $type
 * @return Phalcon\Mvc\Model\CriteriaInterface
 */
PHP_METHOD(Phalcon_Mvc_Model_Criteria, join){

	zval *model, *conditions = NULL, *alias = NULL, *type = NULL, *new_join, *params;
	zval *current_joins, *merged_joins = NULL, *new_join_array = NULL;

	PHALCON_MM_GROW();

	phalcon_fetch_params(1, 1, 3, &model, &conditions, &alias, &type);
	
	if (!conditions) {
		conditions = PHALCON_GLOBAL(z_null);
	}
	
	if (!alias) {
		alias = PHALCON_GLOBAL(z_null);
	}
	
	if (!type) {
		type = PHALCON_GLOBAL(z_null);
	}
	
	PHALCON_INIT_VAR(new_join);
	array_init_size(new_join, 4);
	phalcon_array_append(&new_join, model, 0);
	phalcon_array_append(&new_join, conditions, 0);
	phalcon_array_append(&new_join, alias, 0);
	phalcon_array_append(&new_join, type, 0);
	
	PHALCON_OBS_VAR(params);
	phalcon_read_property_this(&params, this_ptr, SL("_params"), PH_NOISY TSRMLS_CC);
	if (phalcon_array_isset_string(params, SS("joins"))) {
		
		PHALCON_INIT_VAR(new_join_array);
		array_init_size(new_join_array, 1);
		phalcon_array_append(&new_join_array, new_join, 0);

		PHALCON_OBS_VAR(current_joins);
		phalcon_array_fetch_string(&current_joins, params, SL("joins"), PH_NOISY);
		if (Z_TYPE_P(current_joins) == IS_ARRAY) { 
			PHALCON_INIT_VAR(merged_joins);
			phalcon_fast_array_merge(merged_joins, &current_joins, &new_join_array TSRMLS_CC);
		} else {
			PHALCON_CPY_WRT(merged_joins, new_join_array);
		}
	} else {
		PHALCON_INIT_NVAR(merged_joins);
		array_init_size(merged_joins, 1);
		phalcon_array_append(&merged_joins, new_join, 0);
	}
	
	phalcon_update_property_array_string(this_ptr, SL("_params"), SS("joins"), merged_joins TSRMLS_CC);
	
	RETURN_THIS();
}
Exemple #8
0
/**
 * Test\Router constructor
 *
 * @param boolean defaultRoutes
 */
PHP_METHOD(Test_Router, __construct) {

	zephir_fcall_cache_entry *_3 = NULL;
	int ZEPHIR_LAST_CALL_STATUS;
	zval *_1, *_5;
	zval *defaultRoutes_param = NULL, *routes, *_0, *_2 = NULL, *_4;
	zend_bool defaultRoutes;

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

	if (!defaultRoutes_param) {
		defaultRoutes = 1;
	} else {
		defaultRoutes = zephir_get_boolval(defaultRoutes_param);
	}


	ZEPHIR_INIT_VAR(routes);
	array_init(routes);
	if ((defaultRoutes == 1)) {
		ZEPHIR_INIT_VAR(_0);
		object_init_ex(_0, test_router_route_ce);
		ZEPHIR_INIT_VAR(_1);
		array_init_size(_1, 2);
		add_assoc_long_ex(_1, SS("controller"), 1);
		ZEPHIR_INIT_VAR(_2);
		ZVAL_STRING(_2, "#^/([a-zA-Z0-9\\_\\-]+)[/]{0,1}$#", 0);
		ZEPHIR_CALL_METHOD(NULL, _0, "__construct", &_3, _2, _1);
		zephir_check_temp_parameter(_2);
		zephir_check_call_status();
		zephir_array_append(&routes, _0, PH_SEPARATE);
		ZEPHIR_INIT_VAR(_4);
		object_init_ex(_4, test_router_route_ce);
		ZEPHIR_INIT_VAR(_5);
		array_init_size(_5, 5);
		add_assoc_long_ex(_5, SS("controller"), 1);
		add_assoc_long_ex(_5, SS("action"), 2);
		add_assoc_long_ex(_5, SS("params"), 3);
		ZEPHIR_INIT_NVAR(_2);
		ZVAL_STRING(_2, "#^/([a-zA-Z0-9\\_\\-]+)/([a-zA-Z0-9\\.\\_]+)(/.*)*$#", 0);
		ZEPHIR_CALL_METHOD(NULL, _4, "__construct", &_3, _2, _5);
		zephir_check_temp_parameter(_2);
		zephir_check_call_status();
		zephir_array_append(&routes, _4, PH_SEPARATE);
	}
	ZEPHIR_INIT_NVAR(_2);
	array_init(_2);
	zephir_update_property_this(this_ptr, SL("_params"), _2 TSRMLS_CC);
	zephir_update_property_this(this_ptr, SL("_routes"), routes TSRMLS_CC);
	ZEPHIR_MM_RESTORE();

}
PHP_METHOD(OAuth2_ResponseType_AuthorizationCode, getAuthorizeResponse) {

	int ZEPHIR_LAST_CALL_STATUS;
	zval *_1;
	zval *user_id = NULL;
	zval *params = NULL, *user_id_param = NULL, *result, *_0 = NULL, *_2 = NULL, *_3, *_4, *_5, *_6, *_7;

	ZEPHIR_MM_GROW();
	zephir_fetch_params(1, 1, 1, &params, &user_id_param);

	ZEPHIR_SEPARATE_PARAM(params);
	if (!user_id_param) {
		ZEPHIR_INIT_VAR(user_id);
		ZVAL_EMPTY_STRING(user_id);
	} else {
		zephir_get_strval(user_id, user_id_param);
	}


	ZEPHIR_INIT_VAR(result);
	array_init_size(result, 2);
	ZEPHIR_INIT_VAR(_0);
	array_init(_0);
	zephir_array_update_string(&result, SL("query"), &_0, PH_COPY | PH_SEPARATE);
	ZEPHIR_INIT_NVAR(_0);
	ZEPHIR_INIT_VAR(_1);
	array_init_size(_1, 3);
	zephir_array_update_string(&_1, SL("scope"), &ZEPHIR_GLOBAL(global_null), PH_COPY | PH_SEPARATE);
	zephir_array_update_string(&_1, SL("state"), &ZEPHIR_GLOBAL(global_null), PH_COPY | PH_SEPARATE);
	zephir_fast_array_merge(_0, &(_1), &(params) TSRMLS_CC);
	ZEPHIR_CPY_WRT(params, _0);
	zephir_array_fetch_string(&_3, params, SL("client_id"), PH_NOISY | PH_READONLY, "oauth2/responsetype/authorizationcode.zep", 37 TSRMLS_CC);
	zephir_array_fetch_string(&_4, params, SL("redirect_uri"), PH_NOISY | PH_READONLY, "oauth2/responsetype/authorizationcode.zep", 37 TSRMLS_CC);
	zephir_array_fetch_string(&_5, params, SL("scope"), PH_NOISY | PH_READONLY, "oauth2/responsetype/authorizationcode.zep", 37 TSRMLS_CC);
	ZEPHIR_CALL_METHOD(&_2, this_ptr, "createauthorizationcode", NULL, _3, user_id, _4, _5);
	zephir_check_call_status();
	zephir_array_update_multi(&result, &_2 TSRMLS_CC, SL("ss"), 4, SL("query"), SL("code"));
	if (zephir_array_isset_string(params, SS("state"))) {
		zephir_array_fetch_string(&_6, params, SL("state"), PH_NOISY | PH_READONLY, "oauth2/responsetype/authorizationcode.zep", 40 TSRMLS_CC);
		zephir_array_update_multi(&result, &_6 TSRMLS_CC, SL("ss"), 4, SL("query"), SL("state"));
	}
	array_init_size(return_value, 3);
	ZEPHIR_OBS_VAR(_7);
	zephir_array_fetch_string(&_7, params, SL("redirect_uri"), PH_NOISY, "oauth2/responsetype/authorizationcode.zep", 43 TSRMLS_CC);
	zephir_array_fast_append(return_value, _7);
	zephir_array_fast_append(return_value, result);
	RETURN_MM();

}
Exemple #10
0
/**
 * Adds a RIGHT join to the query
 *
 *<code>
 *	$criteria->rightJoin('Robots', 'r.id = RobotsParts.robots_id', 'r');
 *</code>
 *
 * @param string $model
 * @param string $conditions
 * @param string $alias
 * @return Phalcon\Mvc\Model\Query\Builder
 */
PHP_METHOD(Phalcon_Mvc_Model_Criteria, rightJoin){

	zval *model, *conditions = NULL, *alias = NULL, *type, *join, *params;
	zval *current_joins, *merged_joins = NULL;

	PHALCON_MM_GROW();

	phalcon_fetch_params(1, 1, 2, &model, &conditions, &alias);
	
	if (!conditions) {
		PHALCON_INIT_VAR(conditions);
	}
	
	if (!alias) {
		PHALCON_INIT_VAR(alias);
	}
	
	PHALCON_INIT_VAR(type);
	ZVAL_STRING(type, "RIGHT", 1);
	
	PHALCON_INIT_VAR(join);
	array_init_size(join, 4);
	phalcon_array_append(&join, model, PH_SEPARATE TSRMLS_CC);
	phalcon_array_append(&join, conditions, PH_SEPARATE TSRMLS_CC);
	phalcon_array_append(&join, alias, PH_SEPARATE TSRMLS_CC);
	phalcon_array_append(&join, type, PH_SEPARATE TSRMLS_CC);
	
	PHALCON_OBS_VAR(params);
	phalcon_read_property_this(&params, this_ptr, SL("_params"), PH_NOISY_CC);
	if (phalcon_array_isset_string(params, SS("joins"))) {
	
		PHALCON_OBS_VAR(current_joins);
		phalcon_array_fetch_string(&current_joins, params, SL("joins"), PH_NOISY_CC);
		if (Z_TYPE_P(current_joins) == IS_ARRAY) { 
			PHALCON_INIT_VAR(merged_joins);
			phalcon_fast_array_merge(merged_joins, &current_joins, &join TSRMLS_CC);
		} else {
			PHALCON_CPY_WRT(merged_joins, join);
		}
	} else {
		PHALCON_INIT_NVAR(merged_joins);
		array_init_size(merged_joins, 1);
		phalcon_array_append(&merged_joins, join, PH_SEPARATE TSRMLS_CC);
	}
	
	phalcon_update_property_array_string(this_ptr, SL("_params"), SS("joins"), merged_joins TSRMLS_CC);
	
	RETURN_THIS();
}
Exemple #11
0
/**
 * Phalcon\Flash constructor
 *
 * @param array $cssClasses
 */
PHP_METHOD(Phalcon_Flash, __construct){

	zval *css_classes = NULL;

	PHALCON_MM_GROW();

	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|z", &css_classes) == FAILURE) {
		RETURN_MM_NULL();
	}

	if (!css_classes) {
		PHALCON_INIT_VAR(css_classes);
	} else {
		PHALCON_SEPARATE_PARAM(css_classes);
	}
	
	if (Z_TYPE_P(css_classes) != IS_ARRAY) { 
		PHALCON_INIT_NVAR(css_classes);
		array_init_size(css_classes, 4);
		add_assoc_stringl_ex(css_classes, SS("error"), SL("errorMessage"), 1);
		add_assoc_stringl_ex(css_classes, SS("notice"), SL("noticeMessage"), 1);
		add_assoc_stringl_ex(css_classes, SS("success"), SL("successMessage"), 1);
		add_assoc_stringl_ex(css_classes, SS("warning"), SL("warningMessage"), 1);
	}
	phalcon_update_property_zval(this_ptr, SL("_cssClasses"), css_classes TSRMLS_CC);
	
	PHALCON_MM_RESTORE();
}
Exemple #12
0
/**
 * Serializing a resultset will dump all related rows into a big array
 *
 * @return string
 */
PHP_METHOD(Phalcon_Mvc_Model_Resultset_Complex, serialize){

	zval *records = NULL, *cache, *column_types, *hydrate_mode;
	zval *data, *serialized;

	PHALCON_MM_GROW();

	/** 
	 * Obtain the records as an array
	 */
	PHALCON_CALL_METHOD(&records, this_ptr, "toarray");
	
	cache        = phalcon_fetch_nproperty_this(this_ptr, SL("_cache"), PH_NOISY TSRMLS_CC);
	column_types = phalcon_fetch_nproperty_this(this_ptr, SL("_columnTypes"), PH_NOISY TSRMLS_CC);
	hydrate_mode = phalcon_fetch_nproperty_this(this_ptr, SL("_hydrateMode"), PH_NOISY TSRMLS_CC);
	
	PHALCON_INIT_VAR(data);
	array_init_size(data, 4);
	phalcon_array_update_string(&data, SL("cache"), cache, PH_COPY);
	phalcon_array_update_string(&data, SL("rows"), records, PH_COPY);
	phalcon_array_update_string(&data, SL("columnTypes"), column_types, PH_COPY);
	phalcon_array_update_string(&data, SL("hydrateMode"), hydrate_mode, PH_COPY);
	
	PHALCON_INIT_VAR(serialized);
	phalcon_serialize(serialized, &data TSRMLS_CC);
	
	/** 
	 * Avoid return bad serialized data
	 */
	if (Z_TYPE_P(serialized) != IS_STRING) {
		RETURN_MM_NULL();
	}
	
	RETURN_CTOR(serialized);
}
Exemple #13
0
/**
 * Serializing a resultset will dump all related rows into a big array
 *
 * @return string
 */
PHP_METHOD(Phalcon_Mvc_Model_Resultset_Complex, serialize){

	zval *records, *cache, *column_types, *hydrate_mode;
	zval *data, *serialized;

	PHALCON_MM_GROW();

	/** 
	 * Obtain the records as an array
	 */
	PHALCON_INIT_VAR(records);
	PHALCON_CALL_METHOD(records, this_ptr, "toarray");
	
	PHALCON_OBS_VAR(cache);
	phalcon_read_property_this(&cache, this_ptr, SL("_cache"), PH_NOISY_CC);
	
	PHALCON_OBS_VAR(column_types);
	phalcon_read_property_this(&column_types, this_ptr, SL("_columnTypes"), PH_NOISY_CC);
	
	PHALCON_OBS_VAR(hydrate_mode);
	phalcon_read_property_this(&hydrate_mode, this_ptr, SL("_hydrateMode"), PH_NOISY_CC);
	
	PHALCON_INIT_VAR(data);
	array_init_size(data, 4);
	phalcon_array_update_string(&data, SL("cache"), &cache, PH_COPY | PH_SEPARATE TSRMLS_CC);
	phalcon_array_update_string(&data, SL("rows"), &records, PH_COPY | PH_SEPARATE TSRMLS_CC);
	phalcon_array_update_string(&data, SL("columnTypes"), &column_types, PH_COPY | PH_SEPARATE TSRMLS_CC);
	phalcon_array_update_string(&data, SL("hydrateMode"), &hydrate_mode, PH_COPY | PH_SEPARATE TSRMLS_CC);
	
	PHALCON_INIT_VAR(serialized);
	PHALCON_CALL_FUNC_PARAMS_1(serialized, "serialize", data);
	RETURN_CCTOR(serialized);
}
Exemple #14
0
/**
 * Adds a resource to the annotations handler
 * A resource is a class that contains routing annotations
 * The class is located in a module
 *
 * @param string $module
 * @param string $handler
 * @param string $prefix
 * @return Phalcon\Mvc\Router\Annotations
 */
PHP_METHOD(Phalcon_Mvc_Router_Annotations, addModuleResource){

	zval *module, *handler, *prefix = NULL, *scope;

	phalcon_fetch_params(0, 2, 1, &module, &handler, &prefix);
	
	if (!prefix) {
		prefix = PHALCON_GLOBAL(z_null);
	}
	
	if (Z_TYPE_P(module) != IS_STRING) {
		PHALCON_THROW_EXCEPTION_STRW(phalcon_mvc_router_exception_ce, "The module is not a valid string");
		return;
	}
	if (Z_TYPE_P(handler) != IS_STRING) {
		PHALCON_THROW_EXCEPTION_STRW(phalcon_mvc_router_exception_ce, "The handler must be a class name");
		return;
	}
	
	MAKE_STD_ZVAL(scope);
	array_init_size(scope, 3);
	phalcon_array_append(&scope, prefix, 0);
	phalcon_array_append(&scope, handler, 0);
	phalcon_array_append(&scope, module, 0);
	phalcon_update_property_array_append(this_ptr, SL("_handlers"), scope TSRMLS_CC);
	zval_ptr_dtor(&scope);

	phalcon_update_property_this(this_ptr, SL("_processed"), PHALCON_GLOBAL(z_false) TSRMLS_CC);
	
	RETURN_THISW();
}
Exemple #15
0
/**
 * Adds a resource to the annotations handler
 * A resource is a class that contains routing annotations
 *
 * @param string $handler
 * @param string $prefix
 * @return Phalcon\Mvc\Router\Annotations
 */
PHP_METHOD(Phalcon_Mvc_Router_Annotations, addResource){

	zval *handler, *prefix = NULL, *scope;

	PHALCON_MM_GROW();

	phalcon_fetch_params(1, 1, 1, &handler, &prefix);
	
	if (!prefix) {
		prefix = PHALCON_GLOBAL(z_null);
	}
	
	if (Z_TYPE_P(handler) != IS_STRING) {
		PHALCON_THROW_EXCEPTION_STR(phalcon_mvc_router_exception_ce, "The handler must be a class name");
		return;
	}
	
	PHALCON_INIT_VAR(scope);
	array_init_size(scope, 2);
	phalcon_array_append(&scope, prefix, 0);
	phalcon_array_append(&scope, handler, 0);
	phalcon_update_property_array_append(this_ptr, SL("_handlers"), scope TSRMLS_CC);
	phalcon_update_property_this(this_ptr, SL("_processed"), PHALCON_GLOBAL(z_false) TSRMLS_CC);
	
	RETURN_THIS();
}
Exemple #16
0
PHP_METHOD(Test_Flow, testFor3) {

	HashTable *_2;
	HashPosition _1;
	zval *v = NULL, *b, *c, *_0, **_3;

	ZEPHIR_MM_GROW();

	ZEPHIR_INIT_VAR(c);
	array_init(c);
	ZEPHIR_INIT_VAR(b);
	array_init_size(b, 5);
	ZEPHIR_INIT_VAR(_0);
	ZVAL_LONG(_0, 1);
	zephir_array_fast_append(b, _0);
	ZEPHIR_INIT_BNVAR(_0);
	ZVAL_LONG(_0, 2);
	zephir_array_fast_append(b, _0);
	ZEPHIR_INIT_BNVAR(_0);
	ZVAL_LONG(_0, 3);
	zephir_array_fast_append(b, _0);
	ZEPHIR_INIT_BNVAR(_0);
	ZVAL_LONG(_0, 4);
	zephir_array_fast_append(b, _0);
	zephir_is_iterable(b, &_2, &_1, 0, 1);
	for (
		; zend_hash_get_current_data_ex(_2, (void**) &_3, &_1) == SUCCESS
		; zend_hash_move_backwards_ex(_2, &_1)
	) {
		ZEPHIR_GET_HVALUE(v, _3);
		zephir_array_append(&c, v, PH_SEPARATE);
	}
	RETURN_CCTOR(c);

}
Exemple #17
0
static ZEND_NAMED_FUNCTION(zend_closure_call_magic) /* {{{ */ {
	zend_fcall_info fci;
	zend_fcall_info_cache fcc;
	zval params[2];

	memset(&fci, 0, sizeof(zend_fcall_info));
	memset(&fcc, 0, sizeof(zend_fcall_info_cache));

	fci.size = sizeof(zend_fcall_info);
	fci.retval = return_value;

	fcc.function_handler = (zend_function *) EX(func)->common.arg_info;
	fci.params = params;
	fci.param_count = 2;
	ZVAL_STR(&fci.params[0], EX(func)->common.function_name);
	if (ZEND_NUM_ARGS()) {
		array_init_size(&fci.params[1], ZEND_NUM_ARGS());
		zend_copy_parameters_array(ZEND_NUM_ARGS(), &fci.params[1]);
	} else {
		ZVAL_EMPTY_ARRAY(&fci.params[1]);
	}

	fci.object = Z_OBJ(EX(This));
	fcc.object = Z_OBJ(EX(This));

	zend_call_function(&fci, &fcc);

	zval_ptr_dtor(&fci.params[0]);
	zval_ptr_dtor(&fci.params[1]);
}
Exemple #18
0
/**
 * Adds the limit parameter to the criteria
 *
 * @param int $limit
 * @param int $offset
 * @return Phalcon\Mvc\Model\Criteria
 */
PHP_METHOD(Phalcon_Mvc_Model_Criteria, limit){

	zval *limit, *offset = NULL, *limit_clause;

	PHALCON_MM_GROW();

	phalcon_fetch_params(1, 1, 1, &limit, &offset);
	
	if (!offset) {
		PHALCON_INIT_VAR(offset);
	}
	
	if (!phalcon_is_numeric(limit)) {
		PHALCON_THROW_EXCEPTION_STR(phalcon_mvc_model_exception_ce, "Rows limit parameter must be integer");
		return;
	}
	if (Z_TYPE_P(offset) == IS_NULL) {
		phalcon_update_property_array_string(this_ptr, SL("_params"), SS("limit"), limit TSRMLS_CC);
	} else {
		PHALCON_INIT_VAR(limit_clause);
		array_init_size(limit_clause, 2);
		phalcon_array_update_string(&limit_clause, SL("number"), &limit, PH_COPY | PH_SEPARATE TSRMLS_CC);
		phalcon_array_update_string(&limit_clause, SL("offset"), &offset, PH_COPY | PH_SEPARATE TSRMLS_CC);
		phalcon_update_property_array_string(this_ptr, SL("_params"), SS("limit"), limit_clause TSRMLS_CC);
	}
	
	RETURN_THIS();
}
Exemple #19
0
zval * yee_exception_to_array_recursive(zval *self, zval *exception) {
	zend_object *object        = (zend_object *)zend_object_store_get_object(self TSRMLS_CC);
	zend_object *except_object = (zend_object *)zend_object_store_get_object(exception TSRMLS_CC);
	zval *array;
	zval *name = NULL, *message = NULL, *code = NULL, *previous = NULL, *previous2 = NULL;
	
	MAKE_STD_ZVAL(array);
	array_init_size(array, 5);
	
	if (instanceof_function(except_object->ce, yee_ce_Exception)) {
		zend_call_method(&exception, except_object->ce, NULL, ZEND_STRL("getname"), &name, 0, NULL, NULL);
	}else {
		MAKE_STD_ZVAL(name);
		ZVAL_STRING(name, "Exception", 1);
	}
	
	zend_call_method(&exception, except_object->ce, NULL, ZEND_STRL("getmessage"), &message, 0, NULL, NULL);
	zend_call_method(&exception, except_object->ce, NULL, ZEND_STRL("getcode"), &code, 0, NULL, NULL);
	zend_call_method(&exception, except_object->ce, NULL, ZEND_STRL("getprevious"), &previous, 0, NULL, NULL);
	
	add_assoc_string_ex(array, ZEND_STRS("type"), (char *)except_object->ce->name, 1);
	add_assoc_zval_ex(array, ZEND_STRS("name"), name);
	add_assoc_zval_ex(array, ZEND_STRS("message"), message);
	add_assoc_zval_ex(array, ZEND_STRS("code"), code);
	
	if (previous && previous->type == IS_OBJECT) {
		previous2 = yee_exception_to_array_recursive(self, previous);
		add_assoc_zval_ex(array, ZEND_STRS("previous"), previous2);
	}
	zval_dtor(previous);
	efree(previous);
	
	return array;
}
Exemple #20
0
PHP_METHOD(Test_Json, testEncodeOptions) {

	zval *arr, *_0 = NULL, _1;

	ZEPHIR_MM_GROW();

	ZEPHIR_INIT_VAR(arr);
	array_init_size(arr, 7);
	ZEPHIR_INIT_VAR(_0);
	ZVAL_STRING(_0, "<foo>", 1);
	zephir_array_fast_append(arr, _0);
	ZEPHIR_INIT_BNVAR(_0);
	ZVAL_STRING(_0, "'bar'", 1);
	zephir_array_fast_append(arr, _0);
	ZEPHIR_INIT_BNVAR(_0);
	ZVAL_STRING(_0, "&blong&", 1);
	zephir_array_fast_append(arr, _0);
	ZEPHIR_INIT_BNVAR(_0);
	ZVAL_STRING(_0, "\xc3\xa9", 1);
	zephir_array_fast_append(arr, _0);
	ZEPHIR_SINIT_VAR(_1);
	ZVAL_LONG(&_1, 1);
	zephir_json_encode(return_value, &(return_value), arr, zephir_get_intval(&_1)  TSRMLS_CC);
	RETURN_MM();

}
Exemple #21
0
PHP_METHOD(Test_NativeArray, testArrayUpdate3) {

	int b;
	zval *a, *_0, *_1;

	ZEPHIR_MM_GROW();

	ZEPHIR_INIT_VAR(a);
	array_init_size(a, 5);
	ZEPHIR_INIT_VAR(_0);
	ZVAL_LONG(_0, 1);
	zephir_array_fast_append(a, _0);
	ZEPHIR_INIT_BNVAR(_0);
	ZVAL_LONG(_0, 2);
	zephir_array_fast_append(a, _0);
	ZEPHIR_INIT_BNVAR(_0);
	ZVAL_LONG(_0, 3);
	zephir_array_fast_append(a, _0);
	b = 0;
	ZEPHIR_INIT_BNVAR(_0);
	ZVAL_LONG(_0, 4);
	zephir_array_update_long(&a, b, &_0, PH_COPY | PH_SEPARATE, "test/nativearray.zep", 379);
	b = 1;
	ZEPHIR_INIT_VAR(_1);
	ZVAL_LONG(_1, 5);
	zephir_array_update_long(&a, b, &_1, PH_COPY | PH_SEPARATE, "test/nativearray.zep", 381);
	RETURN_CCTOR(a);

}
Exemple #22
0
/**
 * Phalcon\Flash constructor
 *
 * @param array $cssClasses
 */
PHP_METHOD(Phalcon_Flash, __construct){

	zval *css_classes = NULL;

	PHALCON_MM_GROW();

	phalcon_fetch_params(1, 0, 1, &css_classes);
	
	if (!css_classes) {
		PHALCON_INIT_VAR(css_classes);
	} else {
		PHALCON_SEPARATE_PARAM(css_classes);
	}
	
	if (Z_TYPE_P(css_classes) != IS_ARRAY) { 
		PHALCON_INIT_NVAR(css_classes);
		array_init_size(css_classes, 4);
		add_assoc_stringl_ex(css_classes, SS("error"), SL("errorMessage"), 1);
		add_assoc_stringl_ex(css_classes, SS("notice"), SL("noticeMessage"), 1);
		add_assoc_stringl_ex(css_classes, SS("success"), SL("successMessage"), 1);
		add_assoc_stringl_ex(css_classes, SS("warning"), SL("warningMessage"), 1);
	}
	phalcon_update_property_this(this_ptr, SL("_cssClasses"), css_classes TSRMLS_CC);
	
	PHALCON_MM_RESTORE();
}
Exemple #23
0
/* {{{ proto array SplDoublyLinkedList::__serialize() */
SPL_METHOD(SplDoublyLinkedList, __serialize)
{
	spl_dllist_object *intern = Z_SPLDLLIST_P(ZEND_THIS);
	spl_ptr_llist_element *current = intern->llist->head;
	zval tmp;

	if (zend_parse_parameters_none_throw() == FAILURE) {
		return;
	}

	array_init(return_value);

	/* flags */
	ZVAL_LONG(&tmp, intern->flags);
	zend_hash_next_index_insert(Z_ARRVAL_P(return_value), &tmp);

	/* elements */
	array_init_size(&tmp, intern->llist->count);
	while (current) {
		zend_hash_next_index_insert(Z_ARRVAL(tmp), &current->data);
		current = current->next;
	}
	zend_hash_next_index_insert(Z_ARRVAL_P(return_value), &tmp);

	/* members */
	ZVAL_ARR(&tmp, zend_std_get_properties(&intern->std));
	Z_TRY_ADDREF(tmp);
	zend_hash_next_index_insert(Z_ARRVAL_P(return_value), &tmp);
} /* }}} */
Exemple #24
0
/**
 * Adds a variable to the debug output
 *
 * @param mixed $var
 * @param string $key
 * @return Phalcon\Debug
 */
PHP_METHOD(Phalcon_Debug, debugVar){

	zval *var, *key = NULL, *ztime, *backtrace, *data;

	PHALCON_MM_GROW();

	phalcon_fetch_params(1, 1, 1, &var, &key);
	
	if (!key) {
		PHALCON_INIT_VAR(key);
	}
	
	PHALCON_INIT_VAR(ztime);
	ZVAL_LONG(ztime, (long) time(NULL));
	
	PHALCON_INIT_VAR(backtrace);
#if PHP_VERSION_ID < 50400
#ifdef DEBUG_BACKTRACE_PROVIDE_OBJECT
	zend_fetch_debug_backtrace(backtrace, 0, DEBUG_BACKTRACE_PROVIDE_OBJECT TSRMLS_CC);
#else
	zend_fetch_debug_backtrace(backtrace, 0, 1 TSRMLS_CC);
#endif
#else
	zend_fetch_debug_backtrace(backtrace, 0, DEBUG_BACKTRACE_PROVIDE_OBJECT, 0 TSRMLS_CC);
#endif
	
	PHALCON_INIT_VAR(data);
	array_init_size(data, 3);
	phalcon_array_append(&data, var, PH_SEPARATE);
	phalcon_array_append(&data, backtrace, PH_SEPARATE);
	phalcon_array_append(&data, ztime, PH_SEPARATE);
	phalcon_update_property_array_append(this_ptr, SL("_data"), data TSRMLS_CC);
	RETURN_THIS();
}
Exemple #25
0
/**
 * Returns a new Phalcon\Mvc\Model\Transaction or an already created once
 * This method registers a shutdown function to rollback active connections
 *
 * @param boolean $autoBegin
 * @return Phalcon\Mvc\Model\TransactionInterface
 */
PHP_METHOD(Phalcon_Mvc_Model_Transaction_Manager, get){

	zval *auto_begin = NULL, *initialized, *rollback_pendent = NULL;

	PHALCON_MM_GROW();

	phalcon_fetch_params(1, 0, 1, &auto_begin);
	
	if (!auto_begin) {
		PHALCON_INIT_VAR(auto_begin);
		ZVAL_BOOL(auto_begin, 1);
	}
	
	PHALCON_OBS_VAR(initialized);
	phalcon_read_property_this(&initialized, this_ptr, SL("_initialized"), PH_NOISY_CC);
	if (zend_is_true(initialized)) {
	
		PHALCON_OBS_VAR(rollback_pendent);
		phalcon_read_property_this(&rollback_pendent, this_ptr, SL("_rollbackPendent"), PH_NOISY_CC);
		if (zend_is_true(rollback_pendent)) {
			PHALCON_INIT_NVAR(rollback_pendent);
			array_init_size(rollback_pendent, 2);
			phalcon_array_append(&rollback_pendent, this_ptr, PH_SEPARATE);
			add_next_index_stringl(rollback_pendent, SL("rollbackPendent"), 1);
			phalcon_call_func_p1_noret("register_shutdown_function", rollback_pendent);
		}
	
		phalcon_update_property_bool(this_ptr, SL("_initialized"), 1 TSRMLS_CC);
	}
	
	phalcon_call_method(return_value, this_ptr, "getorcreatetransaction");
	RETURN_MM();
}
Exemple #26
0
/**
 * Initializes the internal handler, calling functions on it
 *
 * @param string $method
 * @param array $arguments
 * @return mixed
 */
PHP_METHOD(Phalcon_Mvc_Micro_LazyLoader, __call){

	zval *method, *arguments, *handler = NULL, *definition;
	zval *call_handler;
	zend_class_entry *ce0;

	PHALCON_MM_GROW();

	phalcon_fetch_params(1, 2, 0, &method, &arguments);

	handler = phalcon_read_property(getThis(), SL("_handler"), PH_NOISY);
	if (Z_TYPE_P(handler) != IS_OBJECT) {
		definition = phalcon_read_property(getThis(), SL("_definition"), PH_NOISY);
		ce0 = phalcon_fetch_class(definition);

		PHALCON_INIT_NVAR(handler);
		object_init_ex(handler, ce0);
		if (phalcon_has_constructor(handler)) {
			PHALCON_CALL_METHOD(NULL, handler, "__construct");
		}
		phalcon_update_property_this(getThis(), SL("_handler"), handler);
	}

	PHALCON_INIT_VAR(call_handler);
	array_init_size(call_handler, 2);
	phalcon_array_append(call_handler, handler, PH_COPY);
	phalcon_array_append(call_handler, method, PH_COPY);

	/** 
	 * Call the handler
	 */
	PHALCON_CALL_USER_FUNC_ARRAY(&return_value, call_handler, arguments);
	RETURN_MM();
}
Exemple #27
0
/**
 * Adds a validator to a field
 *
 * @param string $attribute
 * @param Phalcon\Validation\ValidatorInterface
 * @return Phalcon\Validation
 */
PHP_METHOD(Phalcon_Validation, add){

	zval *attribute, *validator, *scope;

	PHALCON_MM_GROW();

	phalcon_fetch_params(1, 2, 0, &attribute, &validator);
	
	if (Z_TYPE_P(attribute) != IS_STRING) {
		PHALCON_THROW_EXCEPTION_STR(phalcon_validation_exception_ce, "The attribute must be a string");
		return;
	}
	if (Z_TYPE_P(validator) != IS_OBJECT) {
		PHALCON_THROW_EXCEPTION_STR(phalcon_validation_exception_ce, "The validator must be an object");
		return;
	}
	
	PHALCON_INIT_VAR(scope);
	array_init_size(scope, 2);
	phalcon_array_append(&scope, attribute, PH_SEPARATE TSRMLS_CC);
	phalcon_array_append(&scope, validator, PH_SEPARATE TSRMLS_CC);
	phalcon_update_property_array_append(this_ptr, SL("_validators"), scope TSRMLS_CC);
	
	RETURN_THIS();
}
Exemple #28
0
PHP_METHOD(Test_Flow, testFor1) {

	HashTable *_2;
	HashPosition _1;
	int c;
	zval *v = NULL, *b, *_0, **_3;

	ZEPHIR_MM_GROW();

	c = 0;
	ZEPHIR_INIT_VAR(b);
	array_init_size(b, 5);
	ZEPHIR_INIT_VAR(_0);
	ZVAL_LONG(_0, 1);
	zephir_array_fast_append(b, _0);
	ZEPHIR_INIT_BNVAR(_0);
	ZVAL_LONG(_0, 2);
	zephir_array_fast_append(b, _0);
	ZEPHIR_INIT_BNVAR(_0);
	ZVAL_LONG(_0, 3);
	zephir_array_fast_append(b, _0);
	ZEPHIR_INIT_BNVAR(_0);
	ZVAL_LONG(_0, 4);
	zephir_array_fast_append(b, _0);
	zephir_is_iterable(b, &_2, &_1, 0, 0);
	for (
		; zend_hash_get_current_data_ex(_2, (void**) &_3, &_1) == SUCCESS
		; zend_hash_move_forward_ex(_2, &_1)
	) {
		ZEPHIR_GET_HVALUE(v, _3);
		c += zephir_get_numberval(v);
	}
	RETURN_MM_LONG(c);

}
Exemple #29
0
/**
 * Initializes the internal handler, calling functions on it
 *
 * @param string $method
 * @param array $arguments
 * @return mixed
 */
PHP_METHOD(Phalcon_Mvc_Micro_LazyLoader, __call){

	zval *method, *arguments, handler = {}, definition = {}, call_handler = {};
	zend_class_entry *ce0;

	phalcon_fetch_params(0, 2, 0, &method, &arguments);

	phalcon_return_property(&handler, getThis(), SL("_handler"));
	if (Z_TYPE(handler) != IS_OBJECT) {
		phalcon_read_property(&definition, getThis(), SL("_definition"), PH_NOISY);
		ce0 = phalcon_fetch_class(&definition, ZEND_FETCH_CLASS_DEFAULT);

		PHALCON_OBJECT_INIT(&handler, ce0);
		if (phalcon_has_constructor(&handler)) {
			PHALCON_CALL_METHODW(NULL, &handler, "__construct");
		}
		phalcon_update_property_zval(getThis(), SL("_handler"), &handler);
	}

	array_init_size(&call_handler, 2);
	phalcon_array_append(&call_handler, &handler, PH_COPY);
	phalcon_array_append(&call_handler, method, PH_COPY);

	/** 
	 * Call the handler
	 */
	PHALCON_CALL_USER_FUNC_ARRAYW(return_value, &call_handler, arguments);
}
Exemple #30
0
/**
 * Executes the validation
 *
 * @param Phalcon\Validation $validator
 * @param string $attribute
 * @return boolean
 */
PHP_METHOD(Phalcon_Validation_Validator_Url, validate){

	zval *validator, *attribute, *value = NULL, *allow_empty, *valid = NULL, *label;
	zval *pairs, *message_str, *code, *prepared = NULL, *message;
	zend_class_entry *ce = Z_OBJCE_P(getThis());

	PHALCON_MM_GROW();

	phalcon_fetch_params(1, 2, 0, &validator, &attribute);
	
	PHALCON_VERIFY_CLASS_EX(validator, phalcon_validation_ce, phalcon_validation_exception_ce, 1);

	PHALCON_CALL_METHOD(&value, validator, "getvalue", attribute);
	
	PHALCON_OBS_VAR(allow_empty);
	RETURN_MM_ON_FAILURE(phalcon_validation_validator_getoption_helper(ce, &allow_empty, getThis(), ISV(allowEmpty)));
	if (zend_is_true(allow_empty) && phalcon_validation_validator_isempty_helper(value)) {
		RETURN_MM_TRUE;
	}

	PHALCON_CALL_SELF(&valid, "valid", value);

	if (PHALCON_IS_FALSE(valid)) {
		PHALCON_OBS_VAR(label);
		RETURN_MM_ON_FAILURE(phalcon_validation_validator_getoption_helper(ce, &label, getThis(), ISV(label)));
		if (!zend_is_true(label)) {
			PHALCON_CALL_METHOD(&label, validator, "getlabel", attribute);
			if (!zend_is_true(label)) {
				PHALCON_CPY_WRT(label, attribute);
			}
		}

		PHALCON_ALLOC_INIT_ZVAL(pairs);
		array_init_size(pairs, 1);
		Z_TRY_ADDREF_P(label); add_assoc_zval_ex(pairs, SL(":field"), label);

		PHALCON_OBS_VAR(message_str);
		RETURN_MM_ON_FAILURE(phalcon_validation_validator_getoption_helper(ce, &message_str, getThis(), ISV(message)));
		if (!zend_is_true(message_str)) {
			PHALCON_OBSERVE_OR_NULLIFY_VAR(message_str);
			RETURN_MM_ON_FAILURE(phalcon_validation_getdefaultmessage_helper(Z_OBJCE_P(validator), message_str, validator, "Url"));
		}
	
		PHALCON_OBS_VAR(code);
		RETURN_MM_ON_FAILURE(phalcon_validation_validator_getoption_helper(ce, &code, getThis(), ISV(code)));
		if (Z_TYPE_P(code) == IS_NULL) {
			ZVAL_LONG(code, 0);
		}

		PHALCON_CALL_FUNCTION(&prepared, "strtr", message_str, pairs);

		message = phalcon_validation_message_construct_helper(prepared, attribute, "Url", code);
		Z_TRY_DELREF_P(message);
	
		PHALCON_CALL_METHOD(NULL, validator, "appendmessage", message);
		RETURN_MM_FALSE;
	}
	
	RETURN_MM_TRUE;
}