/** * Check whether internal resource has rows to fetch * * @return boolean */ PHP_METHOD(Phalcon_Mvc_Model_Resultset_Complex, valid){ zval *type = NULL, *result, *row = NULL, *rows, *underscore, *empty_str; zval *active_row, *columns_types, *column = NULL, *alias = NULL; zval *source = NULL, *instance = NULL, *attributes = NULL, *column_map = NULL; zval *row_model = NULL, *attribute = NULL, *column_alias = NULL, *value = NULL; zval *model_attribute = NULL, *sql_alias = NULL, *n_alias = NULL; HashTable *ah0, *ah1; HashPosition hp0, hp1; zval **hd; char *hash_index; uint hash_index_len; ulong hash_num; int hash_type; int eval_int; PHALCON_MM_GROW(); PHALCON_INIT_VAR(type); phalcon_read_property(&type, this_ptr, SL("_type"), PH_NOISY_CC); if (zend_is_true(type)) { PHALCON_INIT_VAR(result); phalcon_read_property(&result, this_ptr, SL("_result"), PH_NOISY_CC); if (PHALCON_IS_NOT_FALSE(result)) { PHALCON_INIT_VAR(row); PHALCON_CALL_METHOD_PARAMS_1(row, result, "fetch", result, PH_NO_CHECK); } else { PHALCON_INIT_NVAR(row); ZVAL_BOOL(row, 0); } } else { PHALCON_INIT_VAR(rows); phalcon_read_property(&rows, this_ptr, SL("_rows"), PH_NOISY_CC); Z_SET_ISREF_P(rows); PHALCON_INIT_NVAR(row); PHALCON_CALL_FUNC_PARAMS_1(row, "current", rows); Z_UNSET_ISREF_P(rows); if (zend_is_true(row)) { Z_SET_ISREF_P(rows); PHALCON_CALL_FUNC_PARAMS_1_NORETURN("next", rows); Z_UNSET_ISREF_P(rows); } } if (PHALCON_IS_NOT_FALSE(row)) { PHALCON_INIT_VAR(underscore); ZVAL_STRING(underscore, "_", 1); PHALCON_INIT_VAR(empty_str); ZVAL_STRING(empty_str, "", 1); PHALCON_INIT_VAR(active_row); object_init_ex(active_row, phalcon_mvc_model_row_ce); PHALCON_INIT_VAR(columns_types); phalcon_read_property(&columns_types, this_ptr, SL("_columnTypes"), PH_NOISY_CC); if (!phalcon_valid_foreach(columns_types TSRMLS_CC)) { return; } ah0 = Z_ARRVAL_P(columns_types); zend_hash_internal_pointer_reset_ex(ah0, &hp0); ph_cycle_start_0: if (zend_hash_get_current_data_ex(ah0, (void**) &hd, &hp0) != SUCCESS) { goto ph_cycle_end_0; } PHALCON_GET_FOREACH_KEY(alias, ah0, hp0); PHALCON_GET_FOREACH_VALUE(column); PHALCON_INIT_NVAR(type); phalcon_array_fetch_string(&type, column, SL("type"), PH_NOISY_CC); if (PHALCON_COMPARE_STRING(type, "object")) { /** * Object columns are assigned column by column */ PHALCON_INIT_NVAR(source); phalcon_array_fetch_string(&source, column, SL("column"), PH_NOISY_CC); PHALCON_INIT_NVAR(instance); phalcon_array_fetch_string(&instance, column, SL("instance"), PH_NOISY_CC); PHALCON_INIT_NVAR(attributes); phalcon_array_fetch_string(&attributes, column, SL("attributes"), PH_NOISY_CC); PHALCON_INIT_NVAR(column_map); phalcon_array_fetch_string(&column_map, column, SL("columnMap"), PH_NOISY_CC); /** * Assign the values from the _source_attribute notation to its real column name */ PHALCON_INIT_NVAR(row_model); array_init(row_model); if (!phalcon_valid_foreach(attributes TSRMLS_CC)) { return; } ah1 = Z_ARRVAL_P(attributes); zend_hash_internal_pointer_reset_ex(ah1, &hp1); ph_cycle_start_1: if (zend_hash_get_current_data_ex(ah1, (void**) &hd, &hp1) != SUCCESS) { goto ph_cycle_end_1; } PHALCON_GET_FOREACH_VALUE(attribute); PHALCON_INIT_NVAR(column_alias); PHALCON_CONCAT_VVVV(column_alias, underscore, source, underscore, attribute); PHALCON_INIT_NVAR(value); phalcon_array_fetch(&value, row, column_alias, PH_NOISY_CC); phalcon_array_update_zval(&row_model, attribute, &value, PH_COPY | PH_SEPARATE TSRMLS_CC); zend_hash_move_forward_ex(ah1, &hp1); goto ph_cycle_start_1; ph_cycle_end_1: /** * Assign the values to the attributes using a column map */ PHALCON_INIT_NVAR(model_attribute); PHALCON_CALL_STATIC_PARAMS_3(model_attribute, "phalcon\\mvc\\model", "dumpresultmap", instance, row_model, column_map); /** * The complete object is assigned to an attribute with the name of the alias or * the model name */ PHALCON_INIT_NVAR(attribute); phalcon_array_fetch_string(&attribute, column, SL("balias"), PH_NOISY_CC); phalcon_update_property_zval_zval(active_row, attribute, model_attribute TSRMLS_CC); } else { /** * Scalar columns are simply assigned to the result object */ eval_int = phalcon_array_isset_string(column, SS("sqlAlias")); if (eval_int) { PHALCON_INIT_NVAR(sql_alias); phalcon_array_fetch_string(&sql_alias, column, SL("sqlAlias"), PH_NOISY_CC); PHALCON_INIT_NVAR(value); phalcon_array_fetch(&value, row, sql_alias, PH_NOISY_CC); } else { PHALCON_INIT_NVAR(value); phalcon_array_fetch(&value, row, alias, PH_NOISY_CC); } /** * If a 'balias' is defined is not an unnamed scalar */ eval_int = phalcon_array_isset_string(column, SS("balias")); if (eval_int) { phalcon_update_property_zval_zval(active_row, alias, value TSRMLS_CC); } else { PHALCON_INIT_NVAR(n_alias); phalcon_fast_str_replace(n_alias, underscore, empty_str, alias TSRMLS_CC); phalcon_update_property_zval_zval(active_row, n_alias, value TSRMLS_CC); } } zend_hash_move_forward_ex(ah0, &hp0); goto ph_cycle_start_0; ph_cycle_end_0: phalcon_update_property_zval(this_ptr, SL("_activeRow"), active_row TSRMLS_CC); PHALCON_MM_RESTORE(); RETURN_TRUE; } else { phalcon_update_property_bool(this_ptr, SL("_activeRow"), 0 TSRMLS_CC); } PHALCON_MM_RESTORE(); RETURN_FALSE; }
/** * Returns a PHQL statement built based on the builder parameters * * @return string */ PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, getPhql){ zval *dependency_injector = NULL, *models, *conditions = NULL; zval *one, *number_models, *invalid_condition; zval *model = NULL, *service_name, *meta_data, *model_instance; zval *no_primary = NULL, *primary_keys, *first_primary_key; zval *column_map = NULL, *attribute_field = NULL, *exception_message; zval *primary_key_condition, *phql, *columns; zval *selected_columns = NULL, *column = NULL, *column_alias = NULL; zval *aliased_column = NULL, *joined_columns = NULL, *model_column_alias = NULL; zval *selected_column = NULL, *selected_models, *model_alias = NULL; zval *selected_model = NULL, *joined_models, *joins; zval *join = NULL, *join_model = NULL, *join_conditions = NULL, *join_alias = NULL; zval *join_type = NULL, *group, *group_items, *group_item = NULL; zval *escaped_item = NULL, *joined_items = NULL, *having, *order; zval *order_items, *order_item = NULL, *limit, *number; zval *offset = NULL; HashTable *ah0, *ah1, *ah2, *ah3, *ah4, *ah5; HashPosition hp0, hp1, hp2, hp3, hp4, hp5; zval **hd; zend_class_entry *ce0; PHALCON_MM_GROW(); PHALCON_OBS_VAR(dependency_injector); phalcon_read_property_this(&dependency_injector, this_ptr, SL("_dependencyInjector"), PH_NOISY_CC); if (Z_TYPE_P(dependency_injector) != IS_OBJECT) { PHALCON_INIT_NVAR(dependency_injector); PHALCON_CALL_STATIC(dependency_injector, "phalcon\\di", "getdefault"); phalcon_update_property_this(this_ptr, SL("_dependencyInjector"), dependency_injector TSRMLS_CC); } PHALCON_OBS_VAR(models); phalcon_read_property_this(&models, this_ptr, SL("_models"), PH_NOISY_CC); if (Z_TYPE_P(models) == IS_ARRAY) { if (!phalcon_fast_count_ev(models TSRMLS_CC)) { PHALCON_THROW_EXCEPTION_STR(phalcon_mvc_model_exception_ce, "At least one model is required to build the query"); return; } } else { if (!zend_is_true(models)) { PHALCON_THROW_EXCEPTION_STR(phalcon_mvc_model_exception_ce, "At least one model is required to build the query"); return; } } PHALCON_OBS_VAR(conditions); phalcon_read_property_this(&conditions, this_ptr, SL("_conditions"), PH_NOISY_CC); if (phalcon_is_numeric(conditions)) { /** * If the conditions is a single numeric field. We internally create a condition * using the related primary key */ if (Z_TYPE_P(models) == IS_ARRAY) { PHALCON_INIT_VAR(one); ZVAL_LONG(one, 1); PHALCON_INIT_VAR(number_models); phalcon_fast_count(number_models, models TSRMLS_CC); PHALCON_INIT_VAR(invalid_condition); is_smaller_function(invalid_condition, one, number_models TSRMLS_CC); if (PHALCON_IS_TRUE(invalid_condition)) { PHALCON_THROW_EXCEPTION_STR(phalcon_mvc_model_exception_ce, "Cannot build the query. Invalid condition"); return; } PHALCON_OBS_VAR(model); phalcon_array_fetch_long(&model, models, 0, PH_NOISY); } else { PHALCON_CPY_WRT(model, models); } PHALCON_INIT_VAR(service_name); ZVAL_STRING(service_name, "modelsMetadata", 1); /** * Get the models metadata service to obtain the column names, column map and * primary key */ PHALCON_INIT_VAR(meta_data); phalcon_call_method_p1(meta_data, dependency_injector, "getshared", service_name); ce0 = phalcon_fetch_class(model TSRMLS_CC); PHALCON_INIT_VAR(model_instance); object_init_ex(model_instance, ce0); if (phalcon_has_constructor(model_instance TSRMLS_CC)) { phalcon_call_method_p1_noret(model_instance, "__construct", dependency_injector); } PHALCON_INIT_VAR(no_primary); ZVAL_BOOL(no_primary, 1); PHALCON_INIT_VAR(primary_keys); phalcon_call_method_p1(primary_keys, meta_data, "getprimarykeyattributes", model_instance); if (phalcon_fast_count_ev(primary_keys TSRMLS_CC)) { if (phalcon_array_isset_long(primary_keys, 0)) { PHALCON_OBS_VAR(first_primary_key); phalcon_array_fetch_long(&first_primary_key, primary_keys, 0, PH_NOISY); /** * The PHQL contains the renamed columns if available */ if (PHALCON_GLOBAL(orm).column_renaming) { PHALCON_INIT_VAR(column_map); phalcon_call_method_p1(column_map, meta_data, "getcolumnmap", model_instance); } else { PHALCON_INIT_NVAR(column_map); } if (Z_TYPE_P(column_map) == IS_ARRAY) { if (phalcon_array_isset(column_map, first_primary_key)) { PHALCON_OBS_VAR(attribute_field); phalcon_array_fetch(&attribute_field, column_map, first_primary_key, PH_NOISY); } else { PHALCON_INIT_VAR(exception_message); PHALCON_CONCAT_SVS(exception_message, "Column '", first_primary_key, "\" isn't part of the column map"); PHALCON_THROW_EXCEPTION_ZVAL(phalcon_mvc_model_exception_ce, exception_message); return; } } else { PHALCON_CPY_WRT(attribute_field, first_primary_key); } PHALCON_INIT_VAR(primary_key_condition); PHALCON_CONCAT_SVSVSV(primary_key_condition, "[", model, "].[", attribute_field, "] = ", conditions); PHALCON_CPY_WRT(conditions, primary_key_condition); ZVAL_BOOL(no_primary, 0); } } /** * A primary key is mandatory in these cases */ if (PHALCON_IS_TRUE(no_primary)) { PHALCON_THROW_EXCEPTION_STR(phalcon_mvc_model_exception_ce, "Source related to this model does not have a primary key defined"); return; } } PHALCON_INIT_VAR(phql); ZVAL_STRING(phql, "SELECT ", 1); PHALCON_OBS_VAR(columns); phalcon_read_property_this(&columns, this_ptr, SL("_columns"), PH_NOISY_CC); if (Z_TYPE_P(columns) != IS_NULL) { /** * Generate PHQL for columns */ if (Z_TYPE_P(columns) == IS_ARRAY) { PHALCON_INIT_VAR(selected_columns); array_init(selected_columns); phalcon_is_iterable(columns, &ah0, &hp0, 0, 0); while (zend_hash_get_current_data_ex(ah0, (void**) &hd, &hp0) == SUCCESS) { PHALCON_GET_HKEY(column_alias, ah0, hp0); PHALCON_GET_HVALUE(column); if (Z_TYPE_P(column_alias) == IS_LONG) { phalcon_array_append(&selected_columns, column, PH_SEPARATE); } else { PHALCON_INIT_NVAR(aliased_column); PHALCON_CONCAT_VSV(aliased_column, column, " AS ", column_alias); phalcon_array_append(&selected_columns, aliased_column, PH_SEPARATE); } zend_hash_move_forward_ex(ah0, &hp0); } PHALCON_INIT_VAR(joined_columns); phalcon_fast_join_str(joined_columns, SL(", "), selected_columns TSRMLS_CC); phalcon_concat_self(&phql, joined_columns TSRMLS_CC); } else { phalcon_concat_self(&phql, columns TSRMLS_CC); } } else { /** * Automatically generate an array of models */ if (Z_TYPE_P(models) == IS_ARRAY) { PHALCON_INIT_NVAR(selected_columns); array_init(selected_columns); phalcon_is_iterable(models, &ah1, &hp1, 0, 0); while (zend_hash_get_current_data_ex(ah1, (void**) &hd, &hp1) == SUCCESS) { PHALCON_GET_HKEY(model_column_alias, ah1, hp1); PHALCON_GET_HVALUE(model); if (Z_TYPE_P(model_column_alias) == IS_LONG) { PHALCON_INIT_NVAR(selected_column); PHALCON_CONCAT_SVS(selected_column, "[", model, "].*"); } else { PHALCON_INIT_NVAR(selected_column); PHALCON_CONCAT_SVS(selected_column, "[", model_column_alias, "].*"); } phalcon_array_append(&selected_columns, selected_column, PH_SEPARATE); zend_hash_move_forward_ex(ah1, &hp1); } PHALCON_INIT_NVAR(joined_columns); phalcon_fast_join_str(joined_columns, SL(", "), selected_columns TSRMLS_CC); phalcon_concat_self(&phql, joined_columns TSRMLS_CC); } else { PHALCON_SCONCAT_SVS(phql, "[", models, "].*"); } } /** * Join multiple models or use a single one if it is a string */ if (Z_TYPE_P(models) == IS_ARRAY) { PHALCON_INIT_VAR(selected_models); array_init(selected_models); phalcon_is_iterable(models, &ah2, &hp2, 0, 0); while (zend_hash_get_current_data_ex(ah2, (void**) &hd, &hp2) == SUCCESS) { PHALCON_GET_HKEY(model_alias, ah2, hp2); PHALCON_GET_HVALUE(model); if (Z_TYPE_P(model_alias) == IS_STRING) { PHALCON_INIT_NVAR(selected_model); PHALCON_CONCAT_SVSVS(selected_model, "[", model, "] AS [", model_alias, "]"); } else { PHALCON_INIT_NVAR(selected_model); PHALCON_CONCAT_SVS(selected_model, "[", model, "]"); } phalcon_array_append(&selected_models, selected_model, PH_SEPARATE); zend_hash_move_forward_ex(ah2, &hp2); } PHALCON_INIT_VAR(joined_models); phalcon_fast_join_str(joined_models, SL(", "), selected_models TSRMLS_CC); PHALCON_SCONCAT_SV(phql, " FROM ", joined_models); } else { PHALCON_SCONCAT_SVS(phql, " FROM [", models, "]"); } /** * Check if joins were passed to the builders */ PHALCON_OBS_VAR(joins); phalcon_read_property_this(&joins, this_ptr, SL("_joins"), PH_NOISY_CC); if (Z_TYPE_P(joins) == IS_ARRAY) { phalcon_is_iterable(joins, &ah3, &hp3, 0, 0); while (zend_hash_get_current_data_ex(ah3, (void**) &hd, &hp3) == SUCCESS) { PHALCON_GET_HVALUE(join); /** * The joined table is in the first place of the array */ PHALCON_OBS_NVAR(join_model); phalcon_array_fetch_long(&join_model, join, 0, PH_NOISY); /** * The join conditions are in the second place of the array */ PHALCON_OBS_NVAR(join_conditions); phalcon_array_fetch_long(&join_conditions, join, 1, PH_NOISY); /** * The join alias is in the second place of the array */ PHALCON_OBS_NVAR(join_alias); phalcon_array_fetch_long(&join_alias, join, 2, PH_NOISY); /** * Join type */ PHALCON_OBS_NVAR(join_type); phalcon_array_fetch_long(&join_type, join, 3, PH_NOISY); /** * Create the join according to the type */ if (zend_is_true(join_type)) { PHALCON_SCONCAT_SVSVS(phql, " ", join_type, " JOIN [", join_model, "]"); } else { PHALCON_SCONCAT_SVS(phql, " JOIN [", join_model, "]"); } /** * Alias comes first */ if (zend_is_true(join_alias)) { PHALCON_SCONCAT_SVS(phql, " AS [", join_alias, "]"); } /** * Conditions then */ if (zend_is_true(join_conditions)) { PHALCON_SCONCAT_SV(phql, " ON ", join_conditions); } zend_hash_move_forward_ex(ah3, &hp3); } } /** * Only append conditions if it's string */ if (Z_TYPE_P(conditions) == IS_STRING) { if (PHALCON_IS_NOT_EMPTY(conditions)) { PHALCON_SCONCAT_SV(phql, " WHERE ", conditions); } } /** * Process group parameters */ PHALCON_OBS_VAR(group); phalcon_read_property_this(&group, this_ptr, SL("_group"), PH_NOISY_CC); if (Z_TYPE_P(group) != IS_NULL) { if (Z_TYPE_P(group) == IS_ARRAY) { PHALCON_INIT_VAR(group_items); array_init(group_items); phalcon_is_iterable(group, &ah4, &hp4, 0, 0); while (zend_hash_get_current_data_ex(ah4, (void**) &hd, &hp4) == SUCCESS) { PHALCON_GET_HVALUE(group_item); if (phalcon_is_numeric(group_item)) { phalcon_array_append(&group_items, group_item, PH_SEPARATE); } else { if (phalcon_memnstr_str(group_item, SL("."))) { phalcon_array_append(&group_items, group_item, PH_SEPARATE); } else { PHALCON_INIT_NVAR(escaped_item); PHALCON_CONCAT_SVS(escaped_item, "[", group_item, "]"); phalcon_array_append(&group_items, escaped_item, PH_SEPARATE); } } zend_hash_move_forward_ex(ah4, &hp4); } PHALCON_INIT_VAR(joined_items); phalcon_fast_join_str(joined_items, SL(", "), group_items TSRMLS_CC); PHALCON_SCONCAT_SV(phql, " GROUP BY ", joined_items); } else { if (phalcon_is_numeric(group)) { PHALCON_SCONCAT_SV(phql, " GROUP BY ", group); } else { if (phalcon_memnstr_str(group, SL("."))) { PHALCON_SCONCAT_SV(phql, " GROUP BY ", group); } else { PHALCON_SCONCAT_SVS(phql, " GROUP BY [", group, "]"); } } } PHALCON_OBS_VAR(having); phalcon_read_property_this(&having, this_ptr, SL("_having"), PH_NOISY_CC); if (Z_TYPE_P(having) != IS_NULL) { if (PHALCON_IS_NOT_EMPTY(having)) { PHALCON_SCONCAT_SV(phql, " HAVING ", having); } } } /** * Process order clause */ PHALCON_OBS_VAR(order); phalcon_read_property_this(&order, this_ptr, SL("_order"), PH_NOISY_CC); if (Z_TYPE_P(order) != IS_NULL) { if (Z_TYPE_P(order) == IS_ARRAY) { PHALCON_INIT_VAR(order_items); array_init(order_items); phalcon_is_iterable(order, &ah5, &hp5, 0, 0); while (zend_hash_get_current_data_ex(ah5, (void**) &hd, &hp5) == SUCCESS) { PHALCON_GET_HVALUE(order_item); if (phalcon_is_numeric(order_item)) { phalcon_array_append(&order_items, order_item, PH_SEPARATE); } else { if (phalcon_memnstr_str(order_item, SL("."))) { phalcon_array_append(&order_items, order_item, PH_SEPARATE); } else { PHALCON_INIT_NVAR(escaped_item); PHALCON_CONCAT_SVS(escaped_item, "[", order_item, "]"); phalcon_array_append(&order_items, escaped_item, PH_SEPARATE); } } zend_hash_move_forward_ex(ah5, &hp5); } PHALCON_INIT_NVAR(joined_items); phalcon_fast_join_str(joined_items, SL(", "), order_items TSRMLS_CC); PHALCON_SCONCAT_SV(phql, " ORDER BY ", joined_items); } else { PHALCON_SCONCAT_SV(phql, " ORDER BY ", order); } } /** * Process limit parameters */ PHALCON_OBS_VAR(limit); phalcon_read_property_this(&limit, this_ptr, SL("_limit"), PH_NOISY_CC); if (Z_TYPE_P(limit) != IS_NULL) { if (Z_TYPE_P(limit) == IS_ARRAY) { PHALCON_OBS_VAR(number); phalcon_array_fetch_string(&number, limit, SL("number"), PH_NOISY); if (phalcon_array_isset_string(limit, SS("offset"))) { PHALCON_OBS_VAR(offset); phalcon_array_fetch_string(&offset, limit, SL("offset"), PH_NOISY); if (phalcon_is_numeric(offset)) { PHALCON_SCONCAT_SVSV(phql, " LIMIT ", number, " OFFSET ", offset); } else { PHALCON_SCONCAT_SVS(phql, " LIMIT ", number, " OFFSET 0"); } } else { PHALCON_SCONCAT_SV(phql, " LIMIT ", number); } } else { if (phalcon_is_numeric(limit)) { PHALCON_SCONCAT_SV(phql, " LIMIT ", limit); PHALCON_OBS_NVAR(offset); phalcon_read_property_this(&offset, this_ptr, SL("_offset"), PH_NOISY_CC); if (Z_TYPE_P(offset) != IS_NULL) { if (phalcon_is_numeric(offset)) { PHALCON_SCONCAT_SV(phql, " OFFSET ", offset); } else { phalcon_concat_self_str(&phql, SL(" OFFSET 0") TSRMLS_CC); } } } } } RETURN_CTOR(phql); }
/** * Fires an event in the events manager causing that active listeners be notified about it * *<code> * $eventsManager->fire('db', $connection); *</code> * * @param string $eventType * @param object $source * @param mixed $data * @param int $cancelable * @return mixed */ PHP_METHOD(Phalcon_Events_Manager, fire){ zval *event_type, *source, *data = NULL, *cancelable = NULL, *events; zval *exception_message, *event_parts, *type; zval *event_name, *status = NULL, *collect, *event = NULL, *fire_events = NULL; PHALCON_MM_GROW(); phalcon_fetch_params(1, 2, 2, &event_type, &source, &data, &cancelable); if (!data) { PHALCON_INIT_VAR(data); } if (!cancelable) { PHALCON_INIT_VAR(cancelable); ZVAL_BOOL(cancelable, 1); } if (unlikely(Z_TYPE_P(event_type) != IS_STRING)) { PHALCON_THROW_EXCEPTION_STR(phalcon_events_exception_ce, "Event type must be a string"); return; } PHALCON_OBS_VAR(events); phalcon_read_property_this(&events, this_ptr, SL("_events"), PH_NOISY_CC); if (Z_TYPE_P(events) != IS_ARRAY) { RETURN_MM_NULL(); } /** * All valid events must have a colon separator */ if (!phalcon_memnstr_str(event_type, SL(":"))) { PHALCON_INIT_VAR(exception_message); PHALCON_CONCAT_SV(exception_message, "Invalid event type ", event_type); PHALCON_THROW_EXCEPTION_ZVAL(phalcon_events_exception_ce, exception_message); return; } PHALCON_INIT_VAR(event_parts); phalcon_fast_explode_str(event_parts, SL(":"), event_type); PHALCON_OBS_VAR(type); phalcon_array_fetch_long(&type, event_parts, 0, PH_NOISY); PHALCON_OBS_VAR(event_name); phalcon_array_fetch_long(&event_name, event_parts, 1, PH_NOISY); PHALCON_INIT_VAR(status); /** * Responses must be traced? */ PHALCON_OBS_VAR(collect); phalcon_read_property_this(&collect, this_ptr, SL("_collect"), PH_NOISY_CC); if (zend_is_true(collect)) { phalcon_update_property_null(this_ptr, SL("_responses") TSRMLS_CC); } PHALCON_INIT_VAR(event); /** * Check if events are grouped by type */ if (phalcon_array_isset(events, type)) { PHALCON_OBS_VAR(fire_events); phalcon_array_fetch(&fire_events, events, type, PH_NOISY); if (Z_TYPE_P(fire_events) == IS_ARRAY || Z_TYPE_P(fire_events) == IS_OBJECT) { /** * Create the event context */ object_init_ex(event, phalcon_events_event_ce); phalcon_call_method_p4_noret(event, "__construct", event_name, source, data, cancelable); /** * Call the events queue */ phalcon_call_method_p2(status, this_ptr, "firequeue", fire_events, event); } } /** * Check if there are listeners for the event type itself */ if (phalcon_array_isset(events, event_type)) { PHALCON_OBS_NVAR(fire_events); phalcon_array_fetch(&fire_events, events, event_type, PH_NOISY); if (Z_TYPE_P(fire_events) == IS_ARRAY || Z_TYPE_P(fire_events) == IS_OBJECT) { /** * Create the event if it wasn't created before */ if (Z_TYPE_P(event) == IS_NULL) { PHALCON_INIT_NVAR(event); object_init_ex(event, phalcon_events_event_ce); phalcon_call_method_p4_noret(event, "__construct", event_name, source, data, cancelable); } /** * Call the events queue */ PHALCON_INIT_NVAR(status); phalcon_call_method_p2(status, this_ptr, "firequeue", fire_events, event); } } RETURN_CCTOR(status); }
PHPAPI int php_var_unserialize(UNSERIALIZE_PARAMETER) { const unsigned char *cursor, *limit, *marker, *start; zval **rval_ref; limit = cursor = *p; if (var_hash && cursor[0] != 'R') { var_push(var_hash, rval); } start = cursor; #line 411 "ext/standard/var_unserializer.c" { YYCTYPE yych; if ((YYLIMIT - YYCURSOR) < 7) YYFILL(7); yych = *YYCURSOR; switch (yych) { case 'C': case 'O': goto yy13; case 'N': goto yy5; case 'R': goto yy2; case 'S': goto yy10; case 'a': goto yy11; case 'b': goto yy6; case 'd': goto yy8; case 'i': goto yy7; case 'o': goto yy12; case 'r': goto yy4; case 's': goto yy9; case '}': goto yy14; default: goto yy16; } yy2: yych = *(YYMARKER = ++YYCURSOR); switch (yych) { case ':': goto yy95; default: goto yy3; } yy3: #line 733 "ext/standard/var_unserializer.re" { return 0; } #line 442 "ext/standard/var_unserializer.c" yy4: yych = *(YYMARKER = ++YYCURSOR); switch (yych) { case ':': goto yy89; default: goto yy3; } yy5: yych = *++YYCURSOR; switch (yych) { case ';': goto yy87; default: goto yy3; } yy6: yych = *(YYMARKER = ++YYCURSOR); switch (yych) { case ':': goto yy83; default: goto yy3; } yy7: yych = *(YYMARKER = ++YYCURSOR); switch (yych) { case ':': goto yy77; default: goto yy3; } yy8: yych = *(YYMARKER = ++YYCURSOR); switch (yych) { case ':': goto yy53; default: goto yy3; } yy9: yych = *(YYMARKER = ++YYCURSOR); switch (yych) { case ':': goto yy46; default: goto yy3; } yy10: yych = *(YYMARKER = ++YYCURSOR); switch (yych) { case ':': goto yy39; default: goto yy3; } yy11: yych = *(YYMARKER = ++YYCURSOR); switch (yych) { case ':': goto yy32; default: goto yy3; } yy12: yych = *(YYMARKER = ++YYCURSOR); switch (yych) { case ':': goto yy25; default: goto yy3; } yy13: yych = *(YYMARKER = ++YYCURSOR); switch (yych) { case ':': goto yy17; default: goto yy3; } yy14: ++YYCURSOR; #line 727 "ext/standard/var_unserializer.re" { /* this is the case where we have less data than planned */ php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Unexpected end of serialized data"); return 0; /* not sure if it should be 0 or 1 here? */ } #line 511 "ext/standard/var_unserializer.c" yy16: yych = *++YYCURSOR; goto yy3; yy17: yych = *++YYCURSOR; switch (yych) { case '+': goto yy19; case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': goto yy20; default: goto yy18; } yy18: YYCURSOR = YYMARKER; goto yy3; yy19: yych = *++YYCURSOR; switch (yych) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': goto yy20; default: goto yy18; } yy20: ++YYCURSOR; if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2); yych = *YYCURSOR; switch (yych) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': goto yy20; case ':': goto yy22; default: goto yy18; } yy22: yych = *++YYCURSOR; switch (yych) { case '"': goto yy23; default: goto yy18; } yy23: ++YYCURSOR; #line 610 "ext/standard/var_unserializer.re" { size_t len, len2, len3, maxlen; long elements; char *class_name; zend_class_entry *ce; zend_class_entry **pce; int incomplete_class = 0; int custom_object = 0; zval *user_func; zval *retval_ptr; zval **args[1]; zval *arg_func_name; if (*start == 'C') { custom_object = 1; } INIT_PZVAL(*rval); len2 = len = parse_uiv(start + 2); maxlen = max - YYCURSOR; if (maxlen < len || len == 0) { *p = start + 2; return 0; } class_name = (char*)YYCURSOR; YYCURSOR += len; if (*(YYCURSOR) != '"') { *p = YYCURSOR; return 0; } if (*(YYCURSOR+1) != ':') { *p = YYCURSOR+1; return 0; } len3 = strspn(class_name, "0123456789_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ\177\200\201\202\203\204\205\206\207\210\211\212\213\214\215\216\217\220\221\222\223\224\225\226\227\230\231\232\233\234\235\236\237\240\241\242\243\244\245\246\247\250\251\252\253\254\255\256\257\260\261\262\263\264\265\266\267\270\271\272\273\274\275\276\277\300\301\302\303\304\305\306\307\310\311\312\313\314\315\316\317\320\321\322\323\324\325\326\327\330\331\332\333\334\335\336\337\340\341\342\343\344\345\346\347\350\351\352\353\354\355\356\357\360\361\362\363\364\365\366\367\370\371\372\373\374\375\376\377\\"); if (len3 != len) { *p = YYCURSOR + len3 - len; return 0; } class_name = estrndup(class_name, len); do { /* Try to find class directly */ if (zend_lookup_class(class_name, len2, &pce TSRMLS_CC) == SUCCESS) { ce = *pce; break; } /* Check for unserialize callback */ if ((PG(unserialize_callback_func) == NULL) || (PG(unserialize_callback_func)[0] == '\0')) { incomplete_class = 1; ce = PHP_IC_ENTRY; break; } /* Call unserialize callback */ MAKE_STD_ZVAL(user_func); ZVAL_STRING(user_func, PG(unserialize_callback_func), 1); args[0] = &arg_func_name; MAKE_STD_ZVAL(arg_func_name); ZVAL_STRING(arg_func_name, class_name, 1); if (call_user_function_ex(CG(function_table), NULL, user_func, &retval_ptr, 1, args, 0, NULL TSRMLS_CC) != SUCCESS) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "defined (%s) but not found", user_func->value.str.val); incomplete_class = 1; ce = PHP_IC_ENTRY; zval_ptr_dtor(&user_func); zval_ptr_dtor(&arg_func_name); break; } if (retval_ptr) { zval_ptr_dtor(&retval_ptr); } /* The callback function may have defined the class */ if (zend_lookup_class(class_name, len2, &pce TSRMLS_CC) == SUCCESS) { ce = *pce; } else { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Function %s() hasn't defined the class it was called for", user_func->value.str.val); incomplete_class = 1; ce = PHP_IC_ENTRY; } zval_ptr_dtor(&user_func); zval_ptr_dtor(&arg_func_name); break; } while (1); *p = YYCURSOR; if (custom_object) { int ret = object_custom(UNSERIALIZE_PASSTHRU, ce); if (ret && incomplete_class) { php_store_class_name(*rval, class_name, len2); } efree(class_name); return ret; } elements = object_common1(UNSERIALIZE_PASSTHRU, ce); if (incomplete_class) { php_store_class_name(*rval, class_name, len2); } efree(class_name); return object_common2(UNSERIALIZE_PASSTHRU, elements); } #line 692 "ext/standard/var_unserializer.c" yy25: yych = *++YYCURSOR; switch (yych) { case '+': case '-': goto yy26; case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': goto yy27; default: goto yy18; } yy26: yych = *++YYCURSOR; switch (yych) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': goto yy27; default: goto yy18; } yy27: ++YYCURSOR; if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2); yych = *YYCURSOR; switch (yych) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': goto yy27; case ':': goto yy29; default: goto yy18; } yy29: yych = *++YYCURSOR; switch (yych) { case '"': goto yy30; default: goto yy18; } yy30: ++YYCURSOR; #line 602 "ext/standard/var_unserializer.re" { INIT_PZVAL(*rval); return object_common2(UNSERIALIZE_PASSTHRU, object_common1(UNSERIALIZE_PASSTHRU, ZEND_STANDARD_CLASS_DEF_PTR)); } #line 759 "ext/standard/var_unserializer.c" yy32: yych = *++YYCURSOR; switch (yych) { case '+': goto yy33; case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': goto yy34; default: goto yy18; } yy33: yych = *++YYCURSOR; switch (yych) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': goto yy34; default: goto yy18; } yy34: ++YYCURSOR; if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2); yych = *YYCURSOR; switch (yych) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': goto yy34; case ':': goto yy36; default: goto yy18; } yy36: yych = *++YYCURSOR; switch (yych) { case '{': goto yy37; default: goto yy18; } yy37: ++YYCURSOR; #line 582 "ext/standard/var_unserializer.re" { long elements = parse_iv(start + 2); /* use iv() not uiv() in order to check data range */ *p = YYCURSOR; if (elements < 0) { return 0; } INIT_PZVAL(*rval); array_init_size(*rval, elements); if (!process_nested_data(UNSERIALIZE_PASSTHRU, Z_ARRVAL_PP(rval), elements)) { return 0; } return finish_nested_data(UNSERIALIZE_PASSTHRU); } #line 837 "ext/standard/var_unserializer.c" yy39: yych = *++YYCURSOR; switch (yych) { case '+': goto yy40; case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': goto yy41; default: goto yy18; } yy40: yych = *++YYCURSOR; switch (yych) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': goto yy41; default: goto yy18; } yy41: ++YYCURSOR; if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2); yych = *YYCURSOR; switch (yych) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': goto yy41; case ':': goto yy43; default: goto yy18; } yy43: yych = *++YYCURSOR; switch (yych) { case '"': goto yy44; default: goto yy18; } yy44: ++YYCURSOR; #line 553 "ext/standard/var_unserializer.re" { size_t len, maxlen; char *str; len = parse_uiv(start + 2); maxlen = max - YYCURSOR; if (maxlen < len) { *p = start + 2; return 0; } if ((str = unserialize_str(&YYCURSOR, &len, maxlen)) == NULL) { return 0; } if (*(YYCURSOR) != '"') { efree(str); *p = YYCURSOR; return 0; } YYCURSOR += 2; *p = YYCURSOR; INIT_PZVAL(*rval); ZVAL_STRINGL(*rval, str, len, 0); return 1; } #line 924 "ext/standard/var_unserializer.c" yy46: yych = *++YYCURSOR; switch (yych) { case '+': goto yy47; case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': goto yy48; default: goto yy18; } yy47: yych = *++YYCURSOR; switch (yych) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': goto yy48; default: goto yy18; } yy48: ++YYCURSOR; if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2); yych = *YYCURSOR; switch (yych) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': goto yy48; case ':': goto yy50; default: goto yy18; } yy50: yych = *++YYCURSOR; switch (yych) { case '"': goto yy51; default: goto yy18; } yy51: ++YYCURSOR; #line 525 "ext/standard/var_unserializer.re" { size_t len, maxlen; char *str; len = parse_uiv(start + 2); maxlen = max - YYCURSOR; if (maxlen < len) { *p = start + 2; return 0; } str = (char*)YYCURSOR; YYCURSOR += len; if (*(YYCURSOR) != '"') { *p = YYCURSOR; return 0; } YYCURSOR += 2; *p = YYCURSOR; INIT_PZVAL(*rval); ZVAL_STRINGL(*rval, str, len, 1); return 1; } #line 1010 "ext/standard/var_unserializer.c" yy53: yych = *++YYCURSOR; switch (yych) { case '+': goto yy57; case '-': goto yy55; case '.': goto yy60; case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': goto yy58; case 'I': goto yy56; case 'N': goto yy54; default: goto yy18; } yy54: yych = *++YYCURSOR; switch (yych) { case 'A': goto yy76; default: goto yy18; } yy55: yych = *++YYCURSOR; switch (yych) { case '.': goto yy60; case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': goto yy58; case 'I': goto yy56; default: goto yy18; } yy56: yych = *++YYCURSOR; switch (yych) { case 'N': goto yy72; default: goto yy18; } yy57: yych = *++YYCURSOR; switch (yych) { case '.': goto yy60; case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': goto yy58; default: goto yy18; } yy58: ++YYCURSOR; if ((YYLIMIT - YYCURSOR) < 4) YYFILL(4); yych = *YYCURSOR; switch (yych) { case '.': goto yy70; case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': goto yy58; case ';': goto yy63; case 'E': case 'e': goto yy65; default: goto yy18; } yy60: yych = *++YYCURSOR; switch (yych) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': goto yy61; default: goto yy18; } yy61: ++YYCURSOR; if ((YYLIMIT - YYCURSOR) < 4) YYFILL(4); yych = *YYCURSOR; switch (yych) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': goto yy61; case ';': goto yy63; case 'E': case 'e': goto yy65; default: goto yy18; } yy63: ++YYCURSOR; #line 515 "ext/standard/var_unserializer.re" { #if SIZEOF_LONG == 4 use_double: #endif *p = YYCURSOR; INIT_PZVAL(*rval); ZVAL_DOUBLE(*rval, zend_strtod((const char *)start + 2, NULL)); return 1; } #line 1144 "ext/standard/var_unserializer.c" yy65: yych = *++YYCURSOR; switch (yych) { case '+': case '-': goto yy66; case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': goto yy67; default: goto yy18; } yy66: yych = *++YYCURSOR; switch (yych) { case '+': case '-': goto yy69; case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': goto yy67; default: goto yy18; } yy67: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); yych = *YYCURSOR; switch (yych) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': goto yy67; case ';': goto yy63; default: goto yy18; } yy69: yych = *++YYCURSOR; switch (yych) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': goto yy67; default: goto yy18; } yy70: ++YYCURSOR; if ((YYLIMIT - YYCURSOR) < 4) YYFILL(4); yych = *YYCURSOR; switch (yych) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': goto yy70; case ';': goto yy63; case 'E': case 'e': goto yy65; default: goto yy18; } yy72: yych = *++YYCURSOR; switch (yych) { case 'F': goto yy73; default: goto yy18; } yy73: yych = *++YYCURSOR; switch (yych) { case ';': goto yy74; default: goto yy18; } yy74: ++YYCURSOR; #line 500 "ext/standard/var_unserializer.re" { *p = YYCURSOR; INIT_PZVAL(*rval); if (!strncmp(start + 2, "NAN", 3)) { ZVAL_DOUBLE(*rval, php_get_nan()); } else if (!strncmp(start + 2, "INF", 3)) { ZVAL_DOUBLE(*rval, php_get_inf()); } else if (!strncmp(start + 2, "-INF", 4)) { ZVAL_DOUBLE(*rval, -php_get_inf()); } return 1; } #line 1261 "ext/standard/var_unserializer.c" yy76: yych = *++YYCURSOR; switch (yych) { case 'N': goto yy73; default: goto yy18; } yy77: yych = *++YYCURSOR; switch (yych) { case '+': case '-': goto yy78; case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': goto yy79; default: goto yy18; } yy78: yych = *++YYCURSOR; switch (yych) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': goto yy79; default: goto yy18; } yy79: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); yych = *YYCURSOR; switch (yych) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': goto yy79; case ';': goto yy81; default: goto yy18; } yy81: ++YYCURSOR; #line 473 "ext/standard/var_unserializer.re" { #if SIZEOF_LONG == 4 int digits = YYCURSOR - start - 3; if (start[2] == '-' || start[2] == '+') { digits--; } /* Use double for large long values that were serialized on a 64-bit system */ if (digits >= MAX_LENGTH_OF_LONG - 1) { if (digits == MAX_LENGTH_OF_LONG - 1) { int cmp = strncmp(YYCURSOR - MAX_LENGTH_OF_LONG, long_min_digits, MAX_LENGTH_OF_LONG - 1); if (!(cmp < 0 || (cmp == 0 && start[2] == '-'))) { goto use_double; } } else { goto use_double; } } #endif *p = YYCURSOR; INIT_PZVAL(*rval); ZVAL_LONG(*rval, parse_iv(start + 2)); return 1; } #line 1347 "ext/standard/var_unserializer.c" yy83: yych = *++YYCURSOR; switch (yych) { case '0': case '1': goto yy84; default: goto yy18; } yy84: yych = *++YYCURSOR; switch (yych) { case ';': goto yy85; default: goto yy18; } yy85: ++YYCURSOR; #line 466 "ext/standard/var_unserializer.re" { *p = YYCURSOR; INIT_PZVAL(*rval); ZVAL_BOOL(*rval, parse_iv(start + 2)); return 1; } #line 1370 "ext/standard/var_unserializer.c" yy87: ++YYCURSOR; #line 459 "ext/standard/var_unserializer.re" { *p = YYCURSOR; INIT_PZVAL(*rval); ZVAL_NULL(*rval); return 1; } #line 1380 "ext/standard/var_unserializer.c" yy89: yych = *++YYCURSOR; switch (yych) { case '+': case '-': goto yy90; case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': goto yy91; default: goto yy18; } yy90: yych = *++YYCURSOR; switch (yych) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': goto yy91; default: goto yy18; } yy91: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); yych = *YYCURSOR; switch (yych) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': goto yy91; case ';': goto yy93; default: goto yy18; } yy93: ++YYCURSOR; #line 436 "ext/standard/var_unserializer.re" { long id; *p = YYCURSOR; if (!var_hash) return 0; id = parse_iv(start + 2) - 1; if (id == -1 || var_access(var_hash, id, &rval_ref) != SUCCESS) { return 0; } if (*rval == *rval_ref) return 0; if (*rval != NULL) { zval_ptr_dtor(rval); } *rval = *rval_ref; Z_ADDREF_PP(rval); Z_UNSET_ISREF_PP(rval); return 1; } #line 1456 "ext/standard/var_unserializer.c" yy95: yych = *++YYCURSOR; switch (yych) { case '+': case '-': goto yy96; case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': goto yy97; default: goto yy18; } yy96: yych = *++YYCURSOR; switch (yych) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': goto yy97; default: goto yy18; } yy97: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); yych = *YYCURSOR; switch (yych) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': goto yy97; case ';': goto yy99; default: goto yy18; } yy99: ++YYCURSOR; #line 415 "ext/standard/var_unserializer.re" { long id; *p = YYCURSOR; if (!var_hash) return 0; id = parse_iv(start + 2) - 1; if (id == -1 || var_access(var_hash, id, &rval_ref) != SUCCESS) { return 0; } if (*rval != NULL) { zval_ptr_dtor(rval); } *rval = *rval_ref; Z_ADDREF_PP(rval); Z_SET_ISREF_PP(rval); return 1; } #line 1530 "ext/standard/var_unserializer.c" } #line 735 "ext/standard/var_unserializer.re" return 0; }
/** * Phalcon\Di\FactoryDefault constructor */ PHP_METHOD(Phalcon_Di_FactoryDefault, __construct) { zval *_2 = NULL, *_3 = NULL, *_4 = NULL, *_5 = NULL; zval *_1; int ZEPHIR_LAST_CALL_STATUS; zephir_fcall_cache_entry *_0 = NULL, *_6 = NULL; ZEPHIR_MM_GROW(); ZEPHIR_CALL_PARENT(NULL, phalcon_di_factorydefault_ce, this_ptr, "__construct", &_0, 77); zephir_check_call_status(); ZEPHIR_INIT_VAR(_1); zephir_create_array(_1, 21, 0 TSRMLS_CC); ZEPHIR_INIT_VAR(_2); object_init_ex(_2, phalcon_di_service_ce); ZEPHIR_INIT_VAR(_3); ZVAL_STRING(_3, "router", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_VAR(_4); ZVAL_STRING(_4, "Phalcon\\Mvc\\Router", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_VAR(_5); ZVAL_BOOL(_5, 1); ZEPHIR_CALL_METHOD(NULL, _2, "__construct", &_6, 65, _3, _4, _5); zephir_check_temp_parameter(_3); zephir_check_temp_parameter(_4); zephir_check_call_status(); zephir_array_update_string(&_1, SL("router"), &_2, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_2); object_init_ex(_2, phalcon_di_service_ce); ZEPHIR_INIT_NVAR(_3); ZVAL_STRING(_3, "dispatcher", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_4); ZVAL_STRING(_4, "Phalcon\\Mvc\\Dispatcher", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_5); ZVAL_BOOL(_5, 1); ZEPHIR_CALL_METHOD(NULL, _2, "__construct", &_6, 65, _3, _4, _5); zephir_check_temp_parameter(_3); zephir_check_temp_parameter(_4); zephir_check_call_status(); zephir_array_update_string(&_1, SL("dispatcher"), &_2, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_2); object_init_ex(_2, phalcon_di_service_ce); ZEPHIR_INIT_NVAR(_3); ZVAL_STRING(_3, "url", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_4); ZVAL_STRING(_4, "Phalcon\\Mvc\\Url", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_5); ZVAL_BOOL(_5, 1); ZEPHIR_CALL_METHOD(NULL, _2, "__construct", &_6, 65, _3, _4, _5); zephir_check_temp_parameter(_3); zephir_check_temp_parameter(_4); zephir_check_call_status(); zephir_array_update_string(&_1, SL("url"), &_2, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_2); object_init_ex(_2, phalcon_di_service_ce); ZEPHIR_INIT_NVAR(_3); ZVAL_STRING(_3, "modelsManager", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_4); ZVAL_STRING(_4, "Phalcon\\Mvc\\Model\\Manager", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_5); ZVAL_BOOL(_5, 1); ZEPHIR_CALL_METHOD(NULL, _2, "__construct", &_6, 65, _3, _4, _5); zephir_check_temp_parameter(_3); zephir_check_temp_parameter(_4); zephir_check_call_status(); zephir_array_update_string(&_1, SL("modelsManager"), &_2, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_2); object_init_ex(_2, phalcon_di_service_ce); ZEPHIR_INIT_NVAR(_3); ZVAL_STRING(_3, "modelsMetadata", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_4); ZVAL_STRING(_4, "Phalcon\\Mvc\\Model\\MetaData\\Memory", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_5); ZVAL_BOOL(_5, 1); ZEPHIR_CALL_METHOD(NULL, _2, "__construct", &_6, 65, _3, _4, _5); zephir_check_temp_parameter(_3); zephir_check_temp_parameter(_4); zephir_check_call_status(); zephir_array_update_string(&_1, SL("modelsMetadata"), &_2, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_2); object_init_ex(_2, phalcon_di_service_ce); ZEPHIR_INIT_NVAR(_3); ZVAL_STRING(_3, "response", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_4); ZVAL_STRING(_4, "Phalcon\\Http\\Response", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_5); ZVAL_BOOL(_5, 1); ZEPHIR_CALL_METHOD(NULL, _2, "__construct", &_6, 65, _3, _4, _5); zephir_check_temp_parameter(_3); zephir_check_temp_parameter(_4); zephir_check_call_status(); zephir_array_update_string(&_1, SL("response"), &_2, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_2); object_init_ex(_2, phalcon_di_service_ce); ZEPHIR_INIT_NVAR(_3); ZVAL_STRING(_3, "cookies", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_4); ZVAL_STRING(_4, "Phalcon\\Http\\Response\\Cookies", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_5); ZVAL_BOOL(_5, 1); ZEPHIR_CALL_METHOD(NULL, _2, "__construct", &_6, 65, _3, _4, _5); zephir_check_temp_parameter(_3); zephir_check_temp_parameter(_4); zephir_check_call_status(); zephir_array_update_string(&_1, SL("cookies"), &_2, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_2); object_init_ex(_2, phalcon_di_service_ce); ZEPHIR_INIT_NVAR(_3); ZVAL_STRING(_3, "request", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_4); ZVAL_STRING(_4, "Phalcon\\Http\\Request", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_5); ZVAL_BOOL(_5, 1); ZEPHIR_CALL_METHOD(NULL, _2, "__construct", &_6, 65, _3, _4, _5); zephir_check_temp_parameter(_3); zephir_check_temp_parameter(_4); zephir_check_call_status(); zephir_array_update_string(&_1, SL("request"), &_2, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_2); object_init_ex(_2, phalcon_di_service_ce); ZEPHIR_INIT_NVAR(_3); ZVAL_STRING(_3, "filter", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_4); ZVAL_STRING(_4, "Phalcon\\Filter", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_5); ZVAL_BOOL(_5, 1); ZEPHIR_CALL_METHOD(NULL, _2, "__construct", &_6, 65, _3, _4, _5); zephir_check_temp_parameter(_3); zephir_check_temp_parameter(_4); zephir_check_call_status(); zephir_array_update_string(&_1, SL("filter"), &_2, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_2); object_init_ex(_2, phalcon_di_service_ce); ZEPHIR_INIT_NVAR(_3); ZVAL_STRING(_3, "escaper", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_4); ZVAL_STRING(_4, "Phalcon\\Escaper", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_5); ZVAL_BOOL(_5, 1); ZEPHIR_CALL_METHOD(NULL, _2, "__construct", &_6, 65, _3, _4, _5); zephir_check_temp_parameter(_3); zephir_check_temp_parameter(_4); zephir_check_call_status(); zephir_array_update_string(&_1, SL("escaper"), &_2, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_2); object_init_ex(_2, phalcon_di_service_ce); ZEPHIR_INIT_NVAR(_3); ZVAL_STRING(_3, "security", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_4); ZVAL_STRING(_4, "Phalcon\\Security", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_5); ZVAL_BOOL(_5, 1); ZEPHIR_CALL_METHOD(NULL, _2, "__construct", &_6, 65, _3, _4, _5); zephir_check_temp_parameter(_3); zephir_check_temp_parameter(_4); zephir_check_call_status(); zephir_array_update_string(&_1, SL("security"), &_2, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_2); object_init_ex(_2, phalcon_di_service_ce); ZEPHIR_INIT_NVAR(_3); ZVAL_STRING(_3, "crypt", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_4); ZVAL_STRING(_4, "Phalcon\\Crypt", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_5); ZVAL_BOOL(_5, 1); ZEPHIR_CALL_METHOD(NULL, _2, "__construct", &_6, 65, _3, _4, _5); zephir_check_temp_parameter(_3); zephir_check_temp_parameter(_4); zephir_check_call_status(); zephir_array_update_string(&_1, SL("crypt"), &_2, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_2); object_init_ex(_2, phalcon_di_service_ce); ZEPHIR_INIT_NVAR(_3); ZVAL_STRING(_3, "annotations", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_4); ZVAL_STRING(_4, "Phalcon\\Annotations\\Adapter\\Memory", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_5); ZVAL_BOOL(_5, 1); ZEPHIR_CALL_METHOD(NULL, _2, "__construct", &_6, 65, _3, _4, _5); zephir_check_temp_parameter(_3); zephir_check_temp_parameter(_4); zephir_check_call_status(); zephir_array_update_string(&_1, SL("annotations"), &_2, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_2); object_init_ex(_2, phalcon_di_service_ce); ZEPHIR_INIT_NVAR(_3); ZVAL_STRING(_3, "flash", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_4); ZVAL_STRING(_4, "Phalcon\\Flash\\Direct", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_5); ZVAL_BOOL(_5, 1); ZEPHIR_CALL_METHOD(NULL, _2, "__construct", &_6, 65, _3, _4, _5); zephir_check_temp_parameter(_3); zephir_check_temp_parameter(_4); zephir_check_call_status(); zephir_array_update_string(&_1, SL("flash"), &_2, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_2); object_init_ex(_2, phalcon_di_service_ce); ZEPHIR_INIT_NVAR(_3); ZVAL_STRING(_3, "flashSession", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_4); ZVAL_STRING(_4, "Phalcon\\Flash\\Session", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_5); ZVAL_BOOL(_5, 1); ZEPHIR_CALL_METHOD(NULL, _2, "__construct", &_6, 65, _3, _4, _5); zephir_check_temp_parameter(_3); zephir_check_temp_parameter(_4); zephir_check_call_status(); zephir_array_update_string(&_1, SL("flashSession"), &_2, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_2); object_init_ex(_2, phalcon_di_service_ce); ZEPHIR_INIT_NVAR(_3); ZVAL_STRING(_3, "tag", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_4); ZVAL_STRING(_4, "Phalcon\\Tag", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_5); ZVAL_BOOL(_5, 1); ZEPHIR_CALL_METHOD(NULL, _2, "__construct", &_6, 65, _3, _4, _5); zephir_check_temp_parameter(_3); zephir_check_temp_parameter(_4); zephir_check_call_status(); zephir_array_update_string(&_1, SL("tag"), &_2, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_2); object_init_ex(_2, phalcon_di_service_ce); ZEPHIR_INIT_NVAR(_3); ZVAL_STRING(_3, "session", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_4); ZVAL_STRING(_4, "Phalcon\\Session\\Adapter\\Files", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_5); ZVAL_BOOL(_5, 1); ZEPHIR_CALL_METHOD(NULL, _2, "__construct", &_6, 65, _3, _4, _5); zephir_check_temp_parameter(_3); zephir_check_temp_parameter(_4); zephir_check_call_status(); zephir_array_update_string(&_1, SL("session"), &_2, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_2); object_init_ex(_2, phalcon_di_service_ce); ZEPHIR_INIT_NVAR(_3); ZVAL_STRING(_3, "sessionBag", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_4); ZVAL_STRING(_4, "Phalcon\\Session\\Bag", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, _2, "__construct", &_6, 65, _3, _4); zephir_check_temp_parameter(_3); zephir_check_temp_parameter(_4); zephir_check_call_status(); zephir_array_update_string(&_1, SL("sessionBag"), &_2, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_2); object_init_ex(_2, phalcon_di_service_ce); ZEPHIR_INIT_NVAR(_3); ZVAL_STRING(_3, "eventsManager", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_4); ZVAL_STRING(_4, "Phalcon\\Events\\Manager", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_5); ZVAL_BOOL(_5, 1); ZEPHIR_CALL_METHOD(NULL, _2, "__construct", &_6, 65, _3, _4, _5); zephir_check_temp_parameter(_3); zephir_check_temp_parameter(_4); zephir_check_call_status(); zephir_array_update_string(&_1, SL("eventsManager"), &_2, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_2); object_init_ex(_2, phalcon_di_service_ce); ZEPHIR_INIT_NVAR(_3); ZVAL_STRING(_3, "transactionManager", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_4); ZVAL_STRING(_4, "Phalcon\\Mvc\\Model\\Transaction\\Manager", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_5); ZVAL_BOOL(_5, 1); ZEPHIR_CALL_METHOD(NULL, _2, "__construct", &_6, 65, _3, _4, _5); zephir_check_temp_parameter(_3); zephir_check_temp_parameter(_4); zephir_check_call_status(); zephir_array_update_string(&_1, SL("transactionManager"), &_2, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_2); object_init_ex(_2, phalcon_di_service_ce); ZEPHIR_INIT_NVAR(_3); ZVAL_STRING(_3, "assets", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_4); ZVAL_STRING(_4, "Phalcon\\Assets\\Manager", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_5); ZVAL_BOOL(_5, 1); ZEPHIR_CALL_METHOD(NULL, _2, "__construct", &_6, 65, _3, _4, _5); zephir_check_temp_parameter(_3); zephir_check_temp_parameter(_4); zephir_check_call_status(); zephir_array_update_string(&_1, SL("assets"), &_2, PH_COPY | PH_SEPARATE); zephir_update_property_this(this_ptr, SL("_services"), _1 TSRMLS_CC); ZEPHIR_MM_RESTORE(); }
/** * Phalcon_Config_Adapter_Ini constructor * * @param string $filePath * @return Phalcon_Config_Adapter_Ini * */ PHP_METHOD(Phalcon_Config_Adapter_Ini, __construct){ zval *file_path = NULL, *config = NULL, *ini_config = NULL, *directives = NULL; zval *section = NULL, *value = NULL, *key = NULL, *directive_parts = NULL; zval *a0 = NULL; zval *c0 = NULL, *c1 = NULL, *c2 = NULL; zval *i0 = NULL; zval *r0 = NULL, *r1 = NULL, *r2 = NULL, *r3 = NULL, *r4 = NULL, *r5 = NULL; zval *t0 = NULL, *t1 = NULL; HashTable *ah0, *ah1; HashPosition hp0, hp1; zval **hd; char *hash_index; uint hash_index_len; ulong hash_num; int hash_type; PHALCON_MM_GROW(); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &file_path) == FAILURE) { PHALCON_MM_RESTORE(); RETURN_NULL(); } PHALCON_INIT_VAR(a0); array_init(a0); PHALCON_CPY_WRT(config, a0); PHALCON_INIT_VAR(c0); ZVAL_BOOL(c0, 1); PHALCON_INIT_VAR(ini_config); PHALCON_CALL_FUNC_PARAMS_2(ini_config, "parse_ini_file", file_path, c0); if (Z_TYPE_P(ini_config) == IS_BOOL && !Z_BVAL_P(ini_config)) { PHALCON_ALLOC_ZVAL_MM(i0); object_init_ex(i0, phalcon_config_exception_ce); PHALCON_ALLOC_ZVAL_MM(r0); PHALCON_ALLOC_ZVAL_MM(r1); PHALCON_CALL_FUNC_PARAMS_1(r1, "basename", file_path); PHALCON_CONCAT_SVS(r0, "Configuration file ", r1, " can't be loaded"); PHALCON_CALL_METHOD_PARAMS_1_NORETURN(i0, "__construct", r0, PHALCON_CHECK); phalcon_throw_exception(i0 TSRMLS_CC); return; } if (phalcon_valid_foreach(ini_config TSRMLS_CC)) { ah0 = Z_ARRVAL_P(ini_config); zend_hash_internal_pointer_reset_ex(ah0, &hp0); fes_b840_0: if(zend_hash_get_current_data_ex(ah0, (void**) &hd, &hp0) != SUCCESS){ goto fee_b840_0; } else { PHALCON_INIT_VAR(section); PHALCON_GET_FOREACH_KEY(section, ah0, hp0); } PHALCON_INIT_VAR(directives); ZVAL_ZVAL(directives, *hd, 1, 0); if (phalcon_valid_foreach(directives TSRMLS_CC)) { ah1 = Z_ARRVAL_P(directives); zend_hash_internal_pointer_reset_ex(ah1, &hp1); fes_b840_1: if(zend_hash_get_current_data_ex(ah1, (void**) &hd, &hp1) != SUCCESS){ goto fee_b840_1; } else { PHALCON_INIT_VAR(key); PHALCON_GET_FOREACH_KEY(key, ah1, hp1); } PHALCON_INIT_VAR(value); ZVAL_ZVAL(value, *hd, 1, 0); PHALCON_INIT_VAR(c1); ZVAL_STRING(c1, ".", 1); PHALCON_INIT_VAR(r2); phalcon_fast_strpos(r2, key, c1 TSRMLS_CC); if (Z_TYPE_P(r2) != IS_BOOL || (Z_TYPE_P(r2) == IS_BOOL && Z_BVAL_P(r2))) { PHALCON_INIT_VAR(c2); ZVAL_STRING(c2, ".", 1); PHALCON_INIT_VAR(r3); phalcon_fast_explode(r3, c2, key TSRMLS_CC); PHALCON_CPY_WRT(directive_parts, r3); if (Z_TYPE_P(config) == IS_ARRAY) { PHALCON_INIT_VAR(t0); phalcon_array_fetch(&t0, config, section, PHALCON_SILENT TSRMLS_CC); } if (Z_REFCOUNT_P(t0) > 1) { phalcon_array_update(&config, section, &t0, PHALCON_NO_SEPARATE_THX, PHALCON_COPY, PHALCON_CTOR TSRMLS_CC); } if (Z_TYPE_P(t0) != IS_ARRAY) { convert_to_array(t0); phalcon_array_update(&config, section, &t0, PHALCON_NO_SEPARATE_THX, PHALCON_COPY, PHALCON_NO_CTOR TSRMLS_CC); } PHALCON_INIT_VAR(r4); phalcon_array_fetch_long(&r4, directive_parts, 0, PHALCON_NOISY TSRMLS_CC); if (Z_TYPE_P(t0) == IS_ARRAY) { PHALCON_INIT_VAR(t1); phalcon_array_fetch(&t1, t0, r4, PHALCON_SILENT TSRMLS_CC); } if (Z_REFCOUNT_P(t1) > 1) { phalcon_array_update(&t0, r4, &t1, PHALCON_NO_SEPARATE_THX, PHALCON_COPY, PHALCON_CTOR TSRMLS_CC); } if (Z_TYPE_P(t1) != IS_ARRAY) { convert_to_array(t1); phalcon_array_update(&t0, r4, &t1, PHALCON_NO_SEPARATE_THX, PHALCON_COPY, PHALCON_NO_CTOR TSRMLS_CC); } PHALCON_INIT_VAR(r5); phalcon_array_fetch_long(&r5, directive_parts, 1, PHALCON_NOISY TSRMLS_CC); phalcon_array_update(&t1, r5, &value, PHALCON_NO_SEPARATE_THX, PHALCON_COPY, PHALCON_NO_CTOR TSRMLS_CC); } else { phalcon_array_update_multi_2(&config, section, key, &value, PHALCON_NO_SEPARATE_THX TSRMLS_CC); } zend_hash_move_forward_ex(ah1, &hp1); goto fes_b840_1; fee_b840_1: if(0){} } else { return; } zend_hash_move_forward_ex(ah0, &hp0); goto fes_b840_0; fee_b840_0: if(0){} } else { return; } PHALCON_CALL_PARENT_PARAMS_1_NORETURN(this_ptr, "Phalcon_Config_Adapter_Ini", "__construct", config); PHALCON_MM_RESTORE(); }
/** * Executes the validation */ PHP_METHOD(Phalcon_Validation_Validator_ExclusionIn, validate) { int ZEPHIR_LAST_CALL_STATUS; zval *field = NULL; zval *validation, *field_param = NULL, *value = NULL, *domain = NULL, *message = NULL, *label = NULL, *replacePairs = NULL, *strict = NULL, *fieldDomain = NULL, *code = NULL, *_0 = NULL, *_1 = NULL, *_4 = NULL, *_2$$6, *_3$$7, *_5$$9 = NULL, *_10$$9 = NULL, *_11$$9, *_6$$10, *_7$$12, *_8$$13, *_9$$14; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &validation, &field_param); if (unlikely(Z_TYPE_P(field_param) != IS_STRING && Z_TYPE_P(field_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'field' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(field_param) == IS_STRING)) { zephir_get_strval(field, field_param); } else { ZEPHIR_INIT_VAR(field); ZVAL_EMPTY_STRING(field); } ZEPHIR_CALL_METHOD(&value, validation, "getvalue", NULL, 0, field); zephir_check_call_status(); ZEPHIR_INIT_VAR(_0); ZVAL_STRING(_0, "domain", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&domain, this_ptr, "getoption", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); ZEPHIR_OBS_VAR(fieldDomain); if (zephir_array_isset_fetch(&fieldDomain, domain, field, 0 TSRMLS_CC)) { if (Z_TYPE_P(fieldDomain) == IS_ARRAY) { ZEPHIR_CPY_WRT(domain, fieldDomain); } } if (Z_TYPE_P(domain) != IS_ARRAY) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_validation_exception_ce, "Option 'domain' must be an array", "phalcon/validation/validator/exclusionin.zep", 74); return; } ZEPHIR_INIT_VAR(strict); ZVAL_BOOL(strict, 0); ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "strict", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_1, this_ptr, "hasoption", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); if (zephir_is_true(_1)) { ZEPHIR_INIT_VAR(_2$$6); ZVAL_STRING(_2$$6, "strict", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&strict, this_ptr, "getoption", NULL, 0, _2$$6); zephir_check_temp_parameter(_2$$6); zephir_check_call_status(); if (Z_TYPE_P(strict) == IS_ARRAY) { zephir_array_fetch(&_3$$7, strict, field, PH_NOISY | PH_READONLY, "phalcon/validation/validator/exclusionin.zep", 83 TSRMLS_CC); ZEPHIR_CPY_WRT(strict, _3$$7); } if (Z_TYPE_P(strict) != IS_BOOL) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_validation_exception_ce, "Option 'strict' must be a boolean", "phalcon/validation/validator/exclusionin.zep", 87); return; } } ZEPHIR_CALL_FUNCTION(&_4, "in_array", NULL, 377, value, domain, strict); zephir_check_call_status(); if (zephir_is_true(_4)) { ZEPHIR_INIT_VAR(_5$$9); ZVAL_STRING(_5$$9, "label", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&label, this_ptr, "getoption", NULL, 0, _5$$9); zephir_check_temp_parameter(_5$$9); zephir_check_call_status(); if (Z_TYPE_P(label) == IS_ARRAY) { zephir_array_fetch(&_6$$10, label, field, PH_NOISY | PH_READONLY, "phalcon/validation/validator/exclusionin.zep", 98 TSRMLS_CC); ZEPHIR_CPY_WRT(label, _6$$10); } if (ZEPHIR_IS_EMPTY(label)) { ZEPHIR_CALL_METHOD(&label, validation, "getlabel", NULL, 0, field); zephir_check_call_status(); } ZEPHIR_INIT_NVAR(_5$$9); ZVAL_STRING(_5$$9, "message", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, this_ptr, "getoption", NULL, 0, _5$$9); zephir_check_temp_parameter(_5$$9); zephir_check_call_status(); if (Z_TYPE_P(message) == IS_ARRAY) { zephir_array_fetch(&_7$$12, message, field, PH_NOISY | PH_READONLY, "phalcon/validation/validator/exclusionin.zep", 106 TSRMLS_CC); ZEPHIR_CPY_WRT(message, _7$$12); } ZEPHIR_INIT_VAR(replacePairs); zephir_create_array(replacePairs, 2, 0 TSRMLS_CC); zephir_array_update_string(&replacePairs, SL(":field"), &label, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_5$$9); zephir_fast_join_str(_5$$9, SL(", "), domain TSRMLS_CC); zephir_array_update_string(&replacePairs, SL(":domain"), &_5$$9, PH_COPY | PH_SEPARATE); if (ZEPHIR_IS_EMPTY(message)) { ZEPHIR_INIT_VAR(_8$$13); ZVAL_STRING(_8$$13, "ExclusionIn", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, validation, "getdefaultmessage", NULL, 0, _8$$13); zephir_check_temp_parameter(_8$$13); zephir_check_call_status(); } ZEPHIR_INIT_NVAR(_5$$9); ZVAL_STRING(_5$$9, "code", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&code, this_ptr, "getoption", NULL, 0, _5$$9); zephir_check_temp_parameter(_5$$9); zephir_check_call_status(); if (Z_TYPE_P(code) == IS_ARRAY) { zephir_array_fetch(&_9$$14, code, field, PH_NOISY | PH_READONLY, "phalcon/validation/validator/exclusionin.zep", 115 TSRMLS_CC); ZEPHIR_CPY_WRT(code, _9$$14); } ZEPHIR_INIT_NVAR(_5$$9); object_init_ex(_5$$9, phalcon_validation_message_ce); ZEPHIR_CALL_FUNCTION(&_10$$9, "strtr", NULL, 26, message, replacePairs); zephir_check_call_status(); ZEPHIR_INIT_VAR(_11$$9); ZVAL_STRING(_11$$9, "ExclusionIn", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, _5$$9, "__construct", NULL, 462, _10$$9, field, _11$$9, code); zephir_check_temp_parameter(_11$$9); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, validation, "appendmessage", NULL, 0, _5$$9); zephir_check_call_status(); RETURN_MM_BOOL(0); } RETURN_MM_BOOL(1); }
static void dom_xpath_ext_function_php(xmlXPathParserContextPtr ctxt, int nargs, int type) /* {{{ */ { zval retval; int result, i; int error = 0; zend_fcall_info fci; xmlXPathObjectPtr obj; char *str; zend_string *callable = NULL; dom_xpath_object *intern; if (! zend_is_executing()) { xmlGenericError(xmlGenericErrorContext, "xmlExtFunctionTest: Function called from outside of PHP\n"); error = 1; } else { intern = (dom_xpath_object *) ctxt->context->userData; if (intern == NULL) { xmlGenericError(xmlGenericErrorContext, "xmlExtFunctionTest: failed to get the internal object\n"); error = 1; } else if (intern->registerPhpFunctions == 0) { xmlGenericError(xmlGenericErrorContext, "xmlExtFunctionTest: PHP Object did not register PHP functions\n"); error = 1; } } if (error == 1) { for (i = nargs - 1; i >= 0; i--) { obj = valuePop(ctxt); xmlXPathFreeObject(obj); } return; } fci.param_count = nargs - 1; if (fci.param_count > 0) { fci.params = safe_emalloc(fci.param_count, sizeof(zval), 0); } /* Reverse order to pop values off ctxt stack */ for (i = nargs - 2; i >= 0; i--) { obj = valuePop(ctxt); switch (obj->type) { case XPATH_STRING: ZVAL_STRING(&fci.params[i], (char *)obj->stringval); break; case XPATH_BOOLEAN: ZVAL_BOOL(&fci.params[i], obj->boolval); break; case XPATH_NUMBER: ZVAL_DOUBLE(&fci.params[i], obj->floatval); break; case XPATH_NODESET: if (type == 1) { str = (char *)xmlXPathCastToString(obj); ZVAL_STRING(&fci.params[i], str); xmlFree(str); } else if (type == 2) { int j; array_init(&fci.params[i]); if (obj->nodesetval && obj->nodesetval->nodeNr > 0) { for (j = 0; j < obj->nodesetval->nodeNr; j++) { xmlNodePtr node = obj->nodesetval->nodeTab[j]; zval child; /* not sure, if we need this... it's copied from xpath.c */ if (node->type == XML_NAMESPACE_DECL) { xmlNsPtr curns; xmlNodePtr nsparent; nsparent = node->_private; curns = xmlNewNs(NULL, node->name, NULL); if (node->children) { curns->prefix = xmlStrdup((xmlChar *) node->children); } if (node->children) { node = xmlNewDocNode(node->doc, NULL, (xmlChar *) node->children, node->name); } else { node = xmlNewDocNode(node->doc, NULL, (xmlChar *) "xmlns", node->name); } node->type = XML_NAMESPACE_DECL; node->parent = nsparent; node->ns = curns; } php_dom_create_object(node, &child, &intern->dom); add_next_index_zval(&fci.params[i], &child); } } } break; default: ZVAL_STRING(&fci.params[i], (char *)xmlXPathCastToString(obj)); } xmlXPathFreeObject(obj); } fci.size = sizeof(fci); fci.function_table = EG(function_table); obj = valuePop(ctxt); if (obj->stringval == NULL) { php_error_docref(NULL, E_WARNING, "Handler name must be a string"); xmlXPathFreeObject(obj); if (fci.param_count > 0) { for (i = 0; i < nargs - 1; i++) { zval_ptr_dtor(&fci.params[i]); } efree(fci.params); } return; } ZVAL_STRING(&fci.function_name, (char *) obj->stringval); xmlXPathFreeObject(obj); fci.symbol_table = NULL; fci.object = NULL; fci.retval = &retval; fci.no_separation = 0; if (!zend_make_callable(&fci.function_name, &callable)) { php_error_docref(NULL, E_WARNING, "Unable to call handler %s()", ZSTR_VAL(callable)); } else if (intern->registerPhpFunctions == 2 && zend_hash_exists(intern->registered_phpfunctions, callable) == 0) { php_error_docref(NULL, E_WARNING, "Not allowed to call handler '%s()'.", ZSTR_VAL(callable)); /* Push an empty string, so that we at least have an xslt result... */ valuePush(ctxt, xmlXPathNewString((xmlChar *)"")); } else { result = zend_call_function(&fci, NULL); if (result == SUCCESS && Z_TYPE(retval) != IS_UNDEF) { if (Z_TYPE(retval) == IS_OBJECT && instanceof_function(Z_OBJCE(retval), dom_node_class_entry)) { xmlNode *nodep; dom_object *obj; if (intern->node_list == NULL) { ALLOC_HASHTABLE(intern->node_list); zend_hash_init(intern->node_list, 0, NULL, ZVAL_PTR_DTOR, 0); } Z_ADDREF(retval); zend_hash_next_index_insert(intern->node_list, &retval); obj = Z_DOMOBJ_P(&retval); nodep = dom_object_get_node(obj); valuePush(ctxt, xmlXPathNewNodeSet(nodep)); } else if (Z_TYPE(retval) == IS_FALSE || Z_TYPE(retval) == IS_TRUE) { valuePush(ctxt, xmlXPathNewBoolean(Z_TYPE(retval) == IS_TRUE)); } else if (Z_TYPE(retval) == IS_OBJECT) { php_error_docref(NULL, E_WARNING, "A PHP Object cannot be converted to a XPath-string"); valuePush(ctxt, xmlXPathNewString((xmlChar *)"")); } else { zend_string *str = zval_get_string(&retval); valuePush(ctxt, xmlXPathNewString((xmlChar *) ZSTR_VAL(str))); zend_string_release(str); } zval_ptr_dtor(&retval); } } zend_string_release(callable); zval_dtor(&fci.function_name); if (fci.param_count > 0) { for (i = 0; i < nargs - 1; i++) { zval_ptr_dtor(&fci.params[i]); } efree(fci.params); } }
/** * Checks for annotations in the public methods of the controller * * @param string $controller * @param string $action * @param Phalcon\Annotations\Annotation $annotation */ PHP_METHOD(Phalcon_Mvc_Router_Annotations, processActionAnnotation){ zval *controller, *action, *annotation, *is_route = NULL; zval *methods = NULL, *name, *action_sufix, *empty_str; zval *real_action_name, *action_name, *route_prefix; zval *parameter = NULL, *paths = NULL, *position, *value, *uri = NULL, *route; zval *converts, *convert = NULL, *param = NULL, *route_name; HashTable *ah0; HashPosition hp0; zval **hd; PHALCON_MM_GROW(); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zzz", &controller, &action, &annotation) == FAILURE) { RETURN_MM_NULL(); } PHALCON_INIT_VAR(is_route); ZVAL_BOOL(is_route, 0); PHALCON_INIT_VAR(methods); PHALCON_INIT_VAR(name); PHALCON_CALL_METHOD(name, annotation, "getname"); /** * Find if the route is for adding routes */ if (PHALCON_IS_STRING(name, "Route")) { ZVAL_BOOL(is_route, 1); } else { if (PHALCON_IS_STRING(name, "Get")) { ZVAL_BOOL(is_route, 1); ZVAL_STRING(methods, "GET", 1); } else { if (PHALCON_IS_STRING(name, "Post")) { ZVAL_BOOL(is_route, 1); PHALCON_INIT_NVAR(methods); ZVAL_STRING(methods, "POST", 1); } else { if (PHALCON_IS_STRING(name, "Put")) { ZVAL_BOOL(is_route, 1); PHALCON_INIT_NVAR(methods); ZVAL_STRING(methods, "PUT", 1); } else { if (PHALCON_IS_STRING(name, "Options")) { ZVAL_BOOL(is_route, 1); PHALCON_INIT_NVAR(methods); ZVAL_STRING(methods, "OPTIONS", 1); } } } } } if (PHALCON_IS_TRUE(is_route)) { PHALCON_OBS_VAR(action_sufix); phalcon_read_property(&action_sufix, this_ptr, SL("_actionSufix"), PH_NOISY_CC); PHALCON_INIT_VAR(empty_str); ZVAL_STRING(empty_str, "", 1); PHALCON_INIT_VAR(real_action_name); phalcon_fast_str_replace(real_action_name, action_sufix, empty_str, action TSRMLS_CC); PHALCON_INIT_VAR(action_name); phalcon_fast_strtolower(action_name, real_action_name); PHALCON_OBS_VAR(route_prefix); phalcon_read_property(&route_prefix, this_ptr, SL("_routePrefix"), PH_NOISY_CC); PHALCON_INIT_VAR(parameter); ZVAL_STRING(parameter, "paths", 1); /** * Check for existing paths in the annotation */ PHALCON_INIT_VAR(paths); PHALCON_CALL_METHOD_PARAMS_1(paths, annotation, "getnamedparameter", parameter); if (Z_TYPE_P(paths) != IS_ARRAY) { PHALCON_INIT_NVAR(paths); array_init(paths); } phalcon_array_update_string(&paths, SL("controller"), &controller, PH_COPY | PH_SEPARATE TSRMLS_CC); phalcon_array_update_string(&paths, SL("action"), &action_name, PH_COPY | PH_SEPARATE TSRMLS_CC); PHALCON_INIT_VAR(position); ZVAL_LONG(position, 0); PHALCON_INIT_VAR(value); PHALCON_CALL_METHOD_PARAMS_1(value, annotation, "getargument", position); /** * Create the route using the prefix */ if (Z_TYPE_P(value) != IS_NULL) { if (!PHALCON_IS_STRING(value, "/")) { PHALCON_INIT_VAR(uri); PHALCON_CONCAT_VV(uri, route_prefix, value); } else { PHALCON_CPY_WRT(uri, route_prefix); } } else { PHALCON_INIT_NVAR(uri); PHALCON_CONCAT_VV(uri, route_prefix, action_name); } /** * Add the route to the router */ PHALCON_INIT_VAR(route); PHALCON_CALL_METHOD_PARAMS_2(route, this_ptr, "add", uri, paths); if (Z_TYPE_P(methods) == IS_NULL) { PHALCON_INIT_NVAR(parameter); ZVAL_STRING(parameter, "methods", 1); PHALCON_INIT_NVAR(methods); PHALCON_CALL_METHOD_PARAMS_1(methods, annotation, "getnamedparameter", parameter); if (Z_TYPE_P(methods) == IS_ARRAY) { PHALCON_CALL_METHOD_PARAMS_1_NORETURN(route, "via", methods); } else { if (Z_TYPE_P(methods) == IS_STRING) { PHALCON_CALL_METHOD_PARAMS_1_NORETURN(route, "via", methods); } } } else { PHALCON_CALL_METHOD_PARAMS_1_NORETURN(route, "via", methods); } PHALCON_INIT_NVAR(parameter); ZVAL_STRING(parameter, "converts", 1); PHALCON_INIT_VAR(converts); PHALCON_CALL_METHOD_PARAMS_1(converts, annotation, "getnamedparameter", parameter); if (Z_TYPE_P(converts) == IS_ARRAY) { if (!phalcon_is_iterable(converts, &ah0, &hp0, 0, 0 TSRMLS_CC)) { return; } while (zend_hash_get_current_data_ex(ah0, (void**) &hd, &hp0) == SUCCESS) { PHALCON_GET_FOREACH_KEY(param, ah0, hp0); PHALCON_GET_FOREACH_VALUE(convert); PHALCON_CALL_METHOD_PARAMS_2_NORETURN(route, "convert", param, convert); zend_hash_move_forward_ex(ah0, &hp0); } } PHALCON_INIT_NVAR(parameter); ZVAL_STRING(parameter, "name", 1); PHALCON_INIT_VAR(route_name); PHALCON_CALL_METHOD_PARAMS_1(route_name, annotation, "getnamedparameter", parameter); if (Z_TYPE_P(route_name) == IS_STRING) { PHALCON_CALL_METHOD_PARAMS_1_NORETURN(route, "setname", route_name); } RETURN_MM_TRUE; } PHALCON_MM_RESTORE(); }
/** * Create/Returns a new transaction or an existing one */ PHP_METHOD(Phalcon_Mvc_Model_Transaction_Manager, getOrCreateTransaction) { HashTable *_2$$5; HashPosition _1$$5; int ZEPHIR_LAST_CALL_STATUS; zval *autoBegin_param = NULL, *dependencyInjector = NULL, *transaction = NULL, *transactions = NULL, *_0, *_5, *_6, **_3$$5, *_4$$7 = NULL; zend_bool autoBegin; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 1, &autoBegin_param); if (!autoBegin_param) { autoBegin = 1; } else { autoBegin = zephir_get_boolval(autoBegin_param); } _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_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_transaction_exception_ce, "A dependency injector container is required to obtain the services related to the ORM", "phalcon/mvc/model/transaction/manager.zep", 188); return; } _0 = zephir_fetch_nproperty_this(this_ptr, SL("_number"), PH_NOISY_CC); if (zephir_is_true(_0)) { ZEPHIR_OBS_VAR(transactions); zephir_read_property_this(&transactions, this_ptr, SL("_transactions"), PH_NOISY_CC); if (Z_TYPE_P(transactions) == IS_ARRAY) { zephir_is_iterable(transactions, &_2$$5, &_1$$5, 0, 1, "phalcon/mvc/model/transaction/manager.zep", 200); for ( ; zephir_hash_get_current_data_ex(_2$$5, (void**) &_3$$5, &_1$$5) == SUCCESS ; zephir_hash_move_backwards_ex(_2$$5, &_1$$5) ) { ZEPHIR_GET_HVALUE(transaction, _3$$5); if (Z_TYPE_P(transaction) == IS_OBJECT) { ZEPHIR_INIT_NVAR(_4$$7); ZVAL_BOOL(_4$$7, 0); ZEPHIR_CALL_METHOD(NULL, transaction, "setisnewtransaction", NULL, 0, _4$$7); zephir_check_call_status(); RETURN_CCTOR(transaction); } } } } ZEPHIR_INIT_NVAR(transaction); object_init_ex(transaction, phalcon_mvc_model_transaction_ce); _5 = zephir_fetch_nproperty_this(this_ptr, SL("_service"), PH_NOISY_CC); ZEPHIR_INIT_VAR(_6); if (autoBegin) { ZVAL_BOOL(_6, 1); } else { ZVAL_BOOL(_6, 0); } ZEPHIR_CALL_METHOD(NULL, transaction, "__construct", NULL, 356, dependencyInjector, _6, _5); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, transaction, "settransactionmanager", NULL, 357, this_ptr); zephir_check_call_status(); zephir_update_property_array_append(this_ptr, SL("_transactions"), transaction TSRMLS_CC); RETURN_ON_FAILURE(zephir_property_incr(this_ptr, SL("_number") TSRMLS_CC)); RETURN_CCTOR(transaction); }
/** * Executes the validation */ PHP_METHOD(Phalcon_Validation_Validator_InclusionIn, validate) { zend_bool _2; int ZEPHIR_LAST_CALL_STATUS; zval *field = NULL; zval *validation, *field_param = NULL, *value = NULL, *domain = NULL, *message = NULL, *label = NULL, *replacePairs, *strict = NULL, *_0 = NULL, *_1 = NULL, *_3 = NULL, *_4 = NULL, *_5 = NULL, *_6; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &validation, &field_param); if (unlikely(Z_TYPE_P(field_param) != IS_STRING && Z_TYPE_P(field_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'field' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(field_param) == IS_STRING)) { zephir_get_strval(field, field_param); } else { ZEPHIR_INIT_VAR(field); ZVAL_EMPTY_STRING(field); } ZEPHIR_CALL_METHOD(&value, validation, "getvalue", NULL, 0, field); zephir_check_call_status(); ZEPHIR_INIT_VAR(_1); ZVAL_STRING(_1, "allowEmpty", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_0, this_ptr, "issetoption", NULL, 0, _1); zephir_check_temp_parameter(_1); zephir_check_call_status(); _2 = zephir_is_true(_0); if (_2) { _2 = ZEPHIR_IS_EMPTY(value); } if (_2) { RETURN_MM_BOOL(1); } ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "domain", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&domain, this_ptr, "getoption", NULL, 0, _1); zephir_check_temp_parameter(_1); zephir_check_call_status(); if (Z_TYPE_P(domain) != IS_ARRAY) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_validation_exception_ce, "Option 'domain' must be an array", "phalcon/validation/validator/inclusionin.zep", 62); return; } ZEPHIR_INIT_VAR(strict); ZVAL_BOOL(strict, 0); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "strict", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_3, this_ptr, "issetoption", NULL, 0, _1); zephir_check_temp_parameter(_1); zephir_check_call_status(); if (zephir_is_true(_3)) { if (Z_TYPE_P(strict) != IS_BOOL) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_validation_exception_ce, "Option 'strict' must be a boolean", "phalcon/validation/validator/inclusionin.zep", 68); return; } ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "strict", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&strict, this_ptr, "getoption", NULL, 0, _1); zephir_check_temp_parameter(_1); zephir_check_call_status(); } ZEPHIR_CALL_FUNCTION(&_4, "in_array", NULL, 365, value, domain, strict); zephir_check_call_status(); if (!(zephir_is_true(_4))) { ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "label", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&label, this_ptr, "getoption", NULL, 0, _1); zephir_check_temp_parameter(_1); zephir_check_call_status(); if (ZEPHIR_IS_EMPTY(label)) { ZEPHIR_CALL_METHOD(&label, validation, "getlabel", NULL, 0, field); zephir_check_call_status(); } ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "message", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, this_ptr, "getoption", NULL, 0, _1); zephir_check_temp_parameter(_1); zephir_check_call_status(); ZEPHIR_INIT_VAR(replacePairs); zephir_create_array(replacePairs, 2, 0 TSRMLS_CC); zephir_array_update_string(&replacePairs, SL(":field"), &label, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_1); zephir_fast_join_str(_1, SL(", "), domain TSRMLS_CC); zephir_array_update_string(&replacePairs, SL(":domain"), &_1, PH_COPY | PH_SEPARATE); if (ZEPHIR_IS_EMPTY(message)) { ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "InclusionIn", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, validation, "getdefaultmessage", NULL, 0, _1); zephir_check_temp_parameter(_1); zephir_check_call_status(); } ZEPHIR_INIT_NVAR(_1); object_init_ex(_1, phalcon_validation_message_ce); ZEPHIR_CALL_FUNCTION(&_5, "strtr", NULL, 53, message, replacePairs); zephir_check_call_status(); ZEPHIR_INIT_VAR(_6); ZVAL_STRING(_6, "InclusionIn", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, _1, "__construct", NULL, 436, _5, field, _6); zephir_check_temp_parameter(_6); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, validation, "appendmessage", NULL, 0, _1); zephir_check_call_status(); RETURN_MM_BOOL(0); } RETURN_MM_BOOL(1); }
/** * Stores cached content into the file backend and stops the frontend * * @param int|string $keyName * @param string $content * @param long $lifetime * @param boolean $stopBuffer */ PHP_METHOD(Phalcon_Cache_Backend_File, save){ zval *key_name = NULL, *content = NULL, *lifetime = NULL, *stop_buffer = NULL; zval *last_key = NULL, *prefix, *frontend, *options, *cache_dir; zval *cache_file, *cached_content = NULL, *prepared_content; zval *status, *is_buffering; PHALCON_MM_GROW(); phalcon_fetch_params(1, 0, 4, &key_name, &content, &lifetime, &stop_buffer); if (!key_name) { PHALCON_INIT_VAR(key_name); } if (!content) { PHALCON_INIT_VAR(content); } if (!lifetime) { PHALCON_INIT_VAR(lifetime); } if (!stop_buffer) { PHALCON_INIT_VAR(stop_buffer); ZVAL_BOOL(stop_buffer, 1); } if (Z_TYPE_P(key_name) == IS_NULL) { PHALCON_OBS_VAR(last_key); phalcon_read_property_this(&last_key, this_ptr, SL("_lastKey"), PH_NOISY_CC); } else { PHALCON_OBS_VAR(prefix); phalcon_read_property_this(&prefix, this_ptr, SL("_prefix"), PH_NOISY_CC); PHALCON_INIT_NVAR(last_key); PHALCON_CONCAT_VV(last_key, prefix, key_name); } if (!zend_is_true(last_key)) { PHALCON_THROW_EXCEPTION_STR(phalcon_cache_exception_ce, "The cache must be started first"); return; } PHALCON_OBS_VAR(frontend); phalcon_read_property_this(&frontend, this_ptr, SL("_frontend"), PH_NOISY_CC); PHALCON_OBS_VAR(options); phalcon_read_property_this(&options, this_ptr, SL("_options"), PH_NOISY_CC); PHALCON_OBS_VAR(cache_dir); phalcon_array_fetch_string(&cache_dir, options, SL("cacheDir"), PH_NOISY); PHALCON_INIT_VAR(cache_file); PHALCON_CONCAT_VV(cache_file, cache_dir, last_key); if (!zend_is_true(content)) { PHALCON_INIT_VAR(cached_content); phalcon_call_method(cached_content, frontend, "getcontent"); } else { PHALCON_CPY_WRT(cached_content, content); } PHALCON_INIT_VAR(prepared_content); phalcon_call_method_p1(prepared_content, frontend, "beforestore", cached_content); /** * We use file_put_contents to respect open-base-dir directive */ PHALCON_INIT_VAR(status); phalcon_file_put_contents(status, cache_file, prepared_content TSRMLS_CC); if (PHALCON_IS_FALSE(status)) { PHALCON_THROW_EXCEPTION_STR(phalcon_cache_exception_ce, "Cache directory can't be written"); return; } PHALCON_INIT_VAR(is_buffering); phalcon_call_method(is_buffering, frontend, "isbuffering"); if (PHALCON_IS_TRUE(stop_buffer)) { phalcon_call_method_noret(frontend, "stop"); } if (PHALCON_IS_TRUE(is_buffering)) { zend_print_zval(cached_content, 0); } phalcon_update_property_bool(this_ptr, SL("_started"), 0 TSRMLS_CC); PHALCON_MM_RESTORE(); }
/** * The meta-data is obtained by reading the column descriptions from the database information schema * * @param Phalcon\Mvc\ModelInterface $model * @param Phalcon\DiInterface $dependencyInjector * @return array */ PHP_METHOD(Phalcon_Mvc_Model_MetaData_Strategy_Introspection, getMetaData){ zval *model, *dependency_injector, *class_name; zval *schema, *table, *read_connection, *exists; zval *complete_table = NULL, *exception_message = NULL; zval *columns, *attributes, *primary_keys, *non_primary_keys; zval *numeric_typed, *not_null, *field_types; zval *field_bind_types, *automatic_default; zval *identity_field = NULL, *column = NULL, *field_name = NULL, *feature = NULL; zval *type = NULL, *bind_type = NULL, *model_metadata; HashTable *ah0; HashPosition hp0; zval **hd; PHALCON_MM_GROW(); phalcon_fetch_params(1, 2, 0, &model, &dependency_injector); PHALCON_INIT_VAR(class_name); phalcon_get_class(class_name, model, 0 TSRMLS_CC); PHALCON_INIT_VAR(schema); phalcon_call_method(schema, model, "getschema"); PHALCON_INIT_VAR(table); phalcon_call_method(table, model, "getsource"); /** * Check if the mapped table exists on the database */ PHALCON_INIT_VAR(read_connection); phalcon_call_method(read_connection, model, "getreadconnection"); PHALCON_INIT_VAR(exists); phalcon_call_method_p2(exists, read_connection, "tableexists", table, schema); if (!zend_is_true(exists)) { if (zend_is_true(schema)) { PHALCON_INIT_VAR(complete_table); PHALCON_CONCAT_VSV(complete_table, schema, "\".\"", table); } else { PHALCON_CPY_WRT(complete_table, table); } /** * The table not exists */ PHALCON_INIT_VAR(exception_message); PHALCON_CONCAT_SVSV(exception_message, "Table \"", complete_table, "\" doesn't exist on database when dumping meta-data for ", class_name); PHALCON_THROW_EXCEPTION_ZVAL(phalcon_mvc_model_exception_ce, exception_message); return; } /** * Try to describe the table */ PHALCON_INIT_VAR(columns); phalcon_call_method_p2(columns, read_connection, "describecolumns", table, schema); if (!phalcon_fast_count_ev(columns TSRMLS_CC)) { if (zend_is_true(schema)) { PHALCON_INIT_NVAR(complete_table); PHALCON_CONCAT_VSV(complete_table, schema, "\".\"", table); } else { PHALCON_CPY_WRT(complete_table, table); } /** * The table not exists */ PHALCON_INIT_NVAR(exception_message); PHALCON_CONCAT_SVSV(exception_message, "Cannot obtain table columns for the mapped source \"", complete_table, "\" used in model ", class_name); PHALCON_THROW_EXCEPTION_ZVAL(phalcon_mvc_model_exception_ce, exception_message); return; } /** * Initialize meta-data */ PHALCON_INIT_VAR(attributes); array_init(attributes); PHALCON_INIT_VAR(primary_keys); array_init(primary_keys); PHALCON_INIT_VAR(non_primary_keys); array_init(non_primary_keys); PHALCON_INIT_VAR(numeric_typed); array_init(numeric_typed); PHALCON_INIT_VAR(not_null); array_init(not_null); PHALCON_INIT_VAR(field_types); array_init(field_types); PHALCON_INIT_VAR(field_bind_types); array_init(field_bind_types); PHALCON_INIT_VAR(automatic_default); array_init(automatic_default); PHALCON_INIT_VAR(identity_field); ZVAL_BOOL(identity_field, 0); phalcon_is_iterable(columns, &ah0, &hp0, 0, 0); while (zend_hash_get_current_data_ex(ah0, (void**) &hd, &hp0) == SUCCESS) { PHALCON_GET_HVALUE(column); PHALCON_INIT_NVAR(field_name); phalcon_call_method(field_name, column, "getname"); phalcon_array_append(&attributes, field_name, PH_SEPARATE); /** * To mark fields as primary keys */ PHALCON_INIT_NVAR(feature); phalcon_call_method(feature, column, "isprimary"); if (PHALCON_IS_TRUE(feature)) { phalcon_array_append(&primary_keys, field_name, PH_SEPARATE); } else { phalcon_array_append(&non_primary_keys, field_name, PH_SEPARATE); } /** * To mark fields as numeric */ PHALCON_INIT_NVAR(feature); phalcon_call_method(feature, column, "isnumeric"); if (PHALCON_IS_TRUE(feature)) { phalcon_array_update_zval_bool(&numeric_typed, field_name, 1, PH_SEPARATE); } /** * To mark fields as not null */ PHALCON_INIT_NVAR(feature); phalcon_call_method(feature, column, "isnotnull"); if (PHALCON_IS_TRUE(feature)) { phalcon_array_append(¬_null, field_name, PH_SEPARATE); } /** * To mark fields as identity columns */ PHALCON_INIT_NVAR(feature); phalcon_call_method(feature, column, "isautoincrement"); if (PHALCON_IS_TRUE(feature)) { PHALCON_CPY_WRT(identity_field, field_name); } /** * To get the internal types */ PHALCON_INIT_NVAR(type); phalcon_call_method(type, column, "gettype"); phalcon_array_update_zval(&field_types, field_name, &type, PH_COPY | PH_SEPARATE); /** * To mark how the fields must be escaped */ PHALCON_INIT_NVAR(bind_type); phalcon_call_method(bind_type, column, "getbindtype"); phalcon_array_update_zval(&field_bind_types, field_name, &bind_type, PH_COPY | PH_SEPARATE); zend_hash_move_forward_ex(ah0, &hp0); } /** * Create an array using the MODELS_* constants as indexes */ PHALCON_INIT_VAR(model_metadata); array_init(model_metadata); phalcon_array_update_long(&model_metadata, 0, &attributes, PH_COPY | PH_SEPARATE); phalcon_array_update_long(&model_metadata, 1, &primary_keys, PH_COPY | PH_SEPARATE); phalcon_array_update_long(&model_metadata, 2, &non_primary_keys, PH_COPY | PH_SEPARATE); phalcon_array_update_long(&model_metadata, 3, ¬_null, PH_COPY | PH_SEPARATE); phalcon_array_update_long(&model_metadata, 4, &field_types, PH_COPY | PH_SEPARATE); phalcon_array_update_long(&model_metadata, 5, &numeric_typed, PH_COPY | PH_SEPARATE); phalcon_array_update_long(&model_metadata, 8, &identity_field, PH_COPY | PH_SEPARATE); phalcon_array_update_long(&model_metadata, 9, &field_bind_types, PH_COPY | PH_SEPARATE); phalcon_array_update_long(&model_metadata, 10, &automatic_default, PH_COPY | PH_SEPARATE); phalcon_array_update_long(&model_metadata, 11, &automatic_default, PH_COPY | PH_SEPARATE); RETURN_CTOR(model_metadata); }
/** * Adds access to resources * * @param array|string accessList */ PHP_METHOD(Phalcon_Acl_Adapter_Memory, addResourceAccess) { HashTable *_5$$5; HashPosition _4$$5; zend_bool exists = 0, _3; int ZEPHIR_LAST_CALL_STATUS; zval *resourceName_param = NULL, *accessList, *accessName = NULL, *accessKey = NULL, *_0, *_1$$3, **_6$$5, *_7$$6, *_8$$7 = NULL, *_9$$8, *_10$$9; zval *resourceName = NULL, *_2$$3; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &resourceName_param, &accessList); zephir_get_strval(resourceName, resourceName_param); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_resourcesNames"), PH_NOISY_CC); if (!(zephir_array_isset(_0, resourceName))) { ZEPHIR_INIT_VAR(_1$$3); object_init_ex(_1$$3, phalcon_acl_exception_ce); ZEPHIR_INIT_VAR(_2$$3); ZEPHIR_CONCAT_SVS(_2$$3, "Resource '", resourceName, "' does not exist in ACL"); ZEPHIR_CALL_METHOD(NULL, _1$$3, "__construct", NULL, 9, _2$$3); zephir_check_call_status(); zephir_throw_exception_debug(_1$$3, "phalcon/acl/adapter/memory.zep", 349 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } _3 = Z_TYPE_P(accessList) != IS_ARRAY; if (_3) { _3 = Z_TYPE_P(accessList) != IS_STRING; } if (_3) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_acl_exception_ce, "Invalid value for accessList", "phalcon/acl/adapter/memory.zep", 353); return; } exists = 1; if (Z_TYPE_P(accessList) == IS_ARRAY) { zephir_is_iterable(accessList, &_5$$5, &_4$$5, 0, 0, "phalcon/acl/adapter/memory.zep", 364); for ( ; zephir_hash_get_current_data_ex(_5$$5, (void**) &_6$$5, &_4$$5) == SUCCESS ; zephir_hash_move_forward_ex(_5$$5, &_4$$5) ) { ZEPHIR_GET_HVALUE(accessName, _6$$5); ZEPHIR_INIT_NVAR(accessKey); ZEPHIR_CONCAT_VSV(accessKey, resourceName, "!", accessName); _7$$6 = zephir_fetch_nproperty_this(this_ptr, SL("_accessList"), PH_NOISY_CC); if (!(zephir_array_isset(_7$$6, accessKey))) { ZEPHIR_INIT_NVAR(_8$$7); ZVAL_BOOL(_8$$7, exists); zephir_update_property_array(this_ptr, SL("_accessList"), accessKey, _8$$7 TSRMLS_CC); } } } else { ZEPHIR_INIT_NVAR(accessKey); ZEPHIR_CONCAT_VSV(accessKey, resourceName, "!", accessList); _9$$8 = zephir_fetch_nproperty_this(this_ptr, SL("_accessList"), PH_NOISY_CC); if (!(zephir_array_isset(_9$$8, accessKey))) { ZEPHIR_INIT_VAR(_10$$9); ZVAL_BOOL(_10$$9, exists); zephir_update_property_array(this_ptr, SL("_accessList"), accessKey, _10$$9 TSRMLS_CC); } } RETURN_MM_BOOL(1); }
/** * Performs logical AND function operator */ int phalcon_and_function(zval *result, zval *left, zval *right) { int istrue = zend_is_true(left) && zend_is_true(right); ZVAL_BOOL(result, istrue); return SUCCESS; }
/* {{{ mysqlnd_vio::enable_ssl */ static enum_func_status MYSQLND_METHOD(mysqlnd_vio, enable_ssl)(MYSQLND_VIO * const net) { #ifdef MYSQLND_SSL_SUPPORTED php_stream_context * context = php_stream_context_alloc(); php_stream * net_stream = net->data->m.get_stream(net); zend_bool any_flag = FALSE; DBG_ENTER("mysqlnd_vio::enable_ssl"); if (net->data->options.ssl_key) { zval key_zval; ZVAL_STRING(&key_zval, net->data->options.ssl_key); php_stream_context_set_option(context, "ssl", "local_pk", &key_zval); zval_ptr_dtor(&key_zval); any_flag = TRUE; } if (net->data->options.ssl_cert) { zval cert_zval; ZVAL_STRING(&cert_zval, net->data->options.ssl_cert); php_stream_context_set_option(context, "ssl", "local_cert", &cert_zval); if (!net->data->options.ssl_key) { php_stream_context_set_option(context, "ssl", "local_pk", &cert_zval); } zval_ptr_dtor(&cert_zval); any_flag = TRUE; } if (net->data->options.ssl_ca) { zval cafile_zval; ZVAL_STRING(&cafile_zval, net->data->options.ssl_ca); php_stream_context_set_option(context, "ssl", "cafile", &cafile_zval); any_flag = TRUE; } if (net->data->options.ssl_capath) { zval capath_zval; ZVAL_STRING(&capath_zval, net->data->options.ssl_capath); php_stream_context_set_option(context, "ssl", "capath", &capath_zval); zval_ptr_dtor(&capath_zval); any_flag = TRUE; } if (net->data->options.ssl_passphrase) { zval passphrase_zval; ZVAL_STRING(&passphrase_zval, net->data->options.ssl_passphrase); php_stream_context_set_option(context, "ssl", "passphrase", &passphrase_zval); zval_ptr_dtor(&passphrase_zval); any_flag = TRUE; } if (net->data->options.ssl_cipher) { zval cipher_zval; ZVAL_STRING(&cipher_zval, net->data->options.ssl_cipher); php_stream_context_set_option(context, "ssl", "ciphers", &cipher_zval); zval_ptr_dtor(&cipher_zval); any_flag = TRUE; } { zval verify_peer_zval; zend_bool verify; if (net->data->options.ssl_verify_peer == MYSQLND_SSL_PEER_DEFAULT) { net->data->options.ssl_verify_peer = any_flag? MYSQLND_SSL_PEER_DEFAULT_ACTION:MYSQLND_SSL_PEER_DONT_VERIFY; } verify = net->data->options.ssl_verify_peer == MYSQLND_SSL_PEER_VERIFY? TRUE:FALSE; DBG_INF_FMT("VERIFY=%d", verify); ZVAL_BOOL(&verify_peer_zval, verify); php_stream_context_set_option(context, "ssl", "verify_peer", &verify_peer_zval); php_stream_context_set_option(context, "ssl", "verify_peer_name", &verify_peer_zval); if (net->data->options.ssl_verify_peer == MYSQLND_SSL_PEER_DONT_VERIFY) { ZVAL_TRUE(&verify_peer_zval); php_stream_context_set_option(context, "ssl", "allow_self_signed", &verify_peer_zval); } } php_stream_context_set(net_stream, context); if (php_stream_xport_crypto_setup(net_stream, STREAM_CRYPTO_METHOD_TLS_CLIENT, NULL) < 0 || php_stream_xport_crypto_enable(net_stream, 1) < 0) { DBG_ERR("Cannot connect to MySQL by using SSL"); php_error_docref(NULL, E_WARNING, "Cannot connect to MySQL by using SSL"); DBG_RETURN(FAIL); } net->data->ssl = TRUE; /* get rid of the context. we are persistent and if this is a real pconn used by mysql/mysqli, then the context would not survive cleaning of EG(regular_list), where it is registered, as a resource. What happens is that after this destruction any use of the network will mean usage of the context, which means usage of already freed memory, bad. Actually we don't need this context anymore after we have enabled SSL on the connection. Thus it is very simple, we remove it. */ php_stream_context_set(net_stream, NULL); if (net->data->options.timeout_read) { struct timeval tv; DBG_INF_FMT("setting %u as PHP_STREAM_OPTION_READ_TIMEOUT", net->data->options.timeout_read); tv.tv_sec = net->data->options.timeout_read; tv.tv_usec = 0; php_stream_set_option(net_stream, PHP_STREAM_OPTION_READ_TIMEOUT, 0, &tv); } DBG_RETURN(PASS); #else DBG_ENTER("mysqlnd_vio::enable_ssl"); DBG_INF("MYSQLND_SSL_SUPPORTED is not defined"); DBG_RETURN(PASS); #endif }
/** * Stores cached content into the Memcached backend and stops the frontend * * @param int|string $keyName * @param string $content * @param long $lifetime * @param boolean $stopBuffer */ PHP_METHOD(Phalcon_Cache_Backend_Memcache, save){ zval *key_name = NULL, *content = NULL, *lifetime = NULL, *stop_buffer = NULL; zval *last_key = NULL, *prefix, *frontend, *memcache = NULL, *cached_content = NULL; zval *prepared_content, *ttl = NULL, *flags, *success; zval *options, *special_key, *keys = NULL, *is_buffering; PHALCON_MM_GROW(); phalcon_fetch_params(1, 0, 4, &key_name, &content, &lifetime, &stop_buffer); if (!key_name) { PHALCON_INIT_VAR(key_name); } if (!content) { PHALCON_INIT_VAR(content); } if (!lifetime) { PHALCON_INIT_VAR(lifetime); } if (!stop_buffer) { PHALCON_INIT_VAR(stop_buffer); ZVAL_BOOL(stop_buffer, 1); } if (Z_TYPE_P(key_name) == IS_NULL) { PHALCON_OBS_VAR(last_key); phalcon_read_property_this(&last_key, this_ptr, SL("_lastKey"), PH_NOISY_CC); } else { PHALCON_OBS_VAR(prefix); phalcon_read_property_this(&prefix, this_ptr, SL("_prefix"), PH_NOISY_CC); PHALCON_INIT_NVAR(last_key); PHALCON_CONCAT_VV(last_key, prefix, key_name); } if (!zend_is_true(last_key)) { PHALCON_THROW_EXCEPTION_STR(phalcon_cache_exception_ce, "The cache must be started first"); return; } PHALCON_OBS_VAR(frontend); phalcon_read_property_this(&frontend, this_ptr, SL("_frontend"), PH_NOISY_CC); /** * Check if a connection is created or make a new one */ PHALCON_OBS_VAR(memcache); phalcon_read_property_this(&memcache, this_ptr, SL("_memcache"), PH_NOISY_CC); if (Z_TYPE_P(memcache) != IS_OBJECT) { phalcon_call_method_noret(this_ptr, "_connect"); PHALCON_OBS_NVAR(memcache); phalcon_read_property_this(&memcache, this_ptr, SL("_memcache"), PH_NOISY_CC); } if (Z_TYPE_P(content) == IS_NULL) { PHALCON_INIT_VAR(cached_content); phalcon_call_method(cached_content, frontend, "getcontent"); } else { PHALCON_CPY_WRT(cached_content, content); } /** * Prepare the content in the frontend */ PHALCON_INIT_VAR(prepared_content); phalcon_call_method_p1(prepared_content, frontend, "beforestore", cached_content); if (Z_TYPE_P(lifetime) == IS_NULL) { PHALCON_INIT_VAR(ttl); phalcon_call_method(ttl, frontend, "getlifetime"); } else { PHALCON_CPY_WRT(ttl, lifetime); } PHALCON_INIT_VAR(flags); ZVAL_LONG(flags, 0); /** * We store without flags */ PHALCON_INIT_VAR(success); phalcon_call_method_p4(success, memcache, "set", last_key, prepared_content, flags, ttl); if (!zend_is_true(success)) { PHALCON_THROW_EXCEPTION_STR(phalcon_cache_exception_ce, "Failed storing data in memcached"); return; } PHALCON_OBS_VAR(options); phalcon_read_property_this(&options, this_ptr, SL("_options"), PH_NOISY_CC); PHALCON_OBS_VAR(special_key); phalcon_array_fetch_string(&special_key, options, SL("statsKey"), PH_NOISY); /** * Update the stats key */ PHALCON_INIT_VAR(keys); phalcon_call_method_p1(keys, memcache, "get", special_key); if (Z_TYPE_P(keys) != IS_ARRAY) { PHALCON_INIT_NVAR(keys); array_init(keys); } if (!phalcon_array_isset(keys, last_key)) { phalcon_array_update_zval(&keys, last_key, &ttl, PH_COPY | PH_SEPARATE); phalcon_call_method_p2_noret(memcache, "set", special_key, keys); } PHALCON_INIT_VAR(is_buffering); phalcon_call_method(is_buffering, frontend, "isbuffering"); if (PHALCON_IS_TRUE(stop_buffer)) { phalcon_call_method_noret(frontend, "stop"); } if (PHALCON_IS_TRUE(is_buffering)) { zend_print_zval(cached_content, 0); } phalcon_update_property_bool(this_ptr, SL("_started"), 0 TSRMLS_CC); PHALCON_MM_RESTORE(); }
/** * Dispatches a controller action taking into account the routing parameters * * @param Phalcon_Request $request * @param Phalcon_Response $response * @param Phalcon_View $view * @param Phalcon_Model_Manager $model * @return Phalcon_Controller */ PHP_METHOD(Phalcon_Dispatcher, dispatch){ zval *request = NULL, *response = NULL, *view = NULL, *model = NULL, *controllers_dir = NULL; zval *value = NULL, *controller = NULL, *number_dispatches = NULL; zval *controller_name = NULL, *controllers = NULL, *controller_class = NULL; zval *controller_path = NULL, *params = NULL, *action_name = NULL; zval *action_method = NULL; zval *r0 = NULL, *r1 = NULL, *r2 = NULL, *r3 = NULL, *r4 = NULL, *r5 = NULL, *r6 = NULL; zval *r7 = NULL, *r8 = NULL, *r9 = NULL, *r10 = NULL, *r11 = NULL, *r12 = NULL, *r13 = NULL; zval *r14 = NULL; zval *t0 = NULL, *t1 = NULL, *t2 = NULL, *t3 = NULL, *t4 = NULL, *t5 = NULL, *t6 = NULL; zval *t7 = NULL, *t8 = NULL, *t9 = NULL, *t10 = NULL; zval *c0 = NULL, *c1 = NULL, *c2 = NULL; zval *i0 = NULL; zval *a0 = NULL, *a1 = NULL; zval *p5[] = { NULL, NULL, NULL, NULL, NULL }; int eval_int; zend_class_entry *ce0; PHALCON_MM_GROW(); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zz|zz", &request, &response, &view, &model) == FAILURE) { PHALCON_MM_RESTORE(); RETURN_NULL(); } if (!view) { PHALCON_INIT_VAR(view); ZVAL_NULL(view); } if (!model) { PHALCON_INIT_VAR(model); ZVAL_NULL(model); } PHALCON_ALLOC_ZVAL_MM(r0); PHALCON_ALLOC_ZVAL_MM(t0); phalcon_read_property(&t0, this_ptr, "_basePath", sizeof("_basePath")-1, PHALCON_NOISY TSRMLS_CC); PHALCON_ALLOC_ZVAL_MM(t1); phalcon_read_property(&t1, this_ptr, "_controllersDir", sizeof("_controllersDir")-1, PHALCON_NOISY TSRMLS_CC); PHALCON_CONCAT_VV(r0, t0, t1); PHALCON_CPY_WRT(controllers_dir, r0); PHALCON_INIT_VAR(value); ZVAL_NULL(value); PHALCON_INIT_VAR(controller); ZVAL_NULL(controller); PHALCON_INIT_VAR(number_dispatches); ZVAL_LONG(number_dispatches, 0); phalcon_update_property_bool(this_ptr, "_finished", strlen("_finished"), 0 TSRMLS_CC); ws_e10f_0: PHALCON_INIT_VAR(t2); phalcon_read_property(&t2, this_ptr, "_finished", sizeof("_finished")-1, PHALCON_NOISY TSRMLS_CC); if (zend_is_true(t2)) { goto we_e10f_0; } phalcon_update_property_bool(this_ptr, "_finished", strlen("_finished"), 1 TSRMLS_CC); PHALCON_INIT_VAR(t3); phalcon_read_property(&t3, this_ptr, "_controllerName", sizeof("_controllerName")-1, PHALCON_NOISY TSRMLS_CC); PHALCON_CPY_WRT(controller_name, t3); if (!zend_is_true(controller_name)) { PHALCON_INIT_VAR(t4); phalcon_read_property(&t4, this_ptr, "_defaultController", sizeof("_defaultController")-1, PHALCON_NOISY TSRMLS_CC); PHALCON_CPY_WRT(controller_name, t4); phalcon_update_property_zval(this_ptr, "_controllerName", strlen("_controllerName"), controller_name TSRMLS_CC); } PHALCON_INIT_VAR(t5); phalcon_read_property(&t5, this_ptr, "_controllers", sizeof("_controllers")-1, PHALCON_NOISY TSRMLS_CC); PHALCON_CPY_WRT(controllers, t5); PHALCON_INIT_VAR(r1); PHALCON_INIT_VAR(r2); PHALCON_CALL_STATIC_PARAMS_1(r2, "phalcon_text", "camelize", controller_name); PHALCON_CONCAT_VS(r1, r2, "Controller"); PHALCON_CPY_WRT(controller_class, r1); eval_int = phalcon_array_isset(controllers, controller_class); if (!eval_int) { PHALCON_INIT_VAR(r3); PHALCON_INIT_VAR(c0); ZVAL_BOOL(c0, 0); PHALCON_CALL_FUNC_PARAMS_2(r3, "class_exists", controller_class, c0, 0x012); if (!zend_is_true(r3)) { PHALCON_INIT_VAR(r4); PHALCON_CONCAT_VVS(r4, controllers_dir, controller_class, ".php"); PHALCON_CPY_WRT(controller_path, r4); if (phalcon_file_exists(controller_path TSRMLS_CC) == SUCCESS) { if (phalcon_require(controller_path TSRMLS_CC) == FAILURE) { return; } } else { PHALCON_INIT_VAR(r5); PHALCON_CONCAT_SVS(r5, "File for controller class ", controller_class, " doesn't exist"); PHALCON_CALL_METHOD_PARAMS_2_NORETURN(this_ptr, "_throwdispatchexception", response, r5, PHALCON_NO_CHECK); } PHALCON_INIT_VAR(r6); PHALCON_INIT_VAR(c1); ZVAL_BOOL(c1, 0); PHALCON_CALL_FUNC_PARAMS_2(r6, "class_exists", controller_class, c1, 0x012); if (!zend_is_true(r6)) { PHALCON_INIT_VAR(r7); PHALCON_CONCAT_SVS(r7, "Class ", controller_class, " was not found on controller file"); PHALCON_CALL_METHOD_PARAMS_2_NORETURN(this_ptr, "_throwdispatchexception", response, r7, PHALCON_NO_CHECK); } } ce0 = phalcon_fetch_class(controller_class TSRMLS_CC); PHALCON_INIT_VAR(i0); object_init_ex(i0, ce0); p5[0] = this_ptr; p5[1] = request; p5[2] = response; p5[3] = view; p5[4] = model; PHALCON_CALL_METHOD_PARAMS_NORETURN(i0, "__construct", 5, p5, PHALCON_CHECK); PHALCON_CPY_WRT(controller, i0); if (phalcon_method_exists_ex(controller, "initialize", strlen("initialize") TSRMLS_CC) == SUCCESS) { PHALCON_CALL_METHOD_NORETURN(controller, "initialize", PHALCON_NO_CHECK); } PHALCON_INIT_VAR(t6); phalcon_read_property(&t6, this_ptr, "_controllers", sizeof("_controllers")-1, PHALCON_NOISY TSRMLS_CC); phalcon_array_update(&t6, controller_class, &controller, PHALCON_NO_SEPARATE_THX, PHALCON_COPY, PHALCON_NO_CTOR TSRMLS_CC); phalcon_update_property_zval(this_ptr, "_controllers", strlen("_controllers"), t6 TSRMLS_CC); } else { PHALCON_INIT_VAR(r8); phalcon_array_fetch(&r8, controllers, controller_class, PHALCON_NOISY TSRMLS_CC); PHALCON_CPY_WRT(controller, r8); } PHALCON_INIT_VAR(t7); phalcon_read_property(&t7, this_ptr, "_params", sizeof("_params")-1, PHALCON_NOISY TSRMLS_CC); PHALCON_CPY_WRT(params, t7); PHALCON_INIT_VAR(t8); phalcon_read_property(&t8, this_ptr, "_actionName", sizeof("_actionName")-1, PHALCON_NOISY TSRMLS_CC); PHALCON_CPY_WRT(action_name, t8); if (!zend_is_true(action_name)) { PHALCON_INIT_VAR(t9); phalcon_read_property(&t9, this_ptr, "_defaultAction", sizeof("_defaultAction")-1, PHALCON_NOISY TSRMLS_CC); PHALCON_CPY_WRT(action_name, t9); phalcon_update_property_zval(this_ptr, "_actionName", strlen("_actionName"), action_name TSRMLS_CC); } if (phalcon_method_exists_ex(controller, "beforedispatch", strlen("beforedispatch") TSRMLS_CC) == SUCCESS) { PHALCON_INIT_VAR(r9); PHALCON_CALL_METHOD_PARAMS_3(r9, controller, "beforedispatch", controller_name, action_name, params, PHALCON_NO_CHECK); if (Z_TYPE_P(r9) == IS_BOOL && !Z_BVAL_P(r9)) { PHALCON_INIT_VAR(value); ZVAL_BOOL(value, 0); goto we_e10f_0; } } PHALCON_INIT_VAR(r10); PHALCON_CONCAT_VS(r10, action_name, "Action"); PHALCON_CPY_WRT(action_method, r10); if (phalcon_method_exists(controller, action_method TSRMLS_CC) == SUCCESS) { PHALCON_INIT_VAR(r11); PHALCON_INIT_VAR(a0); array_init(a0); phalcon_array_append(&a0, controller, PHALCON_SEPARATE_PLZ TSRMLS_CC); phalcon_array_append(&a0, action_method, PHALCON_SEPARATE_PLZ TSRMLS_CC); PHALCON_CALL_FUNC_PARAMS_2(r11, "call_user_func_array", a0, params, 0x013); PHALCON_CPY_WRT(value, r11); } else { if (phalcon_method_exists_ex(controller, "notfoundaction", strlen("notfoundaction") TSRMLS_CC) == SUCCESS) { PHALCON_INIT_VAR(r12); PHALCON_INIT_VAR(a1); array_init(a1); phalcon_array_append(&a1, controller, PHALCON_SEPARATE_PLZ TSRMLS_CC); add_next_index_stringl(a1, "notFoundAction", strlen("notFoundAction"), 1); PHALCON_CALL_FUNC_PARAMS_2(r12, "call_user_func_array", a1, params, 0x013); PHALCON_CPY_WRT(value, r12); } else { PHALCON_INIT_VAR(r13); PHALCON_CONCAT_SVSVS(r13, "Action '", action_name, "' was not found on controller '", controller_name, "'"); PHALCON_CALL_METHOD_PARAMS_2_NORETURN(this_ptr, "_throwdispatchexception", response, r13, PHALCON_NO_CHECK); } } if (phalcon_method_exists_ex(controller, "afterdispatch", strlen("afterdispatch") TSRMLS_CC) == SUCCESS) { PHALCON_CALL_METHOD_PARAMS_3_NORETURN(controller, "afterdispatch", controller_name, action_name, params, PHALCON_NO_CHECK); } PHALCON_SEPARATE(number_dispatches); increment_function(number_dispatches); PHALCON_INIT_VAR(t10); ZVAL_LONG(t10, 256); PHALCON_INIT_VAR(r14); is_smaller_function(r14, t10, number_dispatches TSRMLS_CC); if (zend_is_true(r14)) { PHALCON_INIT_VAR(c2); ZVAL_STRING(c2, "Dispatcher has detected a cyclic routing causing stability problems", 1); PHALCON_CALL_METHOD_PARAMS_2_NORETURN(this_ptr, "_throwdispatchexception", response, c2, PHALCON_NO_CHECK); } goto ws_e10f_0; we_e10f_0: phalcon_update_property_zval(this_ptr, "_returnedValue", strlen("_returnedValue"), value TSRMLS_CC); phalcon_update_property_zval(this_ptr, "_lastController", strlen("_lastController"), controller TSRMLS_CC); PHALCON_RETURN_CHECK_CTOR(controller); }
/** * Handles routing information received from the rewrite engine * *<code> * //Read the info from the rewrite engine * $router->handle(); * * //Manually passing an URL * $router->handle('/posts/edit/1'); *</code> */ PHP_METHOD(Phalcon_Mvc_Router, handle) { zval *_21$$28 = NULL, *_28$$37 = NULL, *_30$$40 = NULL; HashTable *_6, *_25$$33; HashPosition _5, _24$$33; zend_bool _1; zephir_fcall_cache_entry *_18 = NULL, *_20 = NULL, *_23 = NULL, *_31 = NULL; int ZEPHIR_LAST_CALL_STATUS; zval *uri_param = NULL, *realUri = NULL, *request = NULL, *currentHostName = NULL, *routeFound = NULL, *parts = NULL, *params = NULL, *matches = NULL, *notFoundPaths = NULL, *vnamespace = NULL, *module = NULL, *controller = NULL, *action = NULL, *paramsStr = NULL, *strParams = NULL, *route = NULL, *methods = NULL, *dependencyInjector = NULL, *hostname = NULL, *regexHostName = NULL, *matched = NULL, *pattern = NULL, *handledUri = NULL, *beforeMatch = NULL, *paths = NULL, *converters = NULL, *part = NULL, *position = NULL, *matchPosition = NULL, *converter = NULL, *eventsManager = NULL, *_0, *_4, **_7, *_32, *_33, *_34, *_35, *_36, _2$$5, *_3$$7, *_8$$10, *_9$$10 = NULL, *_10$$10 = NULL, *_11$$9 = NULL, *_12$$9 = NULL, *_13$$14, *_14$$14 = NULL, *_15$$14 = NULL, *_16$$18 = NULL, *_17$$23 = NULL, *_19$$27 = NULL, *_22$$31 = NULL, **_26$$33, *_27$$37 = NULL, *_29$$40 = NULL, _37$$55, *_38$$57, *_39$$59; zval *uri = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 1, &uri_param); if (!uri_param) { ZEPHIR_INIT_VAR(uri); ZVAL_EMPTY_STRING(uri); } else { zephir_get_strval(uri, uri_param); } if (!(!(!uri) && Z_STRLEN_P(uri))) { ZEPHIR_CALL_METHOD(&realUri, this_ptr, "getrewriteuri", NULL, 0); zephir_check_call_status(); } else { ZEPHIR_CPY_WRT(realUri, uri); } _0 = zephir_fetch_nproperty_this(this_ptr, SL("_removeExtraSlashes"), PH_NOISY_CC); _1 = zephir_is_true(_0); if (_1) { _1 = !ZEPHIR_IS_STRING(realUri, "/"); } if (_1) { ZEPHIR_SINIT_VAR(_2$$5); ZVAL_STRING(&_2$$5, "/", 0); ZEPHIR_INIT_VAR(handledUri); zephir_fast_trim(handledUri, realUri, &_2$$5, ZEPHIR_TRIM_RIGHT TSRMLS_CC); } else { ZEPHIR_CPY_WRT(handledUri, realUri); } ZEPHIR_INIT_VAR(request); ZVAL_NULL(request); ZEPHIR_INIT_VAR(currentHostName); ZVAL_NULL(currentHostName); ZEPHIR_INIT_VAR(routeFound); ZVAL_BOOL(routeFound, 0); ZEPHIR_INIT_VAR(parts); array_init(parts); ZEPHIR_INIT_VAR(params); array_init(params); ZEPHIR_INIT_VAR(matches); ZVAL_NULL(matches); if (0) { zephir_update_property_this(this_ptr, SL("_wasMatched"), ZEPHIR_GLOBAL(global_true) TSRMLS_CC); } else { zephir_update_property_this(this_ptr, SL("_wasMatched"), ZEPHIR_GLOBAL(global_false) TSRMLS_CC); } zephir_update_property_this(this_ptr, SL("_matchedRoute"), ZEPHIR_GLOBAL(global_null) TSRMLS_CC); ZEPHIR_OBS_VAR(eventsManager); zephir_read_property_this(&eventsManager, this_ptr, SL("_eventsManager"), PH_NOISY_CC); if (Z_TYPE_P(eventsManager) == IS_OBJECT) { ZEPHIR_INIT_VAR(_3$$7); ZVAL_STRING(_3$$7, "router:beforeCheckRoutes", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, eventsManager, "fire", NULL, 0, _3$$7, this_ptr); zephir_check_temp_parameter(_3$$7); zephir_check_call_status(); } _4 = zephir_fetch_nproperty_this(this_ptr, SL("_routes"), PH_NOISY_CC); zephir_is_iterable(_4, &_6, &_5, 0, 1, "phalcon/mvc/router.zep", 558); for ( ; zephir_hash_get_current_data_ex(_6, (void**) &_7, &_5) == SUCCESS ; zephir_hash_move_backwards_ex(_6, &_5) ) { ZEPHIR_GET_HVALUE(route, _7); ZEPHIR_INIT_NVAR(params); array_init(params); ZEPHIR_INIT_NVAR(matches); ZVAL_NULL(matches); ZEPHIR_CALL_METHOD(&methods, route, "gethttpmethods", NULL, 0); zephir_check_call_status(); if (Z_TYPE_P(methods) != IS_NULL) { if (Z_TYPE_P(request) == IS_NULL) { _8$$10 = zephir_fetch_nproperty_this(this_ptr, SL("_dependencyInjector"), PH_NOISY_CC); ZEPHIR_CPY_WRT(dependencyInjector, _8$$10); if (Z_TYPE_P(dependencyInjector) != IS_OBJECT) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_router_exception_ce, "A dependency injection container is required to access the 'request' service", "phalcon/mvc/router.zep", 384); return; } ZEPHIR_INIT_NVAR(_10$$10); ZVAL_STRING(_10$$10, "request", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_9$$10, dependencyInjector, "getshared", NULL, 0, _10$$10); zephir_check_temp_parameter(_10$$10); zephir_check_call_status(); ZEPHIR_CPY_WRT(request, _9$$10); } ZEPHIR_INIT_NVAR(_12$$9); ZVAL_BOOL(_12$$9, 1); ZEPHIR_CALL_METHOD(&_11$$9, request, "ismethod", NULL, 0, methods, _12$$9); zephir_check_call_status(); if (ZEPHIR_IS_FALSE_IDENTICAL(_11$$9)) { continue; } } ZEPHIR_CALL_METHOD(&hostname, route, "gethostname", NULL, 0); zephir_check_call_status(); if (Z_TYPE_P(hostname) != IS_NULL) { if (Z_TYPE_P(request) == IS_NULL) { _13$$14 = zephir_fetch_nproperty_this(this_ptr, SL("_dependencyInjector"), PH_NOISY_CC); ZEPHIR_CPY_WRT(dependencyInjector, _13$$14); if (Z_TYPE_P(dependencyInjector) != IS_OBJECT) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_router_exception_ce, "A dependency injection container is required to access the 'request' service", "phalcon/mvc/router.zep", 411); return; } ZEPHIR_INIT_NVAR(_15$$14); ZVAL_STRING(_15$$14, "request", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_14$$14, dependencyInjector, "getshared", NULL, 0, _15$$14); zephir_check_temp_parameter(_15$$14); zephir_check_call_status(); ZEPHIR_CPY_WRT(request, _14$$14); } if (Z_TYPE_P(currentHostName) != IS_OBJECT) { ZEPHIR_CALL_METHOD(¤tHostName, request, "gethttphost", NULL, 0); zephir_check_call_status(); } if (Z_TYPE_P(currentHostName) == IS_NULL) { continue; } if (zephir_memnstr_str(hostname, SL("("), "phalcon/mvc/router.zep", 434)) { if (!(zephir_memnstr_str(hostname, SL("#"), "phalcon/mvc/router.zep", 435))) { ZEPHIR_INIT_NVAR(regexHostName); ZEPHIR_CONCAT_SVS(regexHostName, "#^", hostname, "$#"); } else { ZEPHIR_CPY_WRT(regexHostName, hostname); } ZEPHIR_INIT_NVAR(_16$$18); ZEPHIR_INIT_NVAR(matched); zephir_preg_match(matched, regexHostName, currentHostName, _16$$18, 0, 0 , 0 TSRMLS_CC); } else { ZEPHIR_INIT_NVAR(matched); ZVAL_BOOL(matched, ZEPHIR_IS_EQUAL(currentHostName, hostname)); } if (!(zephir_is_true(matched))) { continue; } } if (Z_TYPE_P(eventsManager) == IS_OBJECT) { ZEPHIR_INIT_NVAR(_17$$23); ZVAL_STRING(_17$$23, "router:beforeCheckRoute", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, eventsManager, "fire", &_18, 0, _17$$23, this_ptr, route); zephir_check_temp_parameter(_17$$23); zephir_check_call_status(); } ZEPHIR_CALL_METHOD(&pattern, route, "getcompiledpattern", NULL, 0); zephir_check_call_status(); if (zephir_memnstr_str(pattern, SL("^"), "phalcon/mvc/router.zep", 459)) { ZEPHIR_INIT_NVAR(routeFound); zephir_preg_match(routeFound, pattern, handledUri, matches, 0, 0 , 0 TSRMLS_CC); } else { ZEPHIR_INIT_NVAR(routeFound); ZVAL_BOOL(routeFound, ZEPHIR_IS_EQUAL(pattern, handledUri)); } if (zephir_is_true(routeFound)) { if (Z_TYPE_P(eventsManager) == IS_OBJECT) { ZEPHIR_INIT_NVAR(_19$$27); ZVAL_STRING(_19$$27, "router:matchedRoute", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, eventsManager, "fire", &_20, 0, _19$$27, this_ptr, route); zephir_check_temp_parameter(_19$$27); zephir_check_call_status(); } ZEPHIR_CALL_METHOD(&beforeMatch, route, "getbeforematch", NULL, 0); zephir_check_call_status(); if (Z_TYPE_P(beforeMatch) != IS_NULL) { if (!(zephir_is_callable(beforeMatch TSRMLS_CC))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_router_exception_ce, "Before-Match callback is not callable in matched route", "phalcon/mvc/router.zep", 481); return; } ZEPHIR_INIT_NVAR(_21$$28); zephir_create_array(_21$$28, 3, 0 TSRMLS_CC); zephir_array_fast_append(_21$$28, handledUri); zephir_array_fast_append(_21$$28, route); zephir_array_fast_append(_21$$28, this_ptr); ZEPHIR_INIT_NVAR(routeFound); ZEPHIR_CALL_USER_FUNC_ARRAY(routeFound, beforeMatch, _21$$28); zephir_check_call_status(); } } else { if (Z_TYPE_P(eventsManager) == IS_OBJECT) { ZEPHIR_INIT_NVAR(_22$$31); ZVAL_STRING(_22$$31, "router:notMatchedRoute", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&routeFound, eventsManager, "fire", &_23, 0, _22$$31, this_ptr, route); zephir_check_temp_parameter(_22$$31); zephir_check_call_status(); } } if (zephir_is_true(routeFound)) { ZEPHIR_CALL_METHOD(&paths, route, "getpaths", NULL, 0); zephir_check_call_status(); ZEPHIR_CPY_WRT(parts, paths); if (Z_TYPE_P(matches) == IS_ARRAY) { ZEPHIR_CALL_METHOD(&converters, route, "getconverters", NULL, 0); zephir_check_call_status(); zephir_is_iterable(paths, &_25$$33, &_24$$33, 0, 0, "phalcon/mvc/router.zep", 547); for ( ; zephir_hash_get_current_data_ex(_25$$33, (void**) &_26$$33, &_24$$33) == SUCCESS ; zephir_hash_move_forward_ex(_25$$33, &_24$$33) ) { ZEPHIR_GET_HMKEY(part, _25$$33, _24$$33); ZEPHIR_GET_HVALUE(position, _26$$33); ZEPHIR_OBS_NVAR(matchPosition); if (zephir_array_isset_fetch(&matchPosition, matches, position, 0 TSRMLS_CC)) { if (Z_TYPE_P(converters) == IS_ARRAY) { ZEPHIR_OBS_NVAR(converter); if (zephir_array_isset_fetch(&converter, converters, part, 0 TSRMLS_CC)) { ZEPHIR_INIT_NVAR(_27$$37); ZEPHIR_INIT_NVAR(_28$$37); zephir_create_array(_28$$37, 1, 0 TSRMLS_CC); zephir_array_fast_append(_28$$37, matchPosition); ZEPHIR_CALL_USER_FUNC_ARRAY(_27$$37, converter, _28$$37); zephir_check_call_status(); zephir_array_update_zval(&parts, part, &_27$$37, PH_COPY | PH_SEPARATE); continue; } } zephir_array_update_zval(&parts, part, &matchPosition, PH_COPY | PH_SEPARATE); } else { if (Z_TYPE_P(converters) == IS_ARRAY) { ZEPHIR_OBS_NVAR(converter); if (zephir_array_isset_fetch(&converter, converters, part, 0 TSRMLS_CC)) { ZEPHIR_INIT_NVAR(_29$$40); ZEPHIR_INIT_NVAR(_30$$40); zephir_create_array(_30$$40, 1, 0 TSRMLS_CC); zephir_array_fast_append(_30$$40, position); ZEPHIR_CALL_USER_FUNC_ARRAY(_29$$40, converter, _30$$40); zephir_check_call_status(); zephir_array_update_zval(&parts, part, &_29$$40, PH_COPY | PH_SEPARATE); } } } } zephir_update_property_this(this_ptr, SL("_matches"), matches TSRMLS_CC); } zephir_update_property_this(this_ptr, SL("_matchedRoute"), route TSRMLS_CC); break; } } if (zephir_is_true(routeFound)) { if (1) { zephir_update_property_this(this_ptr, SL("_wasMatched"), ZEPHIR_GLOBAL(global_true) TSRMLS_CC); } else { zephir_update_property_this(this_ptr, SL("_wasMatched"), ZEPHIR_GLOBAL(global_false) TSRMLS_CC); } } else { if (0) { zephir_update_property_this(this_ptr, SL("_wasMatched"), ZEPHIR_GLOBAL(global_true) TSRMLS_CC); } else { zephir_update_property_this(this_ptr, SL("_wasMatched"), ZEPHIR_GLOBAL(global_false) TSRMLS_CC); } } if (!(zephir_is_true(routeFound))) { ZEPHIR_OBS_VAR(notFoundPaths); zephir_read_property_this(¬FoundPaths, this_ptr, SL("_notFoundPaths"), PH_NOISY_CC); if (Z_TYPE_P(notFoundPaths) != IS_NULL) { ZEPHIR_CALL_CE_STATIC(&parts, phalcon_mvc_router_route_ce, "getroutepaths", &_31, 79, notFoundPaths); zephir_check_call_status(); ZEPHIR_INIT_NVAR(routeFound); ZVAL_BOOL(routeFound, 1); } } _32 = zephir_fetch_nproperty_this(this_ptr, SL("_defaultNamespace"), PH_NOISY_CC); zephir_update_property_this(this_ptr, SL("_namespace"), _32 TSRMLS_CC); _33 = zephir_fetch_nproperty_this(this_ptr, SL("_defaultModule"), PH_NOISY_CC); zephir_update_property_this(this_ptr, SL("_module"), _33 TSRMLS_CC); _34 = zephir_fetch_nproperty_this(this_ptr, SL("_defaultController"), PH_NOISY_CC); zephir_update_property_this(this_ptr, SL("_controller"), _34 TSRMLS_CC); _35 = zephir_fetch_nproperty_this(this_ptr, SL("_defaultAction"), PH_NOISY_CC); zephir_update_property_this(this_ptr, SL("_action"), _35 TSRMLS_CC); _36 = zephir_fetch_nproperty_this(this_ptr, SL("_defaultParams"), PH_NOISY_CC); zephir_update_property_this(this_ptr, SL("_params"), _36 TSRMLS_CC); if (zephir_is_true(routeFound)) { ZEPHIR_OBS_VAR(vnamespace); if (zephir_array_isset_string_fetch(&vnamespace, parts, SS("namespace"), 0 TSRMLS_CC)) { if (!(zephir_is_numeric(vnamespace))) { zephir_update_property_this(this_ptr, SL("_namespace"), vnamespace TSRMLS_CC); } zephir_array_unset_string(&parts, SS("namespace"), PH_SEPARATE); } ZEPHIR_OBS_VAR(module); if (zephir_array_isset_string_fetch(&module, parts, SS("module"), 0 TSRMLS_CC)) { if (!(zephir_is_numeric(module))) { zephir_update_property_this(this_ptr, SL("_module"), module TSRMLS_CC); } zephir_array_unset_string(&parts, SS("module"), PH_SEPARATE); } ZEPHIR_OBS_VAR(controller); if (zephir_array_isset_string_fetch(&controller, parts, SS("controller"), 0 TSRMLS_CC)) { if (!(zephir_is_numeric(controller))) { zephir_update_property_this(this_ptr, SL("_controller"), controller TSRMLS_CC); } zephir_array_unset_string(&parts, SS("controller"), PH_SEPARATE); } ZEPHIR_OBS_VAR(action); if (zephir_array_isset_string_fetch(&action, parts, SS("action"), 0 TSRMLS_CC)) { if (!(zephir_is_numeric(action))) { zephir_update_property_this(this_ptr, SL("_action"), action TSRMLS_CC); } zephir_array_unset_string(&parts, SS("action"), PH_SEPARATE); } ZEPHIR_OBS_VAR(paramsStr); if (zephir_array_isset_string_fetch(¶msStr, parts, SS("params"), 0 TSRMLS_CC)) { if (Z_TYPE_P(paramsStr) == IS_STRING) { ZEPHIR_SINIT_VAR(_37$$55); ZVAL_STRING(&_37$$55, "/", 0); ZEPHIR_INIT_VAR(strParams); zephir_fast_trim(strParams, paramsStr, &_37$$55, ZEPHIR_TRIM_BOTH TSRMLS_CC); if (!ZEPHIR_IS_STRING_IDENTICAL(strParams, "")) { ZEPHIR_INIT_NVAR(params); zephir_fast_explode_str(params, SL("/"), strParams, LONG_MAX TSRMLS_CC); } } zephir_array_unset_string(&parts, SS("params"), PH_SEPARATE); } if (zephir_fast_count_int(params TSRMLS_CC)) { ZEPHIR_INIT_VAR(_38$$57); zephir_fast_array_merge(_38$$57, &(params), &(parts) TSRMLS_CC); zephir_update_property_this(this_ptr, SL("_params"), _38$$57 TSRMLS_CC); } else { zephir_update_property_this(this_ptr, SL("_params"), parts TSRMLS_CC); } } if (Z_TYPE_P(eventsManager) == IS_OBJECT) { ZEPHIR_INIT_VAR(_39$$59); ZVAL_STRING(_39$$59, "router:afterCheckRoutes", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, eventsManager, "fire", NULL, 0, _39$$59, this_ptr); zephir_check_temp_parameter(_39$$59); zephir_check_call_status(); } ZEPHIR_MM_RESTORE(); }
/** * Executes validator */ PHP_METHOD(Phalcon_Mvc_Model_Validator_Inclusionin, validate) { zval *_6; zend_bool _3; int ZEPHIR_LAST_CALL_STATUS; zval *record, *field = NULL, *domain = NULL, *value = NULL, *message = NULL, *strict = NULL, *_0 = NULL, *_1 = NULL, *_2 = NULL, *_4 = NULL, *_5 = NULL, *_7 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &record); ZEPHIR_INIT_VAR(_0); ZVAL_STRING(_0, "field", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&field, this_ptr, "getoption", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); if (Z_TYPE_P(field) != IS_STRING) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Field name must be a string", "phalcon/mvc/model/validator/inclusionin.zep", 63); return; } ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "domain", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_1, this_ptr, "issetoption", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); if (ZEPHIR_IS_FALSE_IDENTICAL(_1)) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "The option 'domain' is required for this validator", "phalcon/mvc/model/validator/inclusionin.zep", 70); return; } ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "domain", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&domain, this_ptr, "getoption", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); if (Z_TYPE_P(domain) != IS_ARRAY) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Option 'domain' must be an array", "phalcon/mvc/model/validator/inclusionin.zep", 75); return; } ZEPHIR_CALL_METHOD(&value, record, "readattribute", NULL, 0, field); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "allowEmpty", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_2, this_ptr, "issetoption", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); _3 = zephir_is_true(_2); if (_3) { _3 = ZEPHIR_IS_EMPTY(value); } if (_3) { RETURN_MM_BOOL(1); } ZEPHIR_INIT_VAR(strict); ZVAL_BOOL(strict, 0); ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "strict", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_4, this_ptr, "issetoption", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); if (zephir_is_true(_4)) { if (Z_TYPE_P(strict) != IS_BOOL) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Option 'strict' must be a boolean", "phalcon/mvc/model/validator/inclusionin.zep", 87); return; } ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "strict", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&strict, this_ptr, "getoption", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); } ZEPHIR_CALL_FUNCTION(&_5, "in_array", NULL, 358, value, domain, strict); zephir_check_call_status(); if (!(zephir_is_true(_5))) { ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "message", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, this_ptr, "getoption", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); if (ZEPHIR_IS_EMPTY(message)) { ZEPHIR_INIT_NVAR(message); ZVAL_STRING(message, "Value of field ':field' must be part of list: :domain", 1); } ZEPHIR_INIT_VAR(_6); zephir_create_array(_6, 2, 0 TSRMLS_CC); zephir_array_update_string(&_6, SL(":field"), &field, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_0); zephir_fast_join_str(_0, SL(", "), domain TSRMLS_CC); zephir_array_update_string(&_6, SL(":domain"), &_0, PH_COPY | PH_SEPARATE); ZEPHIR_CALL_FUNCTION(&_7, "strtr", NULL, 54, message, _6); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "Inclusion", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, this_ptr, "appendmessage", NULL, 0, _7, field, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); RETURN_MM_BOOL(0); } RETURN_MM_BOOL(1); }
/** * Stores cached content into the file backend * * @param string $keyName * @param string $content * @param boolean $stopBuffer */ PHP_METHOD(Phalcon_Cache_Backend_File, save){ zval *key_name = NULL, *content = NULL, *stop_buffer = NULL, *last_key = NULL; zval *front_end = NULL, *backend = NULL, *cache_dir = NULL, *cache_file = NULL; zval *cached_content = NULL, *prepared_content = NULL, *is_buffering = NULL; zval *t0 = NULL, *t1 = NULL, *t2 = NULL; zval *r0 = NULL, *r1 = NULL, *r2 = NULL, *r3 = NULL, *r4 = NULL, *r5 = NULL, *r6 = NULL; zval *i0 = NULL, *i1 = NULL; zval *c0 = NULL, *c1 = NULL; PHALCON_MM_GROW(); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|zzz", &key_name, &content, &stop_buffer) == FAILURE) { PHALCON_MM_RESTORE(); RETURN_NULL(); } if (!key_name) { PHALCON_INIT_VAR(key_name); ZVAL_NULL(key_name); } if (!content) { PHALCON_INIT_VAR(content); ZVAL_NULL(content); } if (!stop_buffer) { PHALCON_INIT_VAR(stop_buffer); ZVAL_BOOL(stop_buffer, 1); } if (Z_TYPE_P(key_name) == IS_NULL) { PHALCON_ALLOC_ZVAL_MM(t0); phalcon_read_property(&t0, this_ptr, "_lastKey", sizeof("_lastKey")-1, PHALCON_NOISY TSRMLS_CC); PHALCON_CPY_WRT(last_key, t0); } else { PHALCON_ALLOC_ZVAL_MM(r0); phalcon_filter_alphanum(r0, key_name); PHALCON_CPY_WRT(last_key, r0); } if (!zend_is_true(last_key)) { PHALCON_ALLOC_ZVAL_MM(i0); object_init_ex(i0, phalcon_cache_exception_ce); PHALCON_INIT_VAR(c0); ZVAL_STRING(c0, "The cache must be started first", 1); PHALCON_CALL_METHOD_PARAMS_1_NORETURN(i0, "__construct", c0, PHALCON_CHECK); phalcon_throw_exception(i0 TSRMLS_CC); return; } PHALCON_ALLOC_ZVAL_MM(t1); phalcon_read_property(&t1, this_ptr, "_frontendObject", sizeof("_frontendObject")-1, PHALCON_NOISY TSRMLS_CC); PHALCON_CPY_WRT(front_end, t1); PHALCON_ALLOC_ZVAL_MM(t2); phalcon_read_property(&t2, this_ptr, "_backendOptions", sizeof("_backendOptions")-1, PHALCON_NOISY TSRMLS_CC); PHALCON_CPY_WRT(backend, t2); PHALCON_ALLOC_ZVAL_MM(r1); phalcon_array_fetch_string(&r1, backend, "cacheDir", strlen("cacheDir"), PHALCON_NOISY TSRMLS_CC); PHALCON_CPY_WRT(cache_dir, r1); PHALCON_ALLOC_ZVAL_MM(r2); PHALCON_CALL_FUNC_PARAMS_1(r2, "is_writable", cache_dir, 0x017); if (!zend_is_true(r2)) { PHALCON_ALLOC_ZVAL_MM(i1); object_init_ex(i1, phalcon_cache_exception_ce); PHALCON_INIT_VAR(c1); ZVAL_STRING(c1, "The cache file is not writable", 1); PHALCON_CALL_METHOD_PARAMS_1_NORETURN(i1, "__construct", c1, PHALCON_CHECK); phalcon_throw_exception(i1 TSRMLS_CC); return; } PHALCON_ALLOC_ZVAL_MM(r3); concat_function(r3, cache_dir, last_key TSRMLS_CC); PHALCON_CPY_WRT(cache_file, r3); if (!zend_is_true(content)) { PHALCON_ALLOC_ZVAL_MM(r4); PHALCON_CALL_METHOD(r4, front_end, "getcontent", PHALCON_NO_CHECK); PHALCON_CPY_WRT(cached_content, r4); } else { PHALCON_CPY_WRT(cached_content, content); } PHALCON_ALLOC_ZVAL_MM(r5); PHALCON_CALL_METHOD_PARAMS_1(r5, front_end, "beforestore", cached_content, PHALCON_NO_CHECK); PHALCON_CPY_WRT(prepared_content, r5); PHALCON_CALL_FUNC_PARAMS_2_NORETURN("file_put_contents", cache_file, prepared_content, 0x01B); PHALCON_ALLOC_ZVAL_MM(r6); PHALCON_CALL_METHOD(r6, front_end, "isbuffering", PHALCON_NO_CHECK); PHALCON_CPY_WRT(is_buffering, r6); if (zend_is_true(stop_buffer)) { PHALCON_CALL_METHOD_NORETURN(front_end, "stop", PHALCON_NO_CHECK); } if (zend_is_true(is_buffering)) { zend_print_zval(cached_content, 1); } PHALCON_MM_RESTORE(); }
/** * Handles a MVC request * * @param string $uri * @return Phalcon\Http\ResponseInterface */ PHP_METHOD(Phalcon_Mvc_Application, handle){ zval *uri = NULL, *dependency_injector, *events_manager; zval *event_name = NULL, *status = NULL, *service = NULL, *router, *module_name = NULL; zval *module_object = NULL, *modules, *exception_msg = NULL; zval *module, *class_name = NULL, *path, *module_params; zval *implicit_view, *view, *namespace_name; zval *controller_name = NULL, *action_name = NULL, *params = NULL; zval *dispatcher, *controller, *returned_response = NULL; zval *possible_response, *render_status = NULL, *response = NULL; zval *content; PHALCON_MM_GROW(); phalcon_fetch_params(1, 0, 1, &uri); if (!uri) { PHALCON_INIT_VAR(uri); } PHALCON_OBS_VAR(dependency_injector); phalcon_read_property_this(&dependency_injector, this_ptr, SL("_dependencyInjector"), PH_NOISY_CC); if (Z_TYPE_P(dependency_injector) != IS_OBJECT) { PHALCON_THROW_EXCEPTION_STR(phalcon_mvc_application_exception_ce, "A dependency injection object is required to access internal services"); return; } PHALCON_OBS_VAR(events_manager); phalcon_read_property_this(&events_manager, this_ptr, SL("_eventsManager"), PH_NOISY_CC); /** * Call boot event, this allow the developer to perform initialization actions */ if (Z_TYPE_P(events_manager) == IS_OBJECT) { PHALCON_INIT_VAR(event_name); ZVAL_STRING(event_name, "application:boot", 1); PHALCON_INIT_VAR(status); phalcon_call_method_p2(status, events_manager, "fire", event_name, this_ptr); if (PHALCON_IS_FALSE(status)) { RETURN_MM_FALSE; } } PHALCON_INIT_VAR(service); ZVAL_STRING(service, "router", 1); PHALCON_INIT_VAR(router); phalcon_call_method_p1(router, dependency_injector, "getshared", service); /** * Handle the URI pattern (if any) */ phalcon_call_method_p1_noret(router, "handle", uri); /** * Load module config */ PHALCON_INIT_VAR(module_name); phalcon_call_method(module_name, router, "getmodulename"); /** * If the router doesn't return a valid module we use the default module */ if (!zend_is_true(module_name)) { PHALCON_OBS_NVAR(module_name); phalcon_read_property_this(&module_name, this_ptr, SL("_defaultModule"), PH_NOISY_CC); } PHALCON_INIT_VAR(module_object); /** * Process the module definition */ if (zend_is_true(module_name)) { if (Z_TYPE_P(events_manager) == IS_OBJECT) { PHALCON_INIT_NVAR(event_name); ZVAL_STRING(event_name, "application:beforeStartModule", 1); PHALCON_INIT_NVAR(status); phalcon_call_method_p3(status, events_manager, "fire", event_name, this_ptr, module_name); if (PHALCON_IS_FALSE(status)) { RETURN_MM_FALSE; } } /** * Check if the module passed by the router is registered in the modules container */ PHALCON_OBS_VAR(modules); phalcon_read_property_this(&modules, this_ptr, SL("_modules"), PH_NOISY_CC); if (!phalcon_array_isset(modules, module_name)) { PHALCON_INIT_VAR(exception_msg); PHALCON_CONCAT_SVS(exception_msg, "Module '", module_name, "' isn't registered in the application container"); PHALCON_THROW_EXCEPTION_ZVAL(phalcon_mvc_application_exception_ce, exception_msg); return; } /** * A module definition must ne an array or an object */ PHALCON_OBS_VAR(module); phalcon_array_fetch(&module, modules, module_name, PH_NOISY); if (Z_TYPE_P(module) != IS_ARRAY) { if (Z_TYPE_P(module) != IS_OBJECT) { PHALCON_THROW_EXCEPTION_STR(phalcon_mvc_application_exception_ce, "Invalid module definition"); return; } } /** * An array module definition contains a path to a module definition class */ if (Z_TYPE_P(module) == IS_ARRAY) { /** * Class name used to load the module definition */ if (phalcon_array_isset_string(module, SS("className"))) { PHALCON_OBS_VAR(class_name); phalcon_array_fetch_string(&class_name, module, SL("className"), PH_NOISY); } else { PHALCON_INIT_NVAR(class_name); ZVAL_STRING(class_name, "Module", 1); } /** * If developer specify a path try to include the file */ if (phalcon_array_isset_string(module, SS("path"))) { PHALCON_OBS_VAR(path); phalcon_array_fetch_string(&path, module, SL("path"), PH_NOISY); if (!phalcon_class_exists(class_name, 0 TSRMLS_CC)) { if (phalcon_file_exists(path TSRMLS_CC) == SUCCESS) { if (phalcon_require(path TSRMLS_CC) == FAILURE) { return; } } else { PHALCON_INIT_NVAR(exception_msg); PHALCON_CONCAT_SVS(exception_msg, "Module definition path '", path, "' doesn't exist"); PHALCON_THROW_EXCEPTION_ZVAL(phalcon_mvc_application_exception_ce, exception_msg); return; } } } phalcon_call_method_p1(module_object, dependency_injector, "get", class_name); /** * 'registerAutoloaders' and 'registerServices' are automatically called */ phalcon_call_method_p1_noret(module_object, "registerautoloaders", dependency_injector); phalcon_call_method_p1_noret(module_object, "registerservices", dependency_injector); } else { /** * A module definition object, can be a Closure instance */ if (phalcon_is_instance_of(module, SL("Closure") TSRMLS_CC)) { PHALCON_INIT_VAR(module_params); array_init_size(module_params, 1); phalcon_array_append(&module_params, dependency_injector, PH_SEPARATE); PHALCON_INIT_NVAR(status); PHALCON_CALL_USER_FUNC_ARRAY(status, module, module_params); } else { PHALCON_THROW_EXCEPTION_STR(phalcon_mvc_application_exception_ce, "Invalid module definition"); return; } } /** * Calling afterStartModule event */ if (Z_TYPE_P(events_manager) == IS_OBJECT) { phalcon_update_property_this(this_ptr, SL("_moduleObject"), module_object TSRMLS_CC); PHALCON_INIT_NVAR(event_name); ZVAL_STRING(event_name, "application:afterStartModule", 1); PHALCON_INIT_NVAR(status); phalcon_call_method_p3(status, events_manager, "fire", event_name, this_ptr, module_name); if (PHALCON_IS_FALSE(status)) { RETURN_MM_FALSE; } } } /** * Check whether use implicit views or not */ PHALCON_OBS_VAR(implicit_view); phalcon_read_property_this(&implicit_view, this_ptr, SL("_implicitView"), PH_NOISY_CC); if (PHALCON_IS_TRUE(implicit_view)) { PHALCON_INIT_NVAR(service); ZVAL_STRING(service, "view", 1); PHALCON_INIT_VAR(view); phalcon_call_method_p1(view, dependency_injector, "getshared", service); } /** * We get the parameters from the router and assign them to the dispatcher */ PHALCON_INIT_NVAR(module_name); phalcon_call_method(module_name, router, "getmodulename"); PHALCON_INIT_VAR(namespace_name); phalcon_call_method(namespace_name, router, "getnamespacename"); PHALCON_INIT_VAR(controller_name); phalcon_call_method(controller_name, router, "getcontrollername"); PHALCON_INIT_VAR(action_name); phalcon_call_method(action_name, router, "getactionname"); PHALCON_INIT_VAR(params); phalcon_call_method(params, router, "getparams"); PHALCON_INIT_NVAR(service); ZVAL_STRING(service, "dispatcher", 1); PHALCON_INIT_VAR(dispatcher); phalcon_call_method_p1(dispatcher, dependency_injector, "getshared", service); /** * Assign the values passed from the router */ phalcon_call_method_p1_noret(dispatcher, "setmodulename", module_name); phalcon_call_method_p1_noret(dispatcher, "setnamespacename", namespace_name); phalcon_call_method_p1_noret(dispatcher, "setcontrollername", controller_name); phalcon_call_method_p1_noret(dispatcher, "setactionname", action_name); phalcon_call_method_p1_noret(dispatcher, "setparams", params); /** * Start the view component (start output buffering) */ if (PHALCON_IS_TRUE(implicit_view)) { phalcon_call_method_noret(view, "start"); } /** * Calling beforeHandleRequest */ if (Z_TYPE_P(events_manager) == IS_OBJECT) { PHALCON_INIT_NVAR(event_name); ZVAL_STRING(event_name, "application:beforeHandleRequest", 1); PHALCON_INIT_NVAR(status); phalcon_call_method_p3(status, events_manager, "fire", event_name, this_ptr, dispatcher); if (PHALCON_IS_FALSE(status)) { RETURN_MM_FALSE; } } /** * The dispatcher must return an object */ PHALCON_INIT_VAR(controller); phalcon_call_method(controller, dispatcher, "dispatch"); PHALCON_INIT_VAR(returned_response); ZVAL_BOOL(returned_response, 0); /** * Get the latest value returned by an action */ PHALCON_INIT_VAR(possible_response); phalcon_call_method(possible_response, dispatcher, "getreturnedvalue"); if (Z_TYPE_P(possible_response) == IS_OBJECT) { /** * Check if the returned object is already a response */ phalcon_instance_of(returned_response, possible_response, phalcon_http_responseinterface_ce TSRMLS_CC); } /** * Calling afterHandleRequest */ if (Z_TYPE_P(events_manager) == IS_OBJECT) { PHALCON_INIT_NVAR(event_name); ZVAL_STRING(event_name, "application:afterHandleRequest", 1); phalcon_call_method_p3_noret(events_manager, "fire", event_name, this_ptr, controller); } /** * If the dispatcher returns an object we try to render the view in auto-rendering * mode */ if (PHALCON_IS_FALSE(returned_response)) { if (PHALCON_IS_TRUE(implicit_view)) { if (Z_TYPE_P(controller) == IS_OBJECT) { PHALCON_INIT_VAR(render_status); ZVAL_BOOL(render_status, 1); /** * This allows to make a custom view render */ if (Z_TYPE_P(events_manager) == IS_OBJECT) { PHALCON_INIT_NVAR(event_name); ZVAL_STRING(event_name, "application:viewRender", 1); phalcon_call_method_p3(render_status, events_manager, "fire", event_name, this_ptr, view); } /** * Check if the view process has been treated by the developer */ if (PHALCON_IS_NOT_FALSE(render_status)) { PHALCON_INIT_NVAR(controller_name); phalcon_call_method(controller_name, dispatcher, "getcontrollername"); PHALCON_INIT_NVAR(action_name); phalcon_call_method(action_name, dispatcher, "getactionname"); PHALCON_INIT_NVAR(params); phalcon_call_method(params, dispatcher, "getparams"); /** * Automatic render based on the latest controller executed */ phalcon_call_method_p3_noret(view, "render", controller_name, action_name, params); } } } } /** * Finish the view component (stop output buffering) */ if (PHALCON_IS_TRUE(implicit_view)) { phalcon_call_method_noret(view, "finish"); } if (PHALCON_IS_FALSE(returned_response)) { PHALCON_INIT_NVAR(service); ZVAL_STRING(service, "response", 1); PHALCON_INIT_VAR(response); phalcon_call_method_p1(response, dependency_injector, "getshared", service); if (PHALCON_IS_TRUE(implicit_view)) { /** * The content returned by the view is passed to the response service */ PHALCON_INIT_VAR(content); phalcon_call_method(content, view, "getcontent"); phalcon_call_method_p1_noret(response, "setcontent", content); } } else { /** * We don't need to create a response because there is a one already created */ PHALCON_CPY_WRT(response, possible_response); } /** * Calling beforeSendResponse */ if (Z_TYPE_P(events_manager) == IS_OBJECT) { PHALCON_INIT_NVAR(event_name); ZVAL_STRING(event_name, "application:beforeSendResponse", 1); phalcon_call_method_p3_noret(events_manager, "fire", event_name, this_ptr, response); } /** * Headers are automatically send */ phalcon_call_method_noret(response, "sendheaders"); /** * Cookies are automatically send */ phalcon_call_method_noret(response, "sendcookies"); /** * Return the response */ RETURN_CCTOR(response); }
/** * Handles routing information received from command-line arguments * * @param array arguments */ PHP_METHOD(Phalcon_Cli_Router, handle) { zval *_16 = NULL; zval *_6 = NULL, *_11 = NULL; zephir_nts_static zephir_fcall_cache_entry *_5 = NULL, *_19 = NULL; int ZEPHIR_LAST_CALL_STATUS; HashTable *_3, *_8; HashPosition _2, _7; zend_bool _0; zval *arguments = NULL, *moduleName = NULL, *taskName = NULL, *actionName = NULL, *params = NULL, *route = NULL, *parts = NULL, *pattern = NULL, *routeFound = NULL, *matches, *paths = NULL, *beforeMatch = NULL, *converters = NULL, *converter = NULL, *part = NULL, *position = NULL, *matchPosition = NULL, *strParams, *_1, **_4, **_9, *_10 = NULL, *_12, *_13, *_14, *_15, _17, *_18 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 1, &arguments); if (!arguments) { arguments = ZEPHIR_GLOBAL(global_null); } ZEPHIR_INIT_VAR(routeFound); ZVAL_BOOL(routeFound, 0); ZEPHIR_INIT_VAR(parts); array_init(parts); ZEPHIR_INIT_VAR(params); array_init(params); ZEPHIR_INIT_VAR(matches); ZVAL_NULL(matches); zephir_update_property_this(this_ptr, SL("_wasMatched"), (0) ? ZEPHIR_GLOBAL(global_true) : ZEPHIR_GLOBAL(global_false) TSRMLS_CC); zephir_update_property_this(this_ptr, SL("_matchedRoute"), ZEPHIR_GLOBAL(global_null) TSRMLS_CC); if (Z_TYPE_P(arguments) != IS_ARRAY) { _0 = Z_TYPE_P(arguments) != IS_STRING; if (_0) { _0 = Z_TYPE_P(arguments) != IS_NULL; } if (_0) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_cli_router_exception_ce, "Arguments must be an array or string", "phalcon/cli/router.zep", 223); return; } _1 = zephir_fetch_nproperty_this(this_ptr, SL("_routes"), PH_NOISY_CC); zephir_is_iterable(_1, &_3, &_2, 0, 1, "phalcon/cli/router.zep", 323); for ( ; zephir_hash_get_current_data_ex(_3, (void**) &_4, &_2) == SUCCESS ; zephir_hash_move_backwards_ex(_3, &_2) ) { ZEPHIR_GET_HVALUE(route, _4); ZEPHIR_CALL_METHOD(&pattern, route, "getcompiledpattern", NULL); zephir_check_call_status(); if (zephir_memnstr_str(pattern, SL("^"), "phalcon/cli/router.zep", 233)) { Z_SET_ISREF_P(matches); ZEPHIR_CALL_FUNCTION(&routeFound, "preg_match", &_5, pattern, arguments, matches); Z_UNSET_ISREF_P(matches); zephir_check_call_status(); } else { ZEPHIR_INIT_NVAR(routeFound); ZVAL_BOOL(routeFound, ZEPHIR_IS_EQUAL(pattern, arguments)); } if (zephir_is_true(routeFound)) { ZEPHIR_CALL_METHOD(&beforeMatch, route, "getbeforematch", NULL); zephir_check_call_status(); if (Z_TYPE_P(beforeMatch) != IS_NULL) { if (!(zephir_is_callable(beforeMatch TSRMLS_CC))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_cli_router_exception_ce, "Before-Match callback is not callable in matched route", "phalcon/cli/router.zep", 251); return; } ZEPHIR_INIT_NVAR(routeFound); ZEPHIR_INIT_NVAR(_6); zephir_create_array(_6, 3, 0 TSRMLS_CC); zephir_array_fast_append(_6, arguments); zephir_array_fast_append(_6, route); zephir_array_fast_append(_6, this_ptr); ZEPHIR_CALL_USER_FUNC_ARRAY(routeFound, beforeMatch, _6); zephir_check_call_status(); } } if (zephir_is_true(routeFound)) { ZEPHIR_CALL_METHOD(&paths, route, "getpaths", NULL); zephir_check_call_status(); ZEPHIR_CPY_WRT(parts, paths); if (Z_TYPE_P(matches) == IS_ARRAY) { ZEPHIR_CALL_METHOD(&converters, route, "getconverters", NULL); zephir_check_call_status(); zephir_is_iterable(paths, &_8, &_7, 0, 0, "phalcon/cli/router.zep", 312); for ( ; zephir_hash_get_current_data_ex(_8, (void**) &_9, &_7) == SUCCESS ; zephir_hash_move_forward_ex(_8, &_7) ) { ZEPHIR_GET_HMKEY(part, _8, _7); ZEPHIR_GET_HVALUE(position, _9); ZEPHIR_OBS_NVAR(matchPosition); if (zephir_array_isset_fetch(&matchPosition, matches, position, 0 TSRMLS_CC)) { if (Z_TYPE_P(converters) == IS_ARRAY) { ZEPHIR_OBS_NVAR(converter); if (zephir_array_isset_fetch(&converter, converters, part, 0 TSRMLS_CC)) { ZEPHIR_INIT_NVAR(_10); ZEPHIR_INIT_NVAR(_6); zephir_create_array(_6, 1, 0 TSRMLS_CC); zephir_array_fast_append(_6, matchPosition); ZEPHIR_CALL_USER_FUNC_ARRAY(_10, converter, _6); zephir_check_call_status(); zephir_array_update_zval(&parts, part, &_10, PH_COPY | PH_SEPARATE); continue; } } zephir_array_update_zval(&parts, part, &matchPosition, PH_COPY | PH_SEPARATE); } else { if (Z_TYPE_P(converters) == IS_ARRAY) { ZEPHIR_OBS_NVAR(converter); if (zephir_array_isset_fetch(&converter, converters, part, 0 TSRMLS_CC)) { ZEPHIR_INIT_NVAR(_10); ZEPHIR_INIT_NVAR(_11); zephir_create_array(_11, 1, 0 TSRMLS_CC); zephir_array_fast_append(_11, position); ZEPHIR_CALL_USER_FUNC_ARRAY(_10, converter, _11); zephir_check_call_status(); zephir_array_update_zval(&parts, part, &_10, PH_COPY | PH_SEPARATE); } } } } zephir_update_property_this(this_ptr, SL("_matches"), matches TSRMLS_CC); } zephir_update_property_this(this_ptr, SL("_matchedRoute"), route TSRMLS_CC); break; } } if (zephir_is_true(routeFound)) { zephir_update_property_this(this_ptr, SL("_wasMatched"), (1) ? ZEPHIR_GLOBAL(global_true) : ZEPHIR_GLOBAL(global_false) TSRMLS_CC); } else { zephir_update_property_this(this_ptr, SL("_wasMatched"), (0) ? ZEPHIR_GLOBAL(global_true) : ZEPHIR_GLOBAL(global_false) TSRMLS_CC); _12 = zephir_fetch_nproperty_this(this_ptr, SL("_defaultModule"), PH_NOISY_CC); zephir_update_property_this(this_ptr, SL("_module"), _12 TSRMLS_CC); _13 = zephir_fetch_nproperty_this(this_ptr, SL("_defaultTask"), PH_NOISY_CC); zephir_update_property_this(this_ptr, SL("_task"), _13 TSRMLS_CC); _14 = zephir_fetch_nproperty_this(this_ptr, SL("_defaultAction"), PH_NOISY_CC); zephir_update_property_this(this_ptr, SL("_action"), _14 TSRMLS_CC); _15 = zephir_fetch_nproperty_this(this_ptr, SL("_defaultParams"), PH_NOISY_CC); zephir_update_property_this(this_ptr, SL("_params"), _15 TSRMLS_CC); RETURN_THIS(); } } else { ZEPHIR_CPY_WRT(parts, arguments); } ZEPHIR_INIT_VAR(moduleName); ZVAL_NULL(moduleName); ZEPHIR_INIT_VAR(taskName); ZVAL_NULL(taskName); ZEPHIR_INIT_VAR(actionName); ZVAL_NULL(actionName); ZEPHIR_OBS_NVAR(moduleName); if (zephir_array_isset_string_fetch(&moduleName, parts, SS("module"), 0 TSRMLS_CC)) { zephir_array_unset_string(&parts, SS("module"), PH_SEPARATE); } else { ZEPHIR_OBS_NVAR(moduleName); zephir_read_property_this(&moduleName, this_ptr, SL("_defaultModule"), PH_NOISY_CC); } ZEPHIR_OBS_NVAR(taskName); if (zephir_array_isset_string_fetch(&taskName, parts, SS("task"), 0 TSRMLS_CC)) { zephir_array_unset_string(&parts, SS("task"), PH_SEPARATE); } else { ZEPHIR_OBS_NVAR(taskName); zephir_read_property_this(&taskName, this_ptr, SL("_defaultTask"), PH_NOISY_CC); } ZEPHIR_OBS_NVAR(actionName); if (zephir_array_isset_string_fetch(&actionName, parts, SS("action"), 0 TSRMLS_CC)) { zephir_array_unset_string(&parts, SS("action"), PH_SEPARATE); } else { ZEPHIR_OBS_NVAR(actionName); zephir_read_property_this(&actionName, this_ptr, SL("_defaultAction"), PH_NOISY_CC); } if (zephir_is_true(routeFound)) { ZEPHIR_OBS_NVAR(params); if (zephir_array_isset_string_fetch(¶ms, parts, SS("params"), 0 TSRMLS_CC)) { if (Z_TYPE_P(params) != IS_ARRAY) { zephir_get_strval(_16, params); ZEPHIR_SINIT_VAR(_17); ZVAL_LONG(&_17, 1); ZEPHIR_INIT_VAR(strParams); zephir_substr(strParams, _16, 1 , 0, ZEPHIR_SUBSTR_NO_LENGTH); if (zephir_is_true(strParams)) { ZEPHIR_INIT_NVAR(params); ZEPHIR_CALL_CE_STATIC(&_18, phalcon_cli_router_route_ce, "getdelimiter", &_19); zephir_check_call_status(); zephir_fast_explode(params, _18, strParams, LONG_MAX TSRMLS_CC); } else { ZEPHIR_INIT_NVAR(params); array_init(params); } } zephir_array_unset_string(&parts, SS("params"), PH_SEPARATE); } if (zephir_fast_count_int(params TSRMLS_CC)) { ZEPHIR_INIT_NVAR(_10); zephir_fast_array_merge(_10, &(params), &(parts) TSRMLS_CC); ZEPHIR_CPY_WRT(params, _10); } else { ZEPHIR_CPY_WRT(params, parts); } } else { ZEPHIR_CPY_WRT(params, parts); } zephir_update_property_this(this_ptr, SL("_module"), moduleName TSRMLS_CC); zephir_update_property_this(this_ptr, SL("_task"), taskName TSRMLS_CC); zephir_update_property_this(this_ptr, SL("_action"), actionName TSRMLS_CC); zephir_update_property_this(this_ptr, SL("_params"), params TSRMLS_CC); ZEPHIR_MM_RESTORE(); }
/** * Phalcon\Di\FactoryDefault\CLI constructor */ PHP_METHOD(Phalcon_Di_FactoryDefault_Cli, __construct) { zval *_2 = NULL, *_3 = NULL, *_4 = NULL, _5 = zval_used_for_init; zval *_1; int ZEPHIR_LAST_CALL_STATUS; zephir_fcall_cache_entry *_0 = NULL, *_6 = NULL; ZEPHIR_MM_GROW(); ZEPHIR_CALL_PARENT(NULL, phalcon_di_factorydefault_cli_ce, this_ptr, "__construct", &_0, 175); zephir_check_call_status(); ZEPHIR_INIT_VAR(_1); zephir_create_array(_1, 10, 0 TSRMLS_CC); ZEPHIR_INIT_VAR(_2); object_init_ex(_2, phalcon_di_service_ce); ZEPHIR_INIT_VAR(_3); ZVAL_STRING(_3, "router", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_VAR(_4); ZVAL_STRING(_4, "Phalcon\\CLI\\Router", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_SINIT_VAR(_5); ZVAL_BOOL(&_5, 1); ZEPHIR_CALL_METHOD(NULL, _2, "__construct", &_6, 63, _3, _4, &_5); zephir_check_temp_parameter(_3); zephir_check_temp_parameter(_4); zephir_check_call_status(); zephir_array_update_string(&_1, SL("router"), &_2, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_2); object_init_ex(_2, phalcon_di_service_ce); ZEPHIR_INIT_NVAR(_3); ZVAL_STRING(_3, "dispatcher", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_4); ZVAL_STRING(_4, "Phalcon\\CLI\\Dispatcher", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_SINIT_NVAR(_5); ZVAL_BOOL(&_5, 1); ZEPHIR_CALL_METHOD(NULL, _2, "__construct", &_6, 63, _3, _4, &_5); zephir_check_temp_parameter(_3); zephir_check_temp_parameter(_4); zephir_check_call_status(); zephir_array_update_string(&_1, SL("dispatcher"), &_2, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_2); object_init_ex(_2, phalcon_di_service_ce); ZEPHIR_INIT_NVAR(_3); ZVAL_STRING(_3, "modelsManager", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_4); ZVAL_STRING(_4, "Phalcon\\Mvc\\Model\\Manager", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_SINIT_NVAR(_5); ZVAL_BOOL(&_5, 1); ZEPHIR_CALL_METHOD(NULL, _2, "__construct", &_6, 63, _3, _4, &_5); zephir_check_temp_parameter(_3); zephir_check_temp_parameter(_4); zephir_check_call_status(); zephir_array_update_string(&_1, SL("modelsManager"), &_2, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_2); object_init_ex(_2, phalcon_di_service_ce); ZEPHIR_INIT_NVAR(_3); ZVAL_STRING(_3, "modelsMetadata", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_4); ZVAL_STRING(_4, "Phalcon\\Mvc\\Model\\MetaData\\Memory", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_SINIT_NVAR(_5); ZVAL_BOOL(&_5, 1); ZEPHIR_CALL_METHOD(NULL, _2, "__construct", &_6, 63, _3, _4, &_5); zephir_check_temp_parameter(_3); zephir_check_temp_parameter(_4); zephir_check_call_status(); zephir_array_update_string(&_1, SL("modelsMetadata"), &_2, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_2); object_init_ex(_2, phalcon_di_service_ce); ZEPHIR_INIT_NVAR(_3); ZVAL_STRING(_3, "filter", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_4); ZVAL_STRING(_4, "Phalcon\\Filter", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_SINIT_NVAR(_5); ZVAL_BOOL(&_5, 1); ZEPHIR_CALL_METHOD(NULL, _2, "__construct", &_6, 63, _3, _4, &_5); zephir_check_temp_parameter(_3); zephir_check_temp_parameter(_4); zephir_check_call_status(); zephir_array_update_string(&_1, SL("filter"), &_2, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_2); object_init_ex(_2, phalcon_di_service_ce); ZEPHIR_INIT_NVAR(_3); ZVAL_STRING(_3, "escaper", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_4); ZVAL_STRING(_4, "Phalcon\\Escaper", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_SINIT_NVAR(_5); ZVAL_BOOL(&_5, 1); ZEPHIR_CALL_METHOD(NULL, _2, "__construct", &_6, 63, _3, _4, &_5); zephir_check_temp_parameter(_3); zephir_check_temp_parameter(_4); zephir_check_call_status(); zephir_array_update_string(&_1, SL("escaper"), &_2, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_2); object_init_ex(_2, phalcon_di_service_ce); ZEPHIR_INIT_NVAR(_3); ZVAL_STRING(_3, "annotations", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_4); ZVAL_STRING(_4, "Phalcon\\Annotations\\Adapter\\Memory", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_SINIT_NVAR(_5); ZVAL_BOOL(&_5, 1); ZEPHIR_CALL_METHOD(NULL, _2, "__construct", &_6, 63, _3, _4, &_5); zephir_check_temp_parameter(_3); zephir_check_temp_parameter(_4); zephir_check_call_status(); zephir_array_update_string(&_1, SL("annotations"), &_2, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_2); object_init_ex(_2, phalcon_di_service_ce); ZEPHIR_INIT_NVAR(_3); ZVAL_STRING(_3, "security", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_4); ZVAL_STRING(_4, "Phalcon\\Security", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_SINIT_NVAR(_5); ZVAL_BOOL(&_5, 1); ZEPHIR_CALL_METHOD(NULL, _2, "__construct", &_6, 63, _3, _4, &_5); zephir_check_temp_parameter(_3); zephir_check_temp_parameter(_4); zephir_check_call_status(); zephir_array_update_string(&_1, SL("security"), &_2, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_2); object_init_ex(_2, phalcon_di_service_ce); ZEPHIR_INIT_NVAR(_3); ZVAL_STRING(_3, "eventsManager", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_4); ZVAL_STRING(_4, "Phalcon\\Events\\Manager", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_SINIT_NVAR(_5); ZVAL_BOOL(&_5, 1); ZEPHIR_CALL_METHOD(NULL, _2, "__construct", &_6, 63, _3, _4, &_5); zephir_check_temp_parameter(_3); zephir_check_temp_parameter(_4); zephir_check_call_status(); zephir_array_update_string(&_1, SL("eventsManager"), &_2, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_2); object_init_ex(_2, phalcon_di_service_ce); ZEPHIR_INIT_NVAR(_3); ZVAL_STRING(_3, "transactionManager", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_4); ZVAL_STRING(_4, "Phalcon\\Mvc\\Model\\Transaction\\Manager", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_SINIT_NVAR(_5); ZVAL_BOOL(&_5, 1); ZEPHIR_CALL_METHOD(NULL, _2, "__construct", &_6, 63, _3, _4, &_5); zephir_check_temp_parameter(_3); zephir_check_temp_parameter(_4); zephir_check_call_status(); zephir_array_update_string(&_1, SL("transactionManager"), &_2, PH_COPY | PH_SEPARATE); zephir_update_property_this(this_ptr, SL("_services"), _1 TSRMLS_CC); ZEPHIR_MM_RESTORE(); }
/** * Initialize the metadata for certain table * * @param Phalcon\Mvc\Model $model * @param string $table * @param string $schema */ PHP_METHOD(Phalcon_Mvc_Model_MetaData, _initializeMetaData){ zval *model = NULL, *table = NULL, *schema = NULL, *key = NULL, *connection = NULL, *exists = NULL; zval *complete_table = NULL, *attributes = NULL, *primary_keys = NULL; zval *non_primary_keys = NULL, *numeric_typed = NULL, *not_null = NULL; zval *field_types = NULL, *identity_field = NULL, *columns = NULL; zval *column = NULL, *field_name = NULL, *table_metadata = NULL; zval *t0 = NULL, *t1 = NULL, *t2 = NULL; zval *i0 = NULL; zval *r0 = NULL, *r1 = NULL, *r2 = NULL, *r3 = NULL, *r4 = NULL, *r5 = NULL, *r6 = NULL; zval *a0 = NULL; HashTable *ah0; HashPosition hp0; zval **hd; int eval_int; PHALCON_MM_GROW(); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zzz", &model, &table, &schema) == FAILURE) { PHALCON_MM_RESTORE(); RETURN_NULL(); } PHALCON_INIT_VAR(key); PHALCON_CONCAT_VV(key, schema, table); PHALCON_ALLOC_ZVAL_MM(t0); phalcon_read_property(&t0, this_ptr, SL("_metaData"), PH_NOISY_CC); eval_int = phalcon_array_isset(t0, key); if (!eval_int) { PHALCON_INIT_VAR(connection); PHALCON_CALL_METHOD(connection, model, "getconnection", PH_NO_CHECK); PHALCON_INIT_VAR(exists); PHALCON_CALL_METHOD_PARAMS_2(exists, connection, "tableexists", table, schema, PH_NO_CHECK); if (!zend_is_true(exists)) { if (zend_is_true(schema)) { PHALCON_INIT_VAR(complete_table); PHALCON_CONCAT_VSV(complete_table, schema, "\".\"", table); } else { PHALCON_CPY_WRT(complete_table, table); } PHALCON_ALLOC_ZVAL_MM(i0); object_init_ex(i0, phalcon_mvc_model_exception_ce); PHALCON_ALLOC_ZVAL_MM(r0); phalcon_get_class(r0, model TSRMLS_CC); PHALCON_ALLOC_ZVAL_MM(r1); PHALCON_CONCAT_SVSV(r1, "Table \"", complete_table, "\" doesn't exist on database when dumping meta-data for ", r0); PHALCON_CALL_METHOD_PARAMS_1_NORETURN(i0, "__construct", r1, PH_CHECK); phalcon_throw_exception(i0 TSRMLS_CC); return; } PHALCON_INIT_VAR(attributes); array_init(attributes); PHALCON_INIT_VAR(primary_keys); array_init(primary_keys); PHALCON_INIT_VAR(non_primary_keys); array_init(non_primary_keys); PHALCON_INIT_VAR(numeric_typed); array_init(numeric_typed); PHALCON_INIT_VAR(not_null); array_init(not_null); PHALCON_INIT_VAR(field_types); array_init(field_types); PHALCON_INIT_VAR(identity_field); ZVAL_BOOL(identity_field, 0); PHALCON_INIT_VAR(columns); PHALCON_CALL_METHOD_PARAMS_2(columns, connection, "describecolumns", table, schema, PH_NO_CHECK); if (!phalcon_valid_foreach(columns TSRMLS_CC)) { return; } ah0 = Z_ARRVAL_P(columns); zend_hash_internal_pointer_reset_ex(ah0, &hp0); fes_c40c_0: if(zend_hash_get_current_data_ex(ah0, (void**) &hd, &hp0) != SUCCESS){ goto fee_c40c_0; } PHALCON_INIT_VAR(column); ZVAL_ZVAL(column, *hd, 1, 0); PHALCON_INIT_VAR(field_name); PHALCON_CALL_METHOD(field_name, column, "getname", PH_NO_CHECK); phalcon_array_append(&attributes, field_name, PH_SEPARATE TSRMLS_CC); PHALCON_INIT_VAR(r2); PHALCON_CALL_METHOD(r2, column, "isprimary", PH_NO_CHECK); if (zend_is_true(r2)) { phalcon_array_append(&primary_keys, field_name, PH_SEPARATE TSRMLS_CC); } else { phalcon_array_append(&non_primary_keys, field_name, PH_SEPARATE TSRMLS_CC); } PHALCON_INIT_VAR(r3); PHALCON_CALL_METHOD(r3, column, "isnumeric", PH_NO_CHECK); if (zend_is_true(r3)) { phalcon_array_update_zval_bool(&numeric_typed, field_name, 1, PH_SEPARATE TSRMLS_CC); } PHALCON_INIT_VAR(r4); PHALCON_CALL_METHOD(r4, column, "isnotnull", PH_NO_CHECK); if (zend_is_true(r4)) { phalcon_array_append(¬_null, field_name, PH_SEPARATE TSRMLS_CC); } PHALCON_INIT_VAR(r5); PHALCON_CALL_METHOD(r5, column, "isautoincrement", PH_NO_CHECK); if (zend_is_true(r5)) { PHALCON_CPY_WRT(identity_field, field_name); } PHALCON_INIT_VAR(r6); PHALCON_CALL_METHOD(r6, column, "gettype", PH_NO_CHECK); phalcon_array_update_zval(&field_types, field_name, &r6, PH_COPY | PH_SEPARATE TSRMLS_CC); zend_hash_move_forward_ex(ah0, &hp0); goto fes_c40c_0; fee_c40c_0: if(0){} PHALCON_INIT_VAR(table_metadata); array_init(table_metadata); phalcon_array_update_long(&table_metadata, 0, &attributes, PH_COPY | PH_SEPARATE TSRMLS_CC); phalcon_array_update_long(&table_metadata, 1, &primary_keys, PH_COPY | PH_SEPARATE TSRMLS_CC); phalcon_array_update_long(&table_metadata, 2, &non_primary_keys, PH_COPY | PH_SEPARATE TSRMLS_CC); phalcon_array_update_long(&table_metadata, 3, ¬_null, PH_COPY | PH_SEPARATE TSRMLS_CC); phalcon_array_update_long(&table_metadata, 4, &field_types, PH_COPY | PH_SEPARATE TSRMLS_CC); phalcon_array_update_long(&table_metadata, 5, &numeric_typed, PH_COPY | PH_SEPARATE TSRMLS_CC); phalcon_array_update_long(&table_metadata, 8, &identity_field, PH_COPY | PH_SEPARATE TSRMLS_CC); PHALCON_ALLOC_ZVAL_MM(t1); phalcon_read_property(&t1, this_ptr, SL("_metaData"), PH_NOISY_CC); phalcon_array_update_zval(&t1, key, &table_metadata, PH_COPY TSRMLS_CC); phalcon_update_property_zval(this_ptr, SL("_metaData"), t1 TSRMLS_CC); PHALCON_ALLOC_ZVAL_MM(t2); phalcon_read_property(&t2, this_ptr, SL("_changed"), PH_NOISY_CC); if (!zend_is_true(t2)) { PHALCON_ALLOC_ZVAL_MM(a0); array_init(a0); phalcon_array_append(&a0, this_ptr, PH_SEPARATE TSRMLS_CC); add_next_index_stringl(a0, SL("storeMetaData"), 1); PHALCON_CALL_FUNC_PARAMS_1_NORETURN("register_shutdown_function", a0); phalcon_update_property_bool(this_ptr, SL("_changed"), 1 TSRMLS_CC); } } PHALCON_MM_RESTORE(); }
static void dic_optimizer_get_handler(INTERNAL_FUNCTION_PARAMETERS) { char *id, should_free = 1; zend_ulong id_hash; int id_len, i; long oninvalid, exception_on_invalid_reference_const; zval **found_service, **alias, **method_in_map = NULL, *this_services, *this_aliases, *this_methodMap, *this_loading; zend_function *method = NULL; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|l", &id, &id_len, &oninvalid) == FAILURE) { return; } if (strcasecmp(id, "service_container") == 0) { RETURN_THIS; } this_services = zend_read_property(Z_OBJCE_P(getThis()), getThis(), SYMFONY_DIC_TOKEN_SERVICES_KEY, sizeof(SYMFONY_DIC_TOKEN_SERVICES_KEY) - 1, 0 TSRMLS_CC); this_aliases = zend_read_property(Z_OBJCE_P(getThis()), getThis(), SYMFONY_DIC_TOKEN_ALIASES_KEY, sizeof(SYMFONY_DIC_TOKEN_ALIASES_KEY) - 1, 0 TSRMLS_CC); this_loading = zend_read_property(Z_OBJCE_P(getThis()), getThis(), SYMFONY_DIC_TOKEN_LOADING_KEY, sizeof(SYMFONY_DIC_TOKEN_LOADING_KEY) - 1, 0 TSRMLS_CC); this_methodMap = zend_read_property(Z_OBJCE_P(getThis()), getThis(), SYMFONY_DIC_TOKEN_METHODMAP_KEY, sizeof(SYMFONY_DIC_TOKEN_METHODMAP_KEY) - 1, 0 TSRMLS_CC); if (!SYMFONY_DIC_G(cache_done)) { zval invalidBehavior; zend_class_entry **exception_ce; zend_get_constant_ex("self::EXCEPTION_ON_INVALID_REFERENCE", sizeof("self::EXCEPTION_ON_INVALID_REFERENCE") - 1, &invalidBehavior, Z_OBJCE_P(getThis()), 0 TSRMLS_CC); SYMFONY_DIC_G(invalid_behavior) = Z_LVAL(invalidBehavior); if (FAILURE == zend_lookup_class(SYMFONY_DIC_TOKEN_SERVICE_CIRCULAR_REFERENCE_EXCEPTION_KEY_UP, sizeof(SYMFONY_DIC_TOKEN_SERVICE_CIRCULAR_REFERENCE_EXCEPTION_KEY_UP) - 1, &exception_ce TSRMLS_CC)) { zend_error_noreturn(E_ERROR, "Class %s not found", SYMFONY_DIC_TOKEN_SERVICE_CIRCULAR_REFERENCE_EXCEPTION_KEY_UP); } SYMFONY_DIC_G(ServiceCircularReferenceException) = *exception_ce; if (FAILURE == zend_lookup_class(SYMFONY_DIC_TOKEN_SERVICE_NOT_FOUND_EXCEPTION_KEY_UP, sizeof(SYMFONY_DIC_TOKEN_SERVICE_NOT_FOUND_EXCEPTION_KEY_UP) - 1, &exception_ce TSRMLS_CC)) { zend_error_noreturn(E_ERROR, "Class %s not found", SYMFONY_DIC_TOKEN_SERVICE_NOT_FOUND_EXCEPTION_KEY_UP); } SYMFONY_DIC_G(ServiceNotFoundException) = *exception_ce; if (FAILURE == zend_lookup_class(SYMFONY_DIC_TOKEN_INACTIVE_SCOPE_EXCEPTION_KEY_UP, sizeof(SYMFONY_DIC_TOKEN_INACTIVE_SCOPE_EXCEPTION_KEY_UP) - 1, &exception_ce TSRMLS_CC)) { zend_error_noreturn(E_ERROR, "Class %s not found", SYMFONY_DIC_TOKEN_INACTIVE_SCOPE_EXCEPTION_KEY_UP); } SYMFONY_DIC_G(InactiveScopeException) = *exception_ce; SYMFONY_DIC_G(cache_done) = 1; } exception_on_invalid_reference_const = SYMFONY_DIC_G(invalid_behavior); if (ZEND_NUM_ARGS() <= 1) { oninvalid = exception_on_invalid_reference_const; } if (IS_INTERNED(id)) { id_hash = INTERNED_HASH(id); } else { id_hash = zend_inline_hash_func(id, id_len + 1); } id = estrndup(id, id_len); /* zend_str_tolower will change it otherwise */ for (i = 0; i <= 1; i++, zend_str_tolower(id, id_len), id_hash = zend_inline_hash_func(id, id_len + 1)) { if (zend_hash_quick_find(Z_ARRVAL_P(this_aliases), id, id_len + 1, id_hash, (void **)&alias) == SUCCESS) { should_free = 0; efree(id); id = Z_STRVAL_PP(alias); id_len = Z_STRLEN_PP(alias); id_hash = zend_inline_hash_func(id, id_len + 1); } if (zend_hash_quick_find(Z_ARRVAL_P(this_services), id, id_len + 1, id_hash, (void **)&found_service) == SUCCESS) { RETVAL_ZVAL_FAST(*found_service); goto free_and_return; } } if (zend_hash_quick_exists(Z_ARRVAL_P(this_loading), id, id_len + 1, id_hash)) { zval *ServiceCircularReferenceException; ALLOC_INIT_ZVAL(ServiceCircularReferenceException); /* ctor_args */ object_init_ex(ServiceCircularReferenceException, SYMFONY_DIC_G(ServiceCircularReferenceException)); zend_throw_exception_object(ServiceCircularReferenceException TSRMLS_CC); goto free_and_return; } zend_hash_quick_find(Z_ARRVAL_P(this_methodMap), id, id_len + 1, id_hash, (void **)&method_in_map); if (!method_in_map) { char *new_id; for (i=0; i < id_len; i++) { if (id[i] == '_') { memmove(&id[i], &id[i + 1], --id_len); } } php_strtr(id, id_len, ".\\", "__", 2); id_len = spprintf(&new_id, 0, "get%sservice", id); efree(id); id = new_id; id_hash = zend_inline_hash_func(id, id_len + 1); zend_hash_quick_find(&Z_OBJCE_P(getThis())->function_table, id, id_len + 1, id_hash, (void **)&method); if (!method) { if (oninvalid == exception_on_invalid_reference_const) { zval *ServiceNotFoundException; ALLOC_INIT_ZVAL(ServiceNotFoundException); object_init_ex(ServiceNotFoundException, SYMFONY_DIC_G(ServiceNotFoundException)); zend_throw_exception_object(ServiceNotFoundException TSRMLS_CC); /* ctor_args */ } goto free_and_return; } } else { char *method_name_lc; method_name_lc = zend_str_tolower_dup(Z_STRVAL_PP(method_in_map), Z_STRLEN_PP(method_in_map)); zend_hash_find(&Z_OBJCE_P(getThis())->function_table, method_name_lc, Z_STRLEN_PP(method_in_map) + 1, (void **)&method); efree(method_name_lc); } zend_fcall_info fci = {0}; zend_fcall_info_cache fcic = {0}; zval *loading, *result; ALLOC_INIT_ZVAL(loading); ZVAL_BOOL(loading, 1); zend_hash_quick_add(Z_ARRVAL_P(this_loading), id, id_len + 1, id_hash, &loading, sizeof(zval *), NULL); fcic.called_scope = Z_OBJCE_P(getThis()); fcic.calling_scope = Z_OBJCE_P(getThis()); fcic.function_handler = method; fcic.initialized = 1; fcic.object_ptr = getThis(); fci.retval_ptr_ptr = &result; fci.size = sizeof(zend_fcall_info); zend_call_function(&fci, &fcic TSRMLS_CC); zend_hash_quick_del(Z_ARRVAL_P(this_loading), id, id_len + 1, id_hash); if (!EG(exception)) { RETVAL_ZVAL_FAST(result); } else { zend_hash_quick_del(Z_ARRVAL_P(this_services), id, id_len, id_hash); if (instanceof_function(Z_OBJCE_P(EG(exception)), SYMFONY_DIC_G(InactiveScopeException) TSRMLS_CC) && oninvalid == exception_on_invalid_reference_const) { EG(exception) = NULL; } } zval_ptr_dtor(&result); free_and_return: if (should_free) { efree(id); } return; }
/** * Tries to render the view with every engine registered in the component * * @param string path * @param array params */ PHP_METHOD(Phalcon_Mvc_View_Simple, _internalRender) { HashTable *_4; HashPosition _3; zend_bool notExists = 0, mustClean = 0, _7$$8, _10$$8; zephir_fcall_cache_entry *_13 = NULL, *_16 = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; zval *path_param = NULL, *params, *eventsManager = NULL, *engines = NULL, *extension = NULL, *engine = NULL, *viewEnginePath = NULL, *viewsDirPath = NULL, *_2, **_5, *_0$$4 = NULL, *_1$$4, *_6$$6 = NULL, _8$$8 = zval_used_for_init, *_9$$8 = NULL, *_11$$12 = NULL, *_12$$12 = NULL, *_14$$11 = NULL, *_15$$14 = NULL, *_17$$15, *_18$$15, *_19$$16; zval *path = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &path_param, ¶ms); if (UNEXPECTED(Z_TYPE_P(path_param) != IS_STRING && Z_TYPE_P(path_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'path' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (EXPECTED(Z_TYPE_P(path_param) == IS_STRING)) { zephir_get_strval(path, path_param); } else { ZEPHIR_INIT_VAR(path); ZVAL_EMPTY_STRING(path); } ZEPHIR_OBS_VAR(eventsManager); zephir_read_property_this(&eventsManager, this_ptr, SL("_eventsManager"), PH_NOISY_CC); if (Z_TYPE_P(eventsManager) == IS_OBJECT) { zephir_update_property_this(getThis(), SL("_activeRenderPath"), path TSRMLS_CC); } if (Z_TYPE_P(eventsManager) == IS_OBJECT) { ZEPHIR_INIT_VAR(_1$$4); ZVAL_STRING(_1$$4, "view:beforeRender", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_0$$4, eventsManager, "fire", NULL, 0, _1$$4, this_ptr); zephir_check_temp_parameter(_1$$4); zephir_check_call_status(); if (ZEPHIR_IS_FALSE_IDENTICAL(_0$$4)) { RETURN_MM_NULL(); } } notExists = 1; mustClean = 1; _2 = zephir_fetch_nproperty_this(this_ptr, SL("_viewsDir"), PH_NOISY_CC); ZEPHIR_INIT_VAR(viewsDirPath); ZEPHIR_CONCAT_VV(viewsDirPath, _2, path); ZEPHIR_CALL_METHOD(&engines, this_ptr, "_loadtemplateengines", NULL, 0); zephir_check_call_status(); zephir_is_iterable(engines, &_4, &_3, 0, 0, "phalcon/mvc/view/simple.zep", 282); for ( ; zend_hash_get_current_data_ex(_4, (void**) &_5, &_3) == SUCCESS ; zend_hash_move_forward_ex(_4, &_3) ) { ZEPHIR_GET_HMKEY(extension, _4, _3); ZEPHIR_GET_HVALUE(engine, _5); ZEPHIR_INIT_LNVAR(_6$$6); ZEPHIR_CONCAT_VV(_6$$6, viewsDirPath, extension); if ((zephir_file_exists(_6$$6 TSRMLS_CC) == SUCCESS)) { ZEPHIR_INIT_NVAR(viewEnginePath); ZEPHIR_CONCAT_VV(viewEnginePath, viewsDirPath, extension); } else { _7$$8 = zephir_is_true(extension); if (_7$$8) { ZEPHIR_SINIT_NVAR(_8$$8); ZVAL_LONG(&_8$$8, -zephir_fast_strlen_ev(extension)); ZEPHIR_INIT_NVAR(_9$$8); zephir_substr(_9$$8, viewsDirPath, zephir_get_intval(&_8$$8), 0, ZEPHIR_SUBSTR_NO_LENGTH); _7$$8 = ZEPHIR_IS_EQUAL(_9$$8, extension); } _10$$8 = _7$$8; if (_10$$8) { _10$$8 = (zephir_file_exists(viewsDirPath TSRMLS_CC) == SUCCESS); } if (_10$$8) { ZEPHIR_CPY_WRT(viewEnginePath, viewsDirPath); } else { ZEPHIR_INIT_NVAR(viewEnginePath); ZVAL_STRING(viewEnginePath, "", 1); } } if (zephir_is_true(viewEnginePath)) { if (Z_TYPE_P(eventsManager) == IS_OBJECT) { ZEPHIR_INIT_NVAR(_12$$12); ZVAL_STRING(_12$$12, "view:beforeRenderView", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_11$$12, eventsManager, "fire", &_13, 0, _12$$12, this_ptr, viewEnginePath); zephir_check_temp_parameter(_12$$12); zephir_check_call_status(); if (ZEPHIR_IS_FALSE_IDENTICAL(_11$$12)) { continue; } } ZEPHIR_INIT_NVAR(_14$$11); if (mustClean) { ZVAL_BOOL(_14$$11, 1); } else { ZVAL_BOOL(_14$$11, 0); } ZEPHIR_CALL_METHOD(NULL, engine, "render", NULL, 0, viewEnginePath, params, _14$$11); zephir_check_call_status(); notExists = 0; if (Z_TYPE_P(eventsManager) == IS_OBJECT) { ZEPHIR_INIT_NVAR(_15$$14); ZVAL_STRING(_15$$14, "view:afterRenderView", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, eventsManager, "fire", &_16, 0, _15$$14, this_ptr); zephir_check_temp_parameter(_15$$14); zephir_check_call_status(); } break; } } if (notExists == 1) { ZEPHIR_INIT_VAR(_17$$15); object_init_ex(_17$$15, phalcon_mvc_view_exception_ce); ZEPHIR_INIT_VAR(_18$$15); ZEPHIR_CONCAT_SVS(_18$$15, "View '", viewsDirPath, "' was not found in the views directory"); ZEPHIR_CALL_METHOD(NULL, _17$$15, "__construct", NULL, 9, _18$$15); zephir_check_call_status(); zephir_throw_exception_debug(_17$$15, "phalcon/mvc/view/simple.zep", 283 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } if (Z_TYPE_P(eventsManager) == IS_OBJECT) { ZEPHIR_INIT_VAR(_19$$16); ZVAL_STRING(_19$$16, "view:afterRender", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, eventsManager, "fire", NULL, 0, _19$$16, this_ptr); zephir_check_temp_parameter(_19$$16); zephir_check_call_status(); } ZEPHIR_MM_RESTORE(); }
void zend_update_property_bool(zend_class_entry *scope, zval *object, char *name, int name_length, long value TSRMLS_DC) { zval *tmp = ecalloc(1, sizeof(zval)); ZVAL_BOOL(tmp, value); zend_update_property(scope, object, name, name_length, tmp TSRMLS_CC); }
PHP_COM_DOTNET_API int php_com_zval_from_variant(zval *z, VARIANT *v, int codepage TSRMLS_DC) { OLECHAR *olestring = NULL; int ret = SUCCESS; switch (V_VT(v)) { case VT_EMPTY: case VT_NULL: case VT_VOID: ZVAL_NULL(z); break; case VT_UI1: ZVAL_LONG(z, (long)V_UI1(v)); break; case VT_I1: ZVAL_LONG(z, (long)V_I1(v)); break; case VT_UI2: ZVAL_LONG(z, (long)V_UI2(v)); break; case VT_I2: ZVAL_LONG(z, (long)V_I2(v)); break; case VT_UI4: /* TODO: promote to double if large? */ ZVAL_LONG(z, (long)V_UI4(v)); break; case VT_I4: ZVAL_LONG(z, (long)V_I4(v)); break; case VT_INT: ZVAL_LONG(z, V_INT(v)); break; case VT_UINT: /* TODO: promote to double if large? */ ZVAL_LONG(z, (long)V_UINT(v)); break; case VT_R4: ZVAL_DOUBLE(z, (double)V_R4(v)); break; case VT_R8: ZVAL_DOUBLE(z, V_R8(v)); break; case VT_BOOL: ZVAL_BOOL(z, V_BOOL(v) ? 1 : 0); break; case VT_BSTR: olestring = V_BSTR(v); if (olestring) { Z_TYPE_P(z) = IS_STRING; Z_STRVAL_P(z) = php_com_olestring_to_string(olestring, &Z_STRLEN_P(z), codepage TSRMLS_CC); olestring = NULL; } break; case VT_UNKNOWN: if (V_UNKNOWN(v) != NULL) { IDispatch *disp; if (SUCCEEDED(IUnknown_QueryInterface(V_UNKNOWN(v), &IID_IDispatch, &disp))) { php_com_wrap_dispatch(z, disp, codepage TSRMLS_CC); IDispatch_Release(disp); } else { ret = FAILURE; } } break; case VT_DISPATCH: if (V_DISPATCH(v) != NULL) { php_com_wrap_dispatch(z, V_DISPATCH(v), codepage TSRMLS_CC); } break; case VT_VARIANT: /* points to another variant */ return php_com_zval_from_variant(z, V_VARIANTREF(v), codepage TSRMLS_CC); default: php_com_wrap_variant(z, v, codepage TSRMLS_CC); } if (olestring) { efree(olestring); } if (ret == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "variant->zval: conversion from 0x%x ret=%d", V_VT(v), ret); } return ret; }
/** * Stores cached content into the APC backend and stops the frontend * * @param string $keyName * @param string $content * @param long $lifetime * @param boolean $stopBuffer */ PHP_METHOD(Phalcon_Cache_Backend_Apc, save) { zval *key_name = NULL, *content = NULL, *lifetime = NULL, *stop_buffer = NULL; zval *last_key = NULL, *prefix, *frontend, *cached_content = NULL; zval *prepared_content, *ttl = NULL, *is_buffering; PHALCON_MM_GROW(); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|zzzz", &key_name, &content, &lifetime, &stop_buffer) == FAILURE) { RETURN_MM_NULL(); } if (!key_name) { PHALCON_INIT_VAR(key_name); } if (!content) { PHALCON_INIT_VAR(content); } if (!lifetime) { PHALCON_INIT_VAR(lifetime); } if (!stop_buffer) { PHALCON_INIT_VAR(stop_buffer); ZVAL_BOOL(stop_buffer, 1); } if (Z_TYPE_P(key_name) == IS_NULL) { PHALCON_OBS_VAR(last_key); phalcon_read_property_this(&last_key, this_ptr, SL("_lastKey"), PH_NOISY_CC); } else { PHALCON_OBS_VAR(prefix); phalcon_read_property_this(&prefix, this_ptr, SL("_prefix"), PH_NOISY_CC); PHALCON_INIT_NVAR(last_key); PHALCON_CONCAT_SVV(last_key, "_PHCA", prefix, key_name); } if (!zend_is_true(last_key)) { PHALCON_THROW_EXCEPTION_STR(phalcon_cache_exception_ce, "The cache must be started first"); return; } PHALCON_OBS_VAR(frontend); phalcon_read_property_this(&frontend, this_ptr, SL("_frontend"), PH_NOISY_CC); if (Z_TYPE_P(content) == IS_NULL) { PHALCON_INIT_VAR(cached_content); PHALCON_CALL_METHOD(cached_content, frontend, "getcontent"); } else { PHALCON_CPY_WRT(cached_content, content); } PHALCON_INIT_VAR(prepared_content); PHALCON_CALL_METHOD_PARAMS_1(prepared_content, frontend, "beforestore", cached_content); if (Z_TYPE_P(lifetime) == IS_NULL) { PHALCON_INIT_VAR(ttl); PHALCON_CALL_METHOD(ttl, frontend, "getlifetime"); } else { PHALCON_CPY_WRT(ttl, lifetime); } PHALCON_CALL_FUNC_PARAMS_3_NORETURN("apc_store", last_key, prepared_content, ttl); PHALCON_INIT_VAR(is_buffering); PHALCON_CALL_METHOD(is_buffering, frontend, "isbuffering"); if (PHALCON_IS_TRUE(stop_buffer)) { PHALCON_CALL_METHOD_NORETURN(frontend, "stop"); } if (PHALCON_IS_TRUE(is_buffering)) { zend_print_zval(cached_content, 0); } phalcon_update_property_bool(this_ptr, SL("_started"), 0 TSRMLS_CC); PHALCON_MM_RESTORE(); }