/** * Internal validations, if it returns true, then skip the current validator */ PHP_METHOD(Phalcon_Validation, preChecking) { HashTable *_1$$3; HashPosition _0$$3; zephir_fcall_cache_entry *_7 = NULL; int ZEPHIR_LAST_CALL_STATUS; zval *field, *validator, *singleField = NULL, **_2$$3, *_3$$4 = NULL, *_4$$4 = NULL, *_5$$4 = NULL, *_6$$5 = NULL, *_8$$7 = NULL, *_9$$7, *_10$$7, *_11$$8 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &field, &validator); if (Z_TYPE_P(field) == IS_ARRAY) { zephir_is_iterable(field, &_1$$3, &_0$$3, 0, 0, "phalcon/validation.zep", 576); for ( ; zephir_hash_get_current_data_ex(_1$$3, (void**) &_2$$3, &_0$$3) == SUCCESS ; zephir_hash_move_forward_ex(_1$$3, &_0$$3) ) { ZEPHIR_GET_HVALUE(singleField, _2$$3); ZEPHIR_INIT_NVAR(_4$$4); ZVAL_STRING(_4$$4, "allowEmpty", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_5$$4); ZVAL_BOOL(_5$$4, 0); ZEPHIR_CALL_METHOD(&_3$$4, validator, "getoption", NULL, 0, _4$$4, _5$$4); zephir_check_temp_parameter(_4$$4); zephir_check_call_status(); if (zephir_is_true(_3$$4)) { if ((zephir_method_exists_ex(validator, SS("isallowempty") TSRMLS_CC) == SUCCESS)) { ZEPHIR_RETURN_CALL_METHOD(validator, "isallowempty", NULL, 0, this_ptr, singleField); zephir_check_call_status(); RETURN_MM(); } ZEPHIR_CALL_METHOD(&_6$$5, this_ptr, "getvalue", &_7, 0, singleField); zephir_check_call_status(); RETURN_MM_BOOL(ZEPHIR_IS_EMPTY(_6$$5)); } } } else { ZEPHIR_INIT_VAR(_9$$7); ZVAL_STRING(_9$$7, "allowEmpty", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_VAR(_10$$7); ZVAL_BOOL(_10$$7, 0); ZEPHIR_CALL_METHOD(&_8$$7, validator, "getoption", NULL, 0, _9$$7, _10$$7); zephir_check_temp_parameter(_9$$7); zephir_check_call_status(); if (zephir_is_true(_8$$7)) { if ((zephir_method_exists_ex(validator, SS("isallowempty") TSRMLS_CC) == SUCCESS)) { ZEPHIR_RETURN_CALL_METHOD(validator, "isallowempty", NULL, 0, this_ptr, field); zephir_check_call_status(); RETURN_MM(); } ZEPHIR_CALL_METHOD(&_11$$8, this_ptr, "getvalue", &_7, 0, field); zephir_check_call_status(); RETURN_MM_BOOL(ZEPHIR_IS_EMPTY(_11$$8)); } } RETURN_MM_BOOL(0); }
/** * Phalcon\Validation constructor */ PHP_METHOD(Phalcon_Validation, __construct) { int ZEPHIR_LAST_CALL_STATUS; zval *validators_param = NULL; zval *validators = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 1, &validators_param); if (!validators_param) { ZEPHIR_INIT_VAR(validators); array_init(validators); } else { zephir_get_arrval(validators, validators_param); } if (1 == 1) { zephir_update_property_this(this_ptr, SL("_validators"), validators TSRMLS_CC); } ZEPHIR_CALL_METHOD(NULL, this_ptr, "setdefaultmessages", NULL, 0); zephir_check_call_status(); if ((zephir_method_exists_ex(this_ptr, SS("initialize") TSRMLS_CC) == SUCCESS)) { ZEPHIR_CALL_METHOD(NULL, this_ptr, "initialize", NULL, 0); zephir_check_call_status(); } ZEPHIR_MM_RESTORE(); }
/** * Initializes a model in the models manager */ PHP_METHOD(Phalcon_Mvc_Collection_Manager, initialize) { int ZEPHIR_LAST_CALL_STATUS; zval *model, *className, *initialized, *eventsManager, *_0; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &model); ZEPHIR_INIT_VAR(className); zephir_get_class(className, model, 0 TSRMLS_CC); ZEPHIR_OBS_VAR(initialized); zephir_read_property_this(&initialized, this_ptr, SL("_initialized"), PH_NOISY_CC); if (!(zephir_array_isset(initialized, className))) { if ((zephir_method_exists_ex(model, SS("initialize") TSRMLS_CC) == SUCCESS)) { ZEPHIR_CALL_METHOD(NULL, model, "initialize", NULL, 0); zephir_check_call_status(); } 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(_0); ZVAL_STRING(_0, "collectionManager:afterInitialize", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, eventsManager, "fire", NULL, 0, _0, model); zephir_check_temp_parameter(_0); zephir_check_call_status(); } zephir_update_property_array(this_ptr, SL("_initialized"), className, model TSRMLS_CC); zephir_update_property_this(this_ptr, SL("_lastInitialized"), model TSRMLS_CC); } ZEPHIR_MM_RESTORE(); }
/** * Phalcon\Forms\Form constructor * * @param object entity * @param array userOptions */ PHP_METHOD(Phalcon_Forms_Form, __construct) { zend_long ZEPHIR_LAST_CALL_STATUS; zval *entity = NULL, *userOptions = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 2, &entity, &userOptions); if (!entity) { entity = ZEPHIR_GLOBAL(global_null); } if (!userOptions) { userOptions = ZEPHIR_GLOBAL(global_null); } if (Z_TYPE_P(entity) != IS_NULL) { if (Z_TYPE_P(entity) != IS_OBJECT) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_forms_exception_ce, "The base entity is not valid", "phalcon/forms/form.zep", 66); return; } zephir_update_property_this(getThis(), SL("_entity"), entity TSRMLS_CC); } if (Z_TYPE_P(userOptions) == IS_ARRAY) { zephir_update_property_this(getThis(), SL("_options"), userOptions TSRMLS_CC); } if ((zephir_method_exists_ex(this_ptr, SS("initialize") TSRMLS_CC) == SUCCESS)) { ZEPHIR_CALL_METHOD(NULL, this_ptr, "initialize", NULL, 0, entity, userOptions); zephir_check_call_status(); } ZEPHIR_MM_RESTORE(); }
/** * Converts recursively the object to an array * *<code> * print_r($config->toArray()); *</code> */ PHP_METHOD(Phalcon_Config, toArray) { HashTable *_2; HashPosition _1; int ZEPHIR_LAST_CALL_STATUS; zval *key = NULL, *value = NULL, *arrayConfig, *_0 = NULL, **_3, *_4 = NULL; ZEPHIR_MM_GROW(); ZEPHIR_INIT_VAR(arrayConfig); array_init(arrayConfig); ZEPHIR_CALL_FUNCTION(&_0, "get_object_vars", NULL, 23, this_ptr); zephir_check_call_status(); zephir_is_iterable(_0, &_2, &_1, 0, 0, "phalcon/config.zep", 180); for ( ; zephir_hash_get_current_data_ex(_2, (void**) &_3, &_1) == SUCCESS ; zephir_hash_move_forward_ex(_2, &_1) ) { ZEPHIR_GET_HMKEY(key, _2, _1); ZEPHIR_GET_HVALUE(value, _3); if (Z_TYPE_P(value) == IS_OBJECT) { if ((zephir_method_exists_ex(value, SS("toarray") TSRMLS_CC) == SUCCESS)) { ZEPHIR_CALL_METHOD(&_4, value, "toarray", NULL, 0); zephir_check_call_status(); zephir_array_update_zval(&arrayConfig, key, &_4, PH_COPY | PH_SEPARATE); } else { zephir_array_update_zval(&arrayConfig, key, &value, PH_COPY | PH_SEPARATE); } } else { zephir_array_update_zval(&arrayConfig, key, &value, PH_COPY | PH_SEPARATE); } } RETURN_CCTOR(arrayConfig); }
/** * Stops the active profile */ PHP_METHOD(Phalcon_Db_Profiler, stopProfile) { zval *finalTime = NULL, *initialTime = NULL, *activeProfile = NULL, *_0, *_1, *_2; zend_long ZEPHIR_LAST_CALL_STATUS; ZEPHIR_MM_GROW(); ZEPHIR_INIT_VAR(finalTime); zephir_microtime(finalTime, ZEPHIR_GLOBAL(global_true) TSRMLS_CC); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_activeProfile"), PH_NOISY_CC); ZEPHIR_CPY_WRT(activeProfile, _0); ZEPHIR_CALL_METHOD(NULL, activeProfile, "setfinaltime", NULL, 0, finalTime); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&initialTime, activeProfile, "getinitialtime", NULL, 0); zephir_check_call_status(); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_totalSeconds"), PH_NOISY_CC); ZEPHIR_INIT_VAR(_1); zephir_sub_function(_1, finalTime, initialTime); ZEPHIR_INIT_VAR(_2); zephir_add_function(_2, _0, _1); zephir_update_property_this(getThis(), SL("_totalSeconds"), _2 TSRMLS_CC); zephir_update_property_array_append(this_ptr, SL("_allProfiles"), activeProfile TSRMLS_CC); if ((zephir_method_exists_ex(this_ptr, SS("afterendprofile") TSRMLS_CC) == SUCCESS)) { ZEPHIR_CALL_METHOD(NULL, this_ptr, "afterendprofile", NULL, 0, activeProfile); zephir_check_call_status(); } RETURN_THIS(); }
/** * Phalcon\Mvc\Router\Group constructor */ PHP_METHOD(Phalcon_Mvc_Router_Group, __construct) { zend_bool _0; zend_long ZEPHIR_LAST_CALL_STATUS; zval *paths = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 1, &paths); if (!paths) { paths = ZEPHIR_GLOBAL(global_null); } _0 = Z_TYPE_P(paths) == IS_ARRAY; if (!(_0)) { _0 = Z_TYPE_P(paths) == IS_STRING; } if (_0) { zephir_update_property_this(getThis(), SL("_paths"), paths TSRMLS_CC); } if ((zephir_method_exists_ex(this_ptr, SS("initialize") TSRMLS_CC) == SUCCESS)) { ZEPHIR_CALL_METHOD(NULL, this_ptr, "initialize", NULL, 0, paths); zephir_check_call_status(); } ZEPHIR_MM_RESTORE(); }
/** * Produces an string representation of a variable */ PHP_METHOD(Phalcon_Debug, _getVarDump) { zephir_fcall_cache_entry *_3 = NULL; int ZEPHIR_LAST_CALL_STATUS; zephir_nts_static zephir_fcall_cache_entry *_1 = NULL; zval *variable, *className, *dumpedObject = NULL, *dump, *_0 = NULL, *_2 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &variable); ZEPHIR_CALL_FUNCTION(&_0, "is_scalar", &_1, variable); zephir_check_call_status(); if (zephir_is_true(_0)) { if (Z_TYPE_P(variable) == IS_BOOL) { if (zephir_is_true(variable)) { RETURN_MM_STRING("true", 1); } else { RETURN_MM_STRING("false", 1); } } if (Z_TYPE_P(variable) == IS_STRING) { ZEPHIR_RETURN_CALL_METHOD(this_ptr, "_escapestring", NULL, variable); zephir_check_call_status(); RETURN_MM(); } RETVAL_ZVAL(variable, 1, 0); RETURN_MM(); } if (Z_TYPE_P(variable) == IS_OBJECT) { ZEPHIR_INIT_VAR(className); zephir_get_class(className, variable, 0 TSRMLS_CC); ZEPHIR_INIT_VAR(dump); if ((zephir_method_exists_ex(variable, SS("dump") TSRMLS_CC) == SUCCESS)) { ZEPHIR_CALL_METHOD(&dumpedObject, variable, "dump", NULL); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&_2, this_ptr, "_getarraydump", &_3, dumpedObject); zephir_check_call_status(); ZEPHIR_CONCAT_SVSVS(dump, "Object(", className, ": ", _2, ")"); } else { ZEPHIR_CONCAT_SVS(dump, "Object(", className, ")</span>"); } RETURN_CCTOR(dump); } if (Z_TYPE_P(variable) == IS_ARRAY) { ZEPHIR_CALL_METHOD(&_2, this_ptr, "_getarraydump", &_3, variable); zephir_check_call_status(); ZEPHIR_CONCAT_SVS(return_value, "Array(", _2, ")"); RETURN_MM(); } if (Z_TYPE_P(variable) == IS_NULL) { RETURN_MM_STRING("null", 1); } zephir_gettype(return_value, variable TSRMLS_CC); RETURN_MM(); }
int zephir_method_exists(const zval *object, const zval *method_name) { if (Z_TYPE_P(method_name) != IS_STRING) { zend_error(E_WARNING, "method_exists expected a string"); return 0; } char *lcname = zend_str_tolower_dup(Z_STRVAL_P(method_name), Z_STRLEN_P(method_name)); int res = zephir_method_exists_ex(object, lcname, Z_STRLEN_P(method_name)); efree(lcname); return res; }
/** * Phalcon\Mvc\Controller constructor */ PHP_METHOD(Phalcon_Mvc_Controller, __construct) { int ZEPHIR_LAST_CALL_STATUS; ZEPHIR_MM_GROW(); if ((zephir_method_exists_ex(this_ptr, SS("onconstruct") TSRMLS_CC) == SUCCESS)) { ZEPHIR_CALL_METHOD(NULL, this_ptr, "onconstruct", NULL, 0); zephir_check_call_status(); } ZEPHIR_MM_RESTORE(); }
/** * Filters the message group by field name * * @param string fieldName * @return array */ PHP_METHOD(Phalcon_Validation_Message_Group, filter) { int ZEPHIR_LAST_CALL_STATUS; HashTable *_1; HashPosition _0; zval *fieldName_param = NULL, *filtered, *messages, *message = NULL, **_2, *_3 = NULL; zval *fieldName = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &fieldName_param); if (unlikely(Z_TYPE_P(fieldName_param) != IS_STRING && Z_TYPE_P(fieldName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'fieldName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(fieldName_param) == IS_STRING)) { zephir_get_strval(fieldName, fieldName_param); } else { ZEPHIR_INIT_VAR(fieldName); ZVAL_EMPTY_STRING(fieldName); } ZEPHIR_INIT_VAR(filtered); array_init(filtered); ZEPHIR_OBS_VAR(messages); zephir_read_property_this(&messages, this_ptr, SL("_messages"), PH_NOISY_CC); if (Z_TYPE_P(messages) == IS_ARRAY) { zephir_is_iterable(messages, &_1, &_0, 0, 0, "phalcon/validation/message/group.zep", 201); for ( ; zephir_hash_get_current_data_ex(_1, (void**) &_2, &_0) == SUCCESS ; zephir_hash_move_forward_ex(_1, &_0) ) { ZEPHIR_GET_HVALUE(message, _2); if ((zephir_method_exists_ex(message, SS("getfield") TSRMLS_CC) == SUCCESS)) { ZEPHIR_CALL_METHOD(&_3, message, "getfield", NULL, 0); zephir_check_call_status(); if (ZEPHIR_IS_EQUAL(fieldName, _3)) { zephir_array_append(&filtered, message, PH_SEPARATE, "phalcon/validation/message/group.zep", 196); } } } } RETURN_CCTOR(filtered); }
/** * Starts the profile of a SQL sentence * * @param string sqlStatement * @return Phalcon\Db\Profiler */ PHP_METHOD(Phalcon_Db_Profiler, startProfile) { zephir_nts_static zephir_fcall_cache_entry *_0 = NULL, *_1 = NULL, *_2 = NULL, *_4 = NULL; int ZEPHIR_LAST_CALL_STATUS; zval *sqlStatement, *sqlVariables = NULL, *sqlBindTypes = NULL, *activeProfile, *_3; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 2, &sqlStatement, &sqlVariables, &sqlBindTypes); if (!sqlVariables) { sqlVariables = ZEPHIR_GLOBAL(global_null); } if (!sqlBindTypes) { sqlBindTypes = ZEPHIR_GLOBAL(global_null); } ZEPHIR_INIT_VAR(activeProfile); object_init_ex(activeProfile, phalcon_db_profiler_item_ce); if (zephir_has_constructor(activeProfile TSRMLS_CC)) { ZEPHIR_CALL_METHOD(NULL, activeProfile, "__construct", NULL); zephir_check_call_status(); } ZEPHIR_CALL_METHOD(NULL, activeProfile, "setsqlstatement", &_0, sqlStatement); zephir_check_call_status(); if (Z_TYPE_P(sqlVariables) == IS_ARRAY) { ZEPHIR_CALL_METHOD(NULL, activeProfile, "setsqlvariables", &_1, sqlVariables); zephir_check_call_status(); } if (Z_TYPE_P(sqlBindTypes) == IS_ARRAY) { ZEPHIR_CALL_METHOD(NULL, activeProfile, "setsqlbindtypes", &_2, sqlBindTypes); zephir_check_call_status(); } ZEPHIR_INIT_VAR(_3); zephir_microtime(_3, ZEPHIR_GLOBAL(global_true) TSRMLS_CC); ZEPHIR_CALL_METHOD(NULL, activeProfile, "setinitialtime", &_4, _3); zephir_check_call_status(); if ((zephir_method_exists_ex(this_ptr, SS("beforestartprofile") TSRMLS_CC) == SUCCESS)) { ZEPHIR_CALL_METHOD(NULL, this_ptr, "beforestartprofile", NULL, activeProfile); zephir_check_call_status(); } zephir_update_property_this(this_ptr, SL("_activeProfile"), activeProfile TSRMLS_CC); RETURN_THIS(); }
/** * Read the model's column map, this can't be inferred */ PHP_METHOD(Phalcon_Mvc_Model_MetaData_Strategy_Introspection, getColumnMaps) { HashTable *_1$$3; HashPosition _0$$3; zend_long ZEPHIR_LAST_CALL_STATUS; zval *model, *dependencyInjector, *orderedColumnMap = NULL, *userColumnMap = NULL, *reversedColumnMap = NULL, *name = NULL, *userName = NULL, **_2$$3; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &model, &dependencyInjector); ZEPHIR_INIT_VAR(orderedColumnMap); ZVAL_NULL(orderedColumnMap); ZEPHIR_INIT_VAR(reversedColumnMap); ZVAL_NULL(reversedColumnMap); if ((zephir_method_exists_ex(model, SS("columnmap") TSRMLS_CC) == SUCCESS)) { ZEPHIR_CALL_METHOD(&userColumnMap, model, "columnmap", NULL, 0); zephir_check_call_status(); if (Z_TYPE_P(userColumnMap) != IS_ARRAY) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "columnMap() not returned an array", "phalcon/mvc/model/metadata/strategy/introspection.zep", 198); return; } ZEPHIR_INIT_NVAR(reversedColumnMap); array_init(reversedColumnMap); ZEPHIR_CPY_WRT(orderedColumnMap, userColumnMap); zephir_is_iterable(userColumnMap, &_1$$3, &_0$$3, 0, 0, "phalcon/mvc/model/metadata/strategy/introspection.zep", 205); for ( ; zend_hash_get_current_data_ex(_1$$3, (void**) &_2$$3, &_0$$3) == SUCCESS ; zend_hash_move_forward_ex(_1$$3, &_0$$3) ) { ZEPHIR_GET_HMKEY(name, _1$$3, _0$$3); ZEPHIR_GET_HVALUE(userName, _2$$3); zephir_array_update_zval(&reversedColumnMap, userName, &name, PH_COPY | PH_SEPARATE); } } zephir_create_array(return_value, 2, 0 TSRMLS_CC); zephir_array_fast_append(return_value, orderedColumnMap); zephir_array_fast_append(return_value, reversedColumnMap); RETURN_MM(); }
/** * Phalcon\Validation constructor */ PHP_METHOD(Phalcon_Validation, __construct) { int ZEPHIR_LAST_CALL_STATUS; zephir_fcall_cache_entry *_2 = NULL; zval *validators_param = NULL, *_0$$3 = NULL, *_1$$3 = NULL, *_3$$3 = NULL, *_4$$3 = NULL; zval *validators = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 1, &validators_param); if (!validators_param) { ZEPHIR_INIT_VAR(validators); array_init(validators); } else { zephir_get_arrval(validators, validators_param); } if (zephir_fast_count_int(validators TSRMLS_CC)) { ZEPHIR_INIT_VAR(_0$$3); ZEPHIR_INIT_NVAR(_0$$3); zephir_create_closure_ex(_0$$3, NULL, phalcon_0__closure_ce, SS("__invoke") TSRMLS_CC); ZEPHIR_CALL_FUNCTION(&_1$$3, "array_filter", &_2, 460, validators, _0$$3); zephir_check_call_status(); zephir_update_property_this(this_ptr, SL("_validators"), _1$$3 TSRMLS_CC); ZEPHIR_INIT_VAR(_3$$3); ZEPHIR_INIT_NVAR(_3$$3); zephir_create_closure_ex(_3$$3, NULL, phalcon_1__closure_ce, SS("__invoke") TSRMLS_CC); ZEPHIR_CALL_FUNCTION(&_4$$3, "array_filter", &_2, 460, validators, _3$$3); zephir_check_call_status(); zephir_update_property_this(this_ptr, SL("_combinedFieldsValidators"), _4$$3 TSRMLS_CC); } ZEPHIR_CALL_METHOD(NULL, this_ptr, "setdefaultmessages", NULL, 0); zephir_check_call_status(); if ((zephir_method_exists_ex(this_ptr, SS("initialize") TSRMLS_CC) == SUCCESS)) { ZEPHIR_CALL_METHOD(NULL, this_ptr, "initialize", NULL, 0); zephir_check_call_status(); } ZEPHIR_MM_RESTORE(); }
/** * Initialize the metadata for certain table */ PHP_METHOD(Phalcon_Mvc_Model_MetaData, _initialize) { zephir_fcall_cache_entry *_2 = NULL; int ZEPHIR_LAST_CALL_STATUS; zval *model, *key, *table, *schema, *strategy = NULL, *className = NULL, *metaData = NULL, *data = NULL, *modelMetadata = NULL, *modelColumnMap = NULL, *dependencyInjector = NULL, *keyName = NULL, *prefixKey = NULL, *_3, *_0$$8, *_1$$8; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 4, 0, &model, &key, &table, &schema); ZEPHIR_INIT_VAR(strategy); ZVAL_NULL(strategy); ZEPHIR_INIT_VAR(className); zephir_get_class(className, model, 0 TSRMLS_CC); if (Z_TYPE_P(key) != IS_NULL) { ZEPHIR_OBS_VAR(metaData); zephir_read_property_this(&metaData, this_ptr, SL("_metaData"), PH_NOISY_CC); if (!(zephir_array_isset(metaData, key))) { ZEPHIR_INIT_VAR(prefixKey); ZEPHIR_CONCAT_SV(prefixKey, "meta-", key); ZEPHIR_CALL_METHOD(&data, this_ptr, "read", NULL, 0, prefixKey); zephir_check_call_status(); if (Z_TYPE_P(data) != IS_NULL) { zephir_update_property_array(this_ptr, SL("_metaData"), key, data TSRMLS_CC); } else { if ((zephir_method_exists_ex(model, SS("metadata") TSRMLS_CC) == SUCCESS)) { ZEPHIR_CALL_METHOD(&modelMetadata, model, "metadata", NULL, 0); zephir_check_call_status(); if (Z_TYPE_P(modelMetadata) != IS_ARRAY) { ZEPHIR_INIT_VAR(_0$$8); object_init_ex(_0$$8, phalcon_mvc_model_exception_ce); ZEPHIR_INIT_VAR(_1$$8); ZEPHIR_CONCAT_SV(_1$$8, "Invalid meta-data for model ", className); ZEPHIR_CALL_METHOD(NULL, _0$$8, "__construct", NULL, 9, _1$$8); zephir_check_call_status(); zephir_throw_exception_debug(_0$$8, "phalcon/mvc/model/metadata.zep", 122 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } } else { ZEPHIR_OBS_VAR(dependencyInjector); zephir_read_property_this(&dependencyInjector, this_ptr, SL("_dependencyInjector"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(&strategy, this_ptr, "getstrategy", &_2, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&modelMetadata, strategy, "getmetadata", NULL, 0, model, dependencyInjector); zephir_check_call_status(); } zephir_update_property_array(this_ptr, SL("_metaData"), key, modelMetadata TSRMLS_CC); ZEPHIR_CALL_METHOD(NULL, this_ptr, "write", NULL, 0, prefixKey, modelMetadata); zephir_check_call_status(); } } } if (!(ZEPHIR_GLOBAL(orm).column_renaming)) { RETURN_MM_NULL(); } ZEPHIR_INIT_VAR(keyName); zephir_fast_strtolower(keyName, className); _3 = zephir_fetch_nproperty_this(this_ptr, SL("_columnMap"), PH_NOISY_CC); if (zephir_array_isset(_3, keyName)) { RETURN_MM_NULL(); } ZEPHIR_INIT_NVAR(prefixKey); ZEPHIR_CONCAT_SV(prefixKey, "map-", keyName); ZEPHIR_CALL_METHOD(&data, this_ptr, "read", NULL, 0, prefixKey); zephir_check_call_status(); if (Z_TYPE_P(data) != IS_NULL) { zephir_update_property_array(this_ptr, SL("_columnMap"), keyName, data TSRMLS_CC); RETURN_MM_NULL(); } if (Z_TYPE_P(strategy) != IS_OBJECT) { ZEPHIR_OBS_NVAR(dependencyInjector); zephir_read_property_this(&dependencyInjector, this_ptr, SL("_dependencyInjector"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(&strategy, this_ptr, "getstrategy", &_2, 0); zephir_check_call_status(); } ZEPHIR_CALL_METHOD(&modelColumnMap, strategy, "getcolumnmaps", NULL, 0, model, dependencyInjector); zephir_check_call_status(); zephir_update_property_array(this_ptr, SL("_columnMap"), keyName, modelColumnMap TSRMLS_CC); ZEPHIR_CALL_METHOD(NULL, this_ptr, "write", NULL, 0, prefixKey, modelColumnMap); zephir_check_call_status(); ZEPHIR_MM_RESTORE(); }
/** * Dispatches a handle action taking into account the routing parameters * * @return object */ PHP_METHOD(Phalcon_Dispatcher, dispatch) { zval *_30$$6 = NULL, *_50$$39 = NULL; zval *value = NULL, *handler = NULL, *dependencyInjector = NULL, *namespaceName = NULL, *handlerName = NULL, *actionName = NULL, *params = NULL, *eventsManager = NULL, *actionSuffix = NULL, *handlerClass = NULL, *status = NULL, *actionMethod = NULL, *e = NULL, *_0, *_1$$3, *_2$$3, *_3$$4 = NULL, *_4$$4, *_5$$7 = NULL, *_6$$7 = NULL, *_10$$8 = NULL, *_11$$8 = NULL, *_13$$8, *_14$$6 = NULL, *_16$$12 = NULL, *_17$$12 = NULL, *_19$$13, *_22$$16 = NULL, *_23$$16 = NULL, *_25$$17, *_26$$19 = NULL, *_27$$19 = NULL, *_29$$20, *_31$$23 = NULL, *_32$$23 = NULL, *_34$$23, *_35$$22 = NULL, *_36$$22 = NULL, *_38$$26, *_39$$28 = NULL, *_40$$28 = NULL, *_42$$28, *_43$$31 = NULL, *_44$$31, *_45$$36 = NULL, *_46$$36 = NULL, *_48$$36, *_49$$39 = NULL, *_51$$40 = NULL, *_53$$41, *_54$$44 = NULL, *_55$$44 = NULL, *_57$$44, *_59$$47 = NULL, *_60$$47, *_61$$50; zend_bool hasService = 0, wasFresh; zephir_fcall_cache_entry *_7 = NULL, *_8 = NULL, *_9 = NULL, *_12 = NULL, *_15 = NULL, *_18 = NULL, *_20 = NULL, *_21 = NULL, *_24 = NULL, *_28 = NULL, *_33 = NULL, *_37 = NULL, *_41 = NULL, *_47 = NULL, *_52 = NULL, *_56 = NULL, *_58 = NULL; int ZEPHIR_LAST_CALL_STATUS, numberDispatches = 0; ZEPHIR_MM_GROW(); wasFresh = 0; _0 = zephir_fetch_nproperty_this(this_ptr, SL("_dependencyInjector"), PH_NOISY_CC); ZEPHIR_CPY_WRT(dependencyInjector, _0); if (Z_TYPE_P(dependencyInjector) != IS_OBJECT) { ZEPHIR_INIT_VAR(_1$$3); ZVAL_STRING(_1$$3, "A dependency injection container is required to access related dispatching services", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_VAR(_2$$3); ZVAL_LONG(_2$$3, 0); ZEPHIR_CALL_METHOD(NULL, this_ptr, "_throwdispatchexception", NULL, 0, _1$$3, _2$$3); zephir_check_temp_parameter(_1$$3); zephir_check_call_status(); RETURN_MM_BOOL(0); } _0 = zephir_fetch_nproperty_this(this_ptr, SL("_eventsManager"), PH_NOISY_CC); ZEPHIR_CPY_WRT(eventsManager, _0); if (Z_TYPE_P(eventsManager) == IS_OBJECT) { ZEPHIR_INIT_VAR(_4$$4); ZVAL_STRING(_4$$4, "dispatch:beforeDispatchLoop", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_3$$4, eventsManager, "fire", NULL, 0, _4$$4, this_ptr); zephir_check_temp_parameter(_4$$4); zephir_check_call_status(); if (ZEPHIR_IS_FALSE_IDENTICAL(_3$$4)) { RETURN_MM_BOOL(0); } } ZEPHIR_INIT_VAR(value); ZVAL_NULL(value); ZEPHIR_INIT_VAR(handler); ZVAL_NULL(handler); numberDispatches = 0; ZEPHIR_OBS_VAR(actionSuffix); zephir_read_property_this(&actionSuffix, this_ptr, SL("_actionSuffix"), PH_NOISY_CC); if (0) { zephir_update_property_this(this_ptr, SL("_finished"), ZEPHIR_GLOBAL(global_true) TSRMLS_CC); } else { zephir_update_property_this(this_ptr, SL("_finished"), ZEPHIR_GLOBAL(global_false) TSRMLS_CC); } while (1) { _0 = zephir_fetch_nproperty_this(this_ptr, SL("_finished"), PH_NOISY_CC); if (!(!(zephir_is_true(_0)))) { break; } numberDispatches++; if (numberDispatches == 256) { ZEPHIR_INIT_NVAR(_5$$7); ZVAL_STRING(_5$$7, "Dispatcher has detected a cyclic routing causing stability problems", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_6$$7); ZVAL_LONG(_6$$7, 1); ZEPHIR_CALL_METHOD(NULL, this_ptr, "_throwdispatchexception", &_7, 0, _5$$7, _6$$7); zephir_check_temp_parameter(_5$$7); zephir_check_call_status(); break; } if (1) { zephir_update_property_this(this_ptr, SL("_finished"), ZEPHIR_GLOBAL(global_true) TSRMLS_CC); } else { zephir_update_property_this(this_ptr, SL("_finished"), ZEPHIR_GLOBAL(global_false) TSRMLS_CC); } ZEPHIR_CALL_METHOD(NULL, this_ptr, "_resolveemptyproperties", &_8, 0); zephir_check_call_status(); ZEPHIR_OBS_NVAR(namespaceName); zephir_read_property_this(&namespaceName, this_ptr, SL("_namespaceName"), PH_NOISY_CC); ZEPHIR_OBS_NVAR(handlerName); zephir_read_property_this(&handlerName, this_ptr, SL("_handlerName"), PH_NOISY_CC); ZEPHIR_OBS_NVAR(actionName); zephir_read_property_this(&actionName, this_ptr, SL("_actionName"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(&handlerClass, this_ptr, "gethandlerclass", &_9, 0); zephir_check_call_status(); if (Z_TYPE_P(eventsManager) == IS_OBJECT) { ZEPHIR_INIT_NVAR(_11$$8); ZVAL_STRING(_11$$8, "dispatch:beforeDispatch", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_10$$8, eventsManager, "fire", &_12, 0, _11$$8, this_ptr); zephir_check_temp_parameter(_11$$8); zephir_check_call_status(); if (ZEPHIR_IS_FALSE_IDENTICAL(_10$$8)) { continue; } _13$$8 = zephir_fetch_nproperty_this(this_ptr, SL("_finished"), PH_NOISY_CC); if (ZEPHIR_IS_FALSE_IDENTICAL(_13$$8)) { continue; } } ZEPHIR_CALL_METHOD(&_14$$6, dependencyInjector, "has", &_15, 0, handlerClass); zephir_check_call_status(); hasService = zephir_get_boolval(_14$$6); if (!(hasService)) { hasService = zephir_class_exists(handlerClass, 1 TSRMLS_CC); } if (!(hasService)) { ZEPHIR_INIT_LNVAR(_16$$12); ZEPHIR_CONCAT_VS(_16$$12, handlerClass, " handler class cannot be loaded"); ZEPHIR_INIT_NVAR(_17$$12); ZVAL_LONG(_17$$12, 2); ZEPHIR_CALL_METHOD(&status, this_ptr, "_throwdispatchexception", &_18, 0, _16$$12, _17$$12); zephir_check_call_status(); if (ZEPHIR_IS_FALSE_IDENTICAL(status)) { _19$$13 = zephir_fetch_nproperty_this(this_ptr, SL("_finished"), PH_NOISY_CC); if (ZEPHIR_IS_FALSE_IDENTICAL(_19$$13)) { continue; } } break; } ZEPHIR_CALL_METHOD(&handler, dependencyInjector, "getshared", &_20, 0, handlerClass); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&_14$$6, dependencyInjector, "wasfreshinstance", &_21, 0); zephir_check_call_status(); if (ZEPHIR_IS_TRUE_IDENTICAL(_14$$6)) { wasFresh = 1; } if (Z_TYPE_P(handler) != IS_OBJECT) { ZEPHIR_INIT_NVAR(_22$$16); ZVAL_STRING(_22$$16, "Invalid handler returned from the services container", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_23$$16); ZVAL_LONG(_23$$16, 3); ZEPHIR_CALL_METHOD(&status, this_ptr, "_throwdispatchexception", &_24, 0, _22$$16, _23$$16); zephir_check_temp_parameter(_22$$16); zephir_check_call_status(); if (ZEPHIR_IS_FALSE_IDENTICAL(status)) { _25$$17 = zephir_fetch_nproperty_this(this_ptr, SL("_finished"), PH_NOISY_CC); if (ZEPHIR_IS_FALSE_IDENTICAL(_25$$17)) { continue; } } break; } zephir_update_property_this(this_ptr, SL("_activeHandler"), handler TSRMLS_CC); ZEPHIR_OBS_NVAR(params); zephir_read_property_this(¶ms, this_ptr, SL("_params"), PH_NOISY_CC); if (Z_TYPE_P(params) != IS_ARRAY) { ZEPHIR_INIT_NVAR(_26$$19); ZVAL_STRING(_26$$19, "Action parameters must be an Array", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_27$$19); ZVAL_LONG(_27$$19, 4); ZEPHIR_CALL_METHOD(&status, this_ptr, "_throwdispatchexception", &_28, 0, _26$$19, _27$$19); zephir_check_temp_parameter(_26$$19); zephir_check_call_status(); if (ZEPHIR_IS_FALSE_IDENTICAL(status)) { _29$$20 = zephir_fetch_nproperty_this(this_ptr, SL("_finished"), PH_NOISY_CC); if (ZEPHIR_IS_FALSE_IDENTICAL(_29$$20)) { continue; } } break; } ZEPHIR_INIT_NVAR(actionMethod); ZEPHIR_CONCAT_VV(actionMethod, actionName, actionSuffix); ZEPHIR_INIT_NVAR(_30$$6); zephir_create_array(_30$$6, 2, 0 TSRMLS_CC); zephir_array_fast_append(_30$$6, handler); zephir_array_fast_append(_30$$6, actionMethod); if (!(zephir_is_callable(_30$$6 TSRMLS_CC))) { if (Z_TYPE_P(eventsManager) == IS_OBJECT) { ZEPHIR_INIT_NVAR(_32$$23); ZVAL_STRING(_32$$23, "dispatch:beforeNotFoundAction", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_31$$23, eventsManager, "fire", &_33, 0, _32$$23, this_ptr); zephir_check_temp_parameter(_32$$23); zephir_check_call_status(); if (ZEPHIR_IS_FALSE_IDENTICAL(_31$$23)) { continue; } _34$$23 = zephir_fetch_nproperty_this(this_ptr, SL("_finished"), PH_NOISY_CC); if (ZEPHIR_IS_FALSE_IDENTICAL(_34$$23)) { continue; } } ZEPHIR_INIT_LNVAR(_35$$22); ZEPHIR_CONCAT_SVSVS(_35$$22, "Action '", actionName, "' was not found on handler '", handlerName, "'"); ZEPHIR_INIT_NVAR(_36$$22); ZVAL_LONG(_36$$22, 5); ZEPHIR_CALL_METHOD(&status, this_ptr, "_throwdispatchexception", &_37, 0, _35$$22, _36$$22); zephir_check_call_status(); if (ZEPHIR_IS_FALSE_IDENTICAL(status)) { _38$$26 = zephir_fetch_nproperty_this(this_ptr, SL("_finished"), PH_NOISY_CC); if (ZEPHIR_IS_FALSE_IDENTICAL(_38$$26)) { continue; } } break; } if (Z_TYPE_P(eventsManager) == IS_OBJECT) { ZEPHIR_INIT_NVAR(_40$$28); ZVAL_STRING(_40$$28, "dispatch:beforeExecuteRoute", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_39$$28, eventsManager, "fire", &_41, 0, _40$$28, this_ptr); zephir_check_temp_parameter(_40$$28); zephir_check_call_status(); if (ZEPHIR_IS_FALSE_IDENTICAL(_39$$28)) { continue; } _42$$28 = zephir_fetch_nproperty_this(this_ptr, SL("_finished"), PH_NOISY_CC); if (ZEPHIR_IS_FALSE_IDENTICAL(_42$$28)) { continue; } } if ((zephir_method_exists_ex(handler, SS("beforeexecuteroute") TSRMLS_CC) == SUCCESS)) { ZEPHIR_CALL_METHOD(&_43$$31, handler, "beforeexecuteroute", NULL, 0, this_ptr); zephir_check_call_status(); if (ZEPHIR_IS_FALSE_IDENTICAL(_43$$31)) { continue; } _44$$31 = zephir_fetch_nproperty_this(this_ptr, SL("_finished"), PH_NOISY_CC); if (ZEPHIR_IS_FALSE_IDENTICAL(_44$$31)) { continue; } } if (wasFresh == 1) { if ((zephir_method_exists_ex(handler, SS("initialize") TSRMLS_CC) == SUCCESS)) { ZEPHIR_CALL_METHOD(NULL, handler, "initialize", NULL, 0); zephir_check_call_status(); } if (zephir_is_true(eventsManager)) { ZEPHIR_INIT_NVAR(_46$$36); ZVAL_STRING(_46$$36, "dispatch:afterInitialize", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_45$$36, eventsManager, "fire", &_47, 0, _46$$36, this_ptr); zephir_check_temp_parameter(_46$$36); zephir_check_call_status(); if (ZEPHIR_IS_FALSE_IDENTICAL(_45$$36)) { continue; } _48$$36 = zephir_fetch_nproperty_this(this_ptr, SL("_finished"), PH_NOISY_CC); if (ZEPHIR_IS_FALSE_IDENTICAL(_48$$36)) { continue; } } } zephir_update_property_this(this_ptr, SL("_lastHandler"), handler TSRMLS_CC); /* try_start_1: */ ZEPHIR_INIT_NVAR(_49$$39); ZEPHIR_INIT_NVAR(_50$$39); zephir_create_array(_50$$39, 2, 0 TSRMLS_CC); zephir_array_fast_append(_50$$39, handler); zephir_array_fast_append(_50$$39, actionMethod); ZEPHIR_CALL_USER_FUNC_ARRAY(_49$$39, _50$$39, params); zephir_check_call_status_or_jump(try_end_1); zephir_update_property_this(this_ptr, SL("_returnedValue"), _49$$39 TSRMLS_CC); try_end_1: if (EG(exception)) { ZEPHIR_CPY_WRT(e, EG(exception)); if (zephir_instance_of_ev(e, zend_exception_get_default(TSRMLS_C) TSRMLS_CC)) { zend_clear_exception(TSRMLS_C); zephir_update_property_this(this_ptr, SL("_lastHandler"), handler TSRMLS_CC); ZEPHIR_CALL_METHOD(&_51$$40, this_ptr, "_handleexception", &_52, 0, e); zephir_check_call_status(); if (ZEPHIR_IS_FALSE_IDENTICAL(_51$$40)) { _53$$41 = zephir_fetch_nproperty_this(this_ptr, SL("_finished"), PH_NOISY_CC); if (ZEPHIR_IS_FALSE_IDENTICAL(_53$$41)) { continue; } } else { zephir_throw_exception_debug(e, "phalcon/dispatcher.zep", 522 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } } } if (Z_TYPE_P(eventsManager) == IS_OBJECT) { ZEPHIR_INIT_NVAR(_55$$44); ZVAL_STRING(_55$$44, "dispatch:afterExecuteRoute", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_54$$44, eventsManager, "fire", &_56, 0, _55$$44, this_ptr, value); zephir_check_temp_parameter(_55$$44); zephir_check_call_status(); if (ZEPHIR_IS_FALSE_IDENTICAL(_54$$44)) { continue; } _57$$44 = zephir_fetch_nproperty_this(this_ptr, SL("_finished"), PH_NOISY_CC); if (ZEPHIR_IS_FALSE_IDENTICAL(_57$$44)) { continue; } ZEPHIR_INIT_NVAR(_55$$44); ZVAL_STRING(_55$$44, "dispatch:afterDispatch", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, eventsManager, "fire", &_58, 0, _55$$44, this_ptr); zephir_check_temp_parameter(_55$$44); zephir_check_call_status(); } if ((zephir_method_exists_ex(handler, SS("afterexecuteroute") TSRMLS_CC) == SUCCESS)) { ZEPHIR_CALL_METHOD(&_59$$47, handler, "afterexecuteroute", NULL, 0, this_ptr, value); zephir_check_call_status(); if (ZEPHIR_IS_FALSE_IDENTICAL(_59$$47)) { continue; } _60$$47 = zephir_fetch_nproperty_this(this_ptr, SL("_finished"), PH_NOISY_CC); if (ZEPHIR_IS_FALSE_IDENTICAL(_60$$47)) { continue; } } } if (Z_TYPE_P(eventsManager) == IS_OBJECT) { ZEPHIR_INIT_VAR(_61$$50); ZVAL_STRING(_61$$50, "dispatch:afterDispatchLoop", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, eventsManager, "fire", NULL, 0, _61$$50, this_ptr); zephir_check_temp_parameter(_61$$50); zephir_check_call_status(); } RETURN_CCTOR(handler); }
/** * Dispatches a handle action taking into account the routing parameters * * @return object */ PHP_METHOD(Phalcon_Dispatcher, _dispatch) { HashTable *_53$$39; HashPosition _52$$39; zval *_30$$6 = NULL, *_60$$44 = NULL, *_62$$44 = NULL, *_63$$44 = NULL, *_68$$45 = NULL, *_70$$45 = NULL; zval *value = NULL, *handler = NULL, *dependencyInjector = NULL, *namespaceName = NULL, *handlerName = NULL, *actionName = NULL, *params = NULL, *eventsManager = NULL, *actionSuffix = NULL, *handlerClass = NULL, *status = NULL, *actionMethod = NULL, *reflectionMethod = NULL, *methodParams = NULL, *className = NULL, *paramKey = NULL, *methodParam = NULL, *modelName = NULL, *bindModel = NULL, *e = NULL, *_0, *_1$$3, *_2$$3, *_3$$4 = NULL, *_4$$4, *_5$$7 = NULL, *_6$$7 = NULL, *_10$$8 = NULL, *_11$$8 = NULL, *_13$$8, *_14$$6 = NULL, *_49$$6, *_16$$12 = NULL, *_17$$12 = NULL, *_19$$13, *_22$$16 = NULL, *_23$$16 = NULL, *_25$$17, *_26$$19 = NULL, *_27$$19 = NULL, *_29$$20, *_31$$23 = NULL, *_32$$23 = NULL, *_34$$23, *_35$$22 = NULL, *_36$$22 = NULL, *_38$$26, *_39$$28 = NULL, *_40$$28 = NULL, *_42$$28, *_43$$31 = NULL, *_44$$31, *_45$$36 = NULL, *_46$$36 = NULL, *_48$$36, **_54$$39, *_55$$40 = NULL, *_56$$41 = NULL, *_57$$43 = NULL, _59$$43 = zval_used_for_init, *_61$$44 = NULL, *_64$$44 = NULL, _65$$42 = zval_used_for_init, *_66$$42 = NULL, *_69$$45 = NULL, *_71$$45 = NULL, *_72$$46 = NULL, *_74$$47 = NULL, *_76$$48, *_77$$51 = NULL, *_78$$51 = NULL, *_80$$51, *_82$$54 = NULL, *_83$$54, *_84$$57; zend_bool hasService = 0, wasFresh; zephir_fcall_cache_entry *_7 = NULL, *_8 = NULL, *_9 = NULL, *_12 = NULL, *_15 = NULL, *_18 = NULL, *_20 = NULL, *_21 = NULL, *_24 = NULL, *_28 = NULL, *_33 = NULL, *_37 = NULL, *_41 = NULL, *_47 = NULL, *_50 = NULL, *_51 = NULL, *_58 = NULL, *_67 = NULL, *_73 = NULL, *_75 = NULL, *_79 = NULL, *_81 = NULL; int ZEPHIR_LAST_CALL_STATUS, numberDispatches = 0; ZEPHIR_MM_GROW(); wasFresh = 0; _0 = zephir_fetch_nproperty_this(this_ptr, SL("_dependencyInjector"), PH_NOISY_CC); ZEPHIR_CPY_WRT(dependencyInjector, _0); if (Z_TYPE_P(dependencyInjector) != IS_OBJECT) { ZEPHIR_INIT_VAR(_1$$3); ZVAL_STRING(_1$$3, "A dependency injection container is required to access related dispatching services", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_VAR(_2$$3); ZVAL_LONG(_2$$3, 0); ZEPHIR_CALL_METHOD(NULL, this_ptr, "_throwdispatchexception", NULL, 0, _1$$3, _2$$3); zephir_check_temp_parameter(_1$$3); zephir_check_call_status(); RETURN_MM_BOOL(0); } _0 = zephir_fetch_nproperty_this(this_ptr, SL("_eventsManager"), PH_NOISY_CC); ZEPHIR_CPY_WRT(eventsManager, _0); if (Z_TYPE_P(eventsManager) == IS_OBJECT) { ZEPHIR_INIT_VAR(_4$$4); ZVAL_STRING(_4$$4, "dispatch:beforeDispatchLoop", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_3$$4, eventsManager, "fire", NULL, 0, _4$$4, this_ptr); zephir_check_temp_parameter(_4$$4); zephir_check_call_status(); if (ZEPHIR_IS_FALSE_IDENTICAL(_3$$4)) { RETURN_MM_BOOL(0); } } ZEPHIR_INIT_VAR(value); ZVAL_NULL(value); ZEPHIR_INIT_VAR(handler); ZVAL_NULL(handler); numberDispatches = 0; ZEPHIR_OBS_VAR(actionSuffix); zephir_read_property_this(&actionSuffix, this_ptr, SL("_actionSuffix"), PH_NOISY_CC); if (0) { zephir_update_property_this(this_ptr, SL("_finished"), ZEPHIR_GLOBAL(global_true) TSRMLS_CC); } else { zephir_update_property_this(this_ptr, SL("_finished"), ZEPHIR_GLOBAL(global_false) TSRMLS_CC); } while (1) { _0 = zephir_fetch_nproperty_this(this_ptr, SL("_finished"), PH_NOISY_CC); if (!(!(zephir_is_true(_0)))) { break; } numberDispatches++; if (numberDispatches == 256) { ZEPHIR_INIT_NVAR(_5$$7); ZVAL_STRING(_5$$7, "Dispatcher has detected a cyclic routing causing stability problems", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_6$$7); ZVAL_LONG(_6$$7, 1); ZEPHIR_CALL_METHOD(NULL, this_ptr, "_throwdispatchexception", &_7, 0, _5$$7, _6$$7); zephir_check_temp_parameter(_5$$7); zephir_check_call_status(); break; } if (1) { zephir_update_property_this(this_ptr, SL("_finished"), ZEPHIR_GLOBAL(global_true) TSRMLS_CC); } else { zephir_update_property_this(this_ptr, SL("_finished"), ZEPHIR_GLOBAL(global_false) TSRMLS_CC); } ZEPHIR_CALL_METHOD(NULL, this_ptr, "_resolveemptyproperties", &_8, 0); zephir_check_call_status(); ZEPHIR_OBS_NVAR(namespaceName); zephir_read_property_this(&namespaceName, this_ptr, SL("_namespaceName"), PH_NOISY_CC); ZEPHIR_OBS_NVAR(handlerName); zephir_read_property_this(&handlerName, this_ptr, SL("_handlerName"), PH_NOISY_CC); ZEPHIR_OBS_NVAR(actionName); zephir_read_property_this(&actionName, this_ptr, SL("_actionName"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(&handlerClass, this_ptr, "gethandlerclass", &_9, 0); zephir_check_call_status(); if (Z_TYPE_P(eventsManager) == IS_OBJECT) { ZEPHIR_INIT_NVAR(_11$$8); ZVAL_STRING(_11$$8, "dispatch:beforeDispatch", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_10$$8, eventsManager, "fire", &_12, 0, _11$$8, this_ptr); zephir_check_temp_parameter(_11$$8); zephir_check_call_status(); if (ZEPHIR_IS_FALSE_IDENTICAL(_10$$8)) { continue; } _13$$8 = zephir_fetch_nproperty_this(this_ptr, SL("_finished"), PH_NOISY_CC); if (ZEPHIR_IS_FALSE_IDENTICAL(_13$$8)) { continue; } } ZEPHIR_CALL_METHOD(&_14$$6, dependencyInjector, "has", &_15, 0, handlerClass); zephir_check_call_status(); hasService = zephir_get_boolval(_14$$6); if (!(hasService)) { hasService = zephir_class_exists(handlerClass, 1 TSRMLS_CC); } if (!(hasService)) { ZEPHIR_INIT_LNVAR(_16$$12); ZEPHIR_CONCAT_VS(_16$$12, handlerClass, " handler class cannot be loaded"); ZEPHIR_INIT_NVAR(_17$$12); ZVAL_LONG(_17$$12, 2); ZEPHIR_CALL_METHOD(&status, this_ptr, "_throwdispatchexception", &_18, 0, _16$$12, _17$$12); zephir_check_call_status(); if (ZEPHIR_IS_FALSE_IDENTICAL(status)) { _19$$13 = zephir_fetch_nproperty_this(this_ptr, SL("_finished"), PH_NOISY_CC); if (ZEPHIR_IS_FALSE_IDENTICAL(_19$$13)) { continue; } } break; } ZEPHIR_CALL_METHOD(&handler, dependencyInjector, "getshared", &_20, 0, handlerClass); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&_14$$6, dependencyInjector, "wasfreshinstance", &_21, 0); zephir_check_call_status(); if (ZEPHIR_IS_TRUE_IDENTICAL(_14$$6)) { wasFresh = 1; } if (Z_TYPE_P(handler) != IS_OBJECT) { ZEPHIR_INIT_NVAR(_22$$16); ZVAL_STRING(_22$$16, "Invalid handler returned from the services container", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_23$$16); ZVAL_LONG(_23$$16, 3); ZEPHIR_CALL_METHOD(&status, this_ptr, "_throwdispatchexception", &_24, 0, _22$$16, _23$$16); zephir_check_temp_parameter(_22$$16); zephir_check_call_status(); if (ZEPHIR_IS_FALSE_IDENTICAL(status)) { _25$$17 = zephir_fetch_nproperty_this(this_ptr, SL("_finished"), PH_NOISY_CC); if (ZEPHIR_IS_FALSE_IDENTICAL(_25$$17)) { continue; } } break; } zephir_update_property_this(this_ptr, SL("_activeHandler"), handler TSRMLS_CC); ZEPHIR_OBS_NVAR(params); zephir_read_property_this(¶ms, this_ptr, SL("_params"), PH_NOISY_CC); if (Z_TYPE_P(params) != IS_ARRAY) { ZEPHIR_INIT_NVAR(_26$$19); ZVAL_STRING(_26$$19, "Action parameters must be an Array", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_27$$19); ZVAL_LONG(_27$$19, 4); ZEPHIR_CALL_METHOD(&status, this_ptr, "_throwdispatchexception", &_28, 0, _26$$19, _27$$19); zephir_check_temp_parameter(_26$$19); zephir_check_call_status(); if (ZEPHIR_IS_FALSE_IDENTICAL(status)) { _29$$20 = zephir_fetch_nproperty_this(this_ptr, SL("_finished"), PH_NOISY_CC); if (ZEPHIR_IS_FALSE_IDENTICAL(_29$$20)) { continue; } } break; } ZEPHIR_INIT_NVAR(actionMethod); ZEPHIR_CONCAT_VV(actionMethod, actionName, actionSuffix); ZEPHIR_INIT_NVAR(_30$$6); zephir_create_array(_30$$6, 2, 0 TSRMLS_CC); zephir_array_fast_append(_30$$6, handler); zephir_array_fast_append(_30$$6, actionMethod); if (!(zephir_is_callable(_30$$6 TSRMLS_CC))) { if (Z_TYPE_P(eventsManager) == IS_OBJECT) { ZEPHIR_INIT_NVAR(_32$$23); ZVAL_STRING(_32$$23, "dispatch:beforeNotFoundAction", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_31$$23, eventsManager, "fire", &_33, 0, _32$$23, this_ptr); zephir_check_temp_parameter(_32$$23); zephir_check_call_status(); if (ZEPHIR_IS_FALSE_IDENTICAL(_31$$23)) { continue; } _34$$23 = zephir_fetch_nproperty_this(this_ptr, SL("_finished"), PH_NOISY_CC); if (ZEPHIR_IS_FALSE_IDENTICAL(_34$$23)) { continue; } } ZEPHIR_INIT_LNVAR(_35$$22); ZEPHIR_CONCAT_SVSVS(_35$$22, "Action '", actionName, "' was not found on handler '", handlerName, "'"); ZEPHIR_INIT_NVAR(_36$$22); ZVAL_LONG(_36$$22, 5); ZEPHIR_CALL_METHOD(&status, this_ptr, "_throwdispatchexception", &_37, 0, _35$$22, _36$$22); zephir_check_call_status(); if (ZEPHIR_IS_FALSE_IDENTICAL(status)) { _38$$26 = zephir_fetch_nproperty_this(this_ptr, SL("_finished"), PH_NOISY_CC); if (ZEPHIR_IS_FALSE_IDENTICAL(_38$$26)) { continue; } } break; } if (Z_TYPE_P(eventsManager) == IS_OBJECT) { ZEPHIR_INIT_NVAR(_40$$28); ZVAL_STRING(_40$$28, "dispatch:beforeExecuteRoute", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_39$$28, eventsManager, "fire", &_41, 0, _40$$28, this_ptr); zephir_check_temp_parameter(_40$$28); zephir_check_call_status(); if (ZEPHIR_IS_FALSE_IDENTICAL(_39$$28)) { continue; } _42$$28 = zephir_fetch_nproperty_this(this_ptr, SL("_finished"), PH_NOISY_CC); if (ZEPHIR_IS_FALSE_IDENTICAL(_42$$28)) { continue; } } if ((zephir_method_exists_ex(handler, SS("beforeexecuteroute") TSRMLS_CC) == SUCCESS)) { ZEPHIR_CALL_METHOD(&_43$$31, handler, "beforeexecuteroute", NULL, 0, this_ptr); zephir_check_call_status(); if (ZEPHIR_IS_FALSE_IDENTICAL(_43$$31)) { continue; } _44$$31 = zephir_fetch_nproperty_this(this_ptr, SL("_finished"), PH_NOISY_CC); if (ZEPHIR_IS_FALSE_IDENTICAL(_44$$31)) { continue; } } if (wasFresh == 1) { if ((zephir_method_exists_ex(handler, SS("initialize") TSRMLS_CC) == SUCCESS)) { ZEPHIR_CALL_METHOD(NULL, handler, "initialize", NULL, 0); zephir_check_call_status(); } if (zephir_is_true(eventsManager)) { ZEPHIR_INIT_NVAR(_46$$36); ZVAL_STRING(_46$$36, "dispatch:afterInitialize", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_45$$36, eventsManager, "fire", &_47, 0, _46$$36, this_ptr); zephir_check_temp_parameter(_46$$36); zephir_check_call_status(); if (ZEPHIR_IS_FALSE_IDENTICAL(_45$$36)) { continue; } _48$$36 = zephir_fetch_nproperty_this(this_ptr, SL("_finished"), PH_NOISY_CC); if (ZEPHIR_IS_FALSE_IDENTICAL(_48$$36)) { continue; } } } _49$$6 = zephir_fetch_nproperty_this(this_ptr, SL("_modelBinding"), PH_NOISY_CC); if (ZEPHIR_IS_TRUE_IDENTICAL(_49$$6)) { ZEPHIR_INIT_NVAR(reflectionMethod); object_init_ex(reflectionMethod, zephir_get_internal_ce(SS("reflectionmethod") TSRMLS_CC)); ZEPHIR_CALL_METHOD(NULL, reflectionMethod, "__construct", &_50, 69, handlerClass, actionMethod); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&methodParams, reflectionMethod, "getparameters", &_51, 70); zephir_check_call_status(); zephir_is_iterable(methodParams, &_53$$39, &_52$$39, 0, 0, "phalcon/dispatcher.zep", 582); for ( ; zephir_hash_get_current_data_ex(_53$$39, (void**) &_54$$39, &_52$$39) == SUCCESS ; zephir_hash_move_forward_ex(_53$$39, &_52$$39) ) { ZEPHIR_GET_HMKEY(paramKey, _53$$39, _52$$39); ZEPHIR_GET_HVALUE(methodParam, _54$$39); ZEPHIR_CALL_METHOD(&_55$$40, methodParam, "getclass", NULL, 0); zephir_check_call_status(); if (zephir_is_true(_55$$40)) { ZEPHIR_CALL_METHOD(&_56$$41, methodParam, "getclass", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&className, _56$$41, "getname", NULL, 0); zephir_check_call_status(); if (Z_TYPE_P(className) == IS_STRING) { if (ZEPHIR_IS_STRING(className, "Phalcon\\Mvc\\Model")) { ZEPHIR_CALL_FUNCTION(&_57$$43, "class_implements", &_58, 71, handlerClass); zephir_check_call_status(); ZEPHIR_SINIT_NVAR(_59$$43); ZVAL_STRING(&_59$$43, "Phalcon\\Mvc\\Controller\\BindModelInterface", 0); if (zephir_fast_in_array(&_59$$43, _57$$43 TSRMLS_CC)) { ZEPHIR_INIT_NVAR(_60$$44); zephir_create_array(_60$$44, 2, 0 TSRMLS_CC); zephir_array_fast_append(_60$$44, handlerClass); ZEPHIR_INIT_NVAR(_61$$44); ZVAL_STRING(_61$$44, "getModelName", 1); zephir_array_fast_append(_60$$44, _61$$44); ZEPHIR_INIT_NVAR(modelName); ZEPHIR_CALL_USER_FUNC(modelName, _60$$44); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_62$$44); zephir_create_array(_62$$44, 2, 0 TSRMLS_CC); zephir_array_fast_append(_62$$44, modelName); ZEPHIR_INIT_NVAR(_61$$44); ZVAL_STRING(_61$$44, "findFirst", 1); zephir_array_fast_append(_62$$44, _61$$44); ZEPHIR_INIT_NVAR(_63$$44); zephir_create_array(_63$$44, 1, 0 TSRMLS_CC); ZEPHIR_OBS_NVAR(_64$$44); zephir_array_fetch(&_64$$44, params, paramKey, PH_NOISY, "phalcon/dispatcher.zep", 567 TSRMLS_CC); zephir_array_fast_append(_63$$44, _64$$44); ZEPHIR_INIT_NVAR(bindModel); ZEPHIR_CALL_USER_FUNC_ARRAY(bindModel, _62$$44, _63$$44); zephir_check_call_status(); zephir_array_update_zval(¶ms, paramKey, &bindModel, PH_COPY | PH_SEPARATE); break; } } ZEPHIR_SINIT_NVAR(_65$$42); ZVAL_STRING(&_65$$42, "Phalcon\\Mvc\\Model", 0); ZEPHIR_CALL_FUNCTION(&_66$$42, "is_subclass_of", &_67, 72, className, &_65$$42); zephir_check_call_status(); if (zephir_is_true(_66$$42)) { ZEPHIR_INIT_NVAR(_68$$45); zephir_create_array(_68$$45, 2, 0 TSRMLS_CC); zephir_array_fast_append(_68$$45, className); ZEPHIR_INIT_NVAR(_69$$45); ZVAL_STRING(_69$$45, "findFirst", 1); zephir_array_fast_append(_68$$45, _69$$45); ZEPHIR_INIT_NVAR(_70$$45); zephir_create_array(_70$$45, 1, 0 TSRMLS_CC); ZEPHIR_OBS_NVAR(_71$$45); zephir_array_fetch(&_71$$45, params, paramKey, PH_NOISY, "phalcon/dispatcher.zep", 575 TSRMLS_CC); zephir_array_fast_append(_70$$45, _71$$45); ZEPHIR_INIT_NVAR(bindModel); ZEPHIR_CALL_USER_FUNC_ARRAY(bindModel, _68$$45, _70$$45); zephir_check_call_status(); zephir_array_update_zval(¶ms, paramKey, &bindModel, PH_COPY | PH_SEPARATE); break; } } } } } zephir_update_property_this(this_ptr, SL("_lastHandler"), handler TSRMLS_CC); /* try_start_1: */ ZEPHIR_CALL_METHOD(&_72$$46, this_ptr, "callactionmethod", &_73, 0, handler, actionMethod, params); zephir_check_call_status_or_jump(try_end_1); zephir_update_property_this(this_ptr, SL("_returnedValue"), _72$$46 TSRMLS_CC); try_end_1: if (EG(exception)) { ZEPHIR_CPY_WRT(e, EG(exception)); if (zephir_instance_of_ev(e, zend_exception_get_default(TSRMLS_C) TSRMLS_CC)) { zend_clear_exception(TSRMLS_C); ZEPHIR_CALL_METHOD(&_74$$47, this_ptr, "_handleexception", &_75, 0, e); zephir_check_call_status(); if (ZEPHIR_IS_FALSE_IDENTICAL(_74$$47)) { _76$$48 = zephir_fetch_nproperty_this(this_ptr, SL("_finished"), PH_NOISY_CC); if (ZEPHIR_IS_FALSE_IDENTICAL(_76$$48)) { continue; } } else { zephir_throw_exception_debug(e, "phalcon/dispatcher.zep", 595 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } } } if (Z_TYPE_P(eventsManager) == IS_OBJECT) { ZEPHIR_INIT_NVAR(_78$$51); ZVAL_STRING(_78$$51, "dispatch:afterExecuteRoute", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_77$$51, eventsManager, "fire", &_79, 0, _78$$51, this_ptr, value); zephir_check_temp_parameter(_78$$51); zephir_check_call_status(); if (ZEPHIR_IS_FALSE_IDENTICAL(_77$$51)) { continue; } _80$$51 = zephir_fetch_nproperty_this(this_ptr, SL("_finished"), PH_NOISY_CC); if (ZEPHIR_IS_FALSE_IDENTICAL(_80$$51)) { continue; } ZEPHIR_INIT_NVAR(_78$$51); ZVAL_STRING(_78$$51, "dispatch:afterDispatch", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, eventsManager, "fire", &_81, 0, _78$$51, this_ptr); zephir_check_temp_parameter(_78$$51); zephir_check_call_status(); } if ((zephir_method_exists_ex(handler, SS("afterexecuteroute") TSRMLS_CC) == SUCCESS)) { ZEPHIR_CALL_METHOD(&_82$$54, handler, "afterexecuteroute", NULL, 0, this_ptr, value); zephir_check_call_status(); if (ZEPHIR_IS_FALSE_IDENTICAL(_82$$54)) { continue; } _83$$54 = zephir_fetch_nproperty_this(this_ptr, SL("_finished"), PH_NOISY_CC); if (ZEPHIR_IS_FALSE_IDENTICAL(_83$$54)) { continue; } } } if (Z_TYPE_P(eventsManager) == IS_OBJECT) { ZEPHIR_INIT_VAR(_84$$57); ZVAL_STRING(_84$$57, "dispatch:afterDispatchLoop", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, eventsManager, "fire", NULL, 0, _84$$57, this_ptr); zephir_check_temp_parameter(_84$$57); zephir_check_call_status(); } RETURN_CCTOR(handler); }
/** * Gets a value from the internal related entity or from the default value */ PHP_METHOD(Phalcon_Forms_Form, getValue) { zend_long ZEPHIR_LAST_CALL_STATUS; zval *name_param = NULL, *entity = NULL, *method = NULL, *value = NULL, *data = NULL, *internal = NULL, *forbidden = NULL, *_1, *_0$$4; zval *name = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &name_param); if (UNEXPECTED(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (EXPECTED(Z_TYPE_P(name_param) == IS_STRING)) { zephir_get_strval(name, name_param); } else { ZEPHIR_INIT_VAR(name); ZVAL_EMPTY_STRING(name); } ZEPHIR_OBS_VAR(entity); zephir_read_property_this(&entity, this_ptr, SL("_entity"), PH_NOISY_CC); ZEPHIR_OBS_VAR(data); zephir_read_property_this(&data, this_ptr, SL("_data"), PH_NOISY_CC); if ((zephir_method_exists_ex(this_ptr, SS("getcustomvalue") TSRMLS_CC) == SUCCESS)) { ZEPHIR_RETURN_CALL_METHOD(this_ptr, "getcustomvalue", NULL, 0, name, entity, data); zephir_check_call_status(); RETURN_MM(); } if (Z_TYPE_P(entity) == IS_OBJECT) { ZEPHIR_INIT_VAR(_0$$4); zephir_camelize(_0$$4, name, NULL ); ZEPHIR_INIT_VAR(method); ZEPHIR_CONCAT_SV(method, "get", _0$$4); if ((zephir_method_exists(entity, method TSRMLS_CC) == SUCCESS)) { ZEPHIR_RETURN_CALL_METHOD_ZVAL(entity, method, NULL, 0); zephir_check_call_status(); RETURN_MM(); } ZEPHIR_OBS_VAR(value); if (zephir_fetch_property_zval(&value, entity, name, PH_SILENT_CC)) { RETURN_CCTOR(value); } } if (Z_TYPE_P(data) == IS_ARRAY) { ZEPHIR_OBS_NVAR(value); if (zephir_array_isset_fetch(&value, data, name, 0 TSRMLS_CC)) { RETURN_CCTOR(value); } } ZEPHIR_INIT_VAR(forbidden); zephir_create_array(forbidden, 12, 0 TSRMLS_CC); zephir_array_update_string(&forbidden, SL("validation"), &ZEPHIR_GLOBAL(global_true), PH_COPY | PH_SEPARATE); zephir_array_update_string(&forbidden, SL("action"), &ZEPHIR_GLOBAL(global_true), PH_COPY | PH_SEPARATE); zephir_array_update_string(&forbidden, SL("useroption"), &ZEPHIR_GLOBAL(global_true), PH_COPY | PH_SEPARATE); zephir_array_update_string(&forbidden, SL("useroptions"), &ZEPHIR_GLOBAL(global_true), PH_COPY | PH_SEPARATE); zephir_array_update_string(&forbidden, SL("entity"), &ZEPHIR_GLOBAL(global_true), PH_COPY | PH_SEPARATE); zephir_array_update_string(&forbidden, SL("elements"), &ZEPHIR_GLOBAL(global_true), PH_COPY | PH_SEPARATE); zephir_array_update_string(&forbidden, SL("messages"), &ZEPHIR_GLOBAL(global_true), PH_COPY | PH_SEPARATE); zephir_array_update_string(&forbidden, SL("messagesfor"), &ZEPHIR_GLOBAL(global_true), PH_COPY | PH_SEPARATE); zephir_array_update_string(&forbidden, SL("label"), &ZEPHIR_GLOBAL(global_true), PH_COPY | PH_SEPARATE); zephir_array_update_string(&forbidden, SL("value"), &ZEPHIR_GLOBAL(global_true), PH_COPY | PH_SEPARATE); zephir_array_update_string(&forbidden, SL("di"), &ZEPHIR_GLOBAL(global_true), PH_COPY | PH_SEPARATE); zephir_array_update_string(&forbidden, SL("eventsmanager"), &ZEPHIR_GLOBAL(global_true), PH_COPY | PH_SEPARATE); ZEPHIR_INIT_VAR(internal); zephir_fast_strtolower(internal, name); if (zephir_array_isset(forbidden, internal)) { RETURN_MM_NULL(); } ZEPHIR_INIT_VAR(_1); zephir_camelize(_1, name, NULL ); ZEPHIR_INIT_NVAR(method); ZEPHIR_CONCAT_SV(method, "get", _1); if ((zephir_method_exists(this_ptr, method TSRMLS_CC) == SUCCESS)) { ZEPHIR_RETURN_CALL_METHOD_ZVAL(this_ptr, method, NULL, 0); zephir_check_call_status(); RETURN_MM(); } RETURN_MM_NULL(); }
/** * Validates the form * * @param array data * @param object entity */ PHP_METHOD(Phalcon_Forms_Form, isValid) { zend_object_iterator *_16$$15; HashTable *_7, *_11$$11; HashPosition _6, _10$$11; zend_bool validationStatus = 0, _4, _9$$11; zephir_fcall_cache_entry *_13 = NULL, *_14 = NULL, *_19 = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; zval *data = NULL, *entity = NULL, *messages = NULL, *element = NULL, *validators = NULL, *name = NULL, *filters = NULL, *validator = NULL, *validation = NULL, *elementMessage = NULL, *_0, *_5, **_8, *_15 = NULL, *_1$$6, *_2$$7, *_3$$8 = NULL, **_12$$11, *_17$$16 = NULL, *_18$$16 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 2, &data, &entity); if (!data) { ZEPHIR_CPY_WRT(data, ZEPHIR_GLOBAL(global_null)); } else { ZEPHIR_SEPARATE_PARAM(data); } if (!entity) { entity = ZEPHIR_GLOBAL(global_null); } _0 = zephir_fetch_nproperty_this(this_ptr, SL("_elements"), PH_NOISY_CC); if (ZEPHIR_IS_EMPTY(_0)) { RETURN_MM_BOOL(1); } if (Z_TYPE_P(data) != IS_ARRAY) { ZEPHIR_OBS_NVAR(data); zephir_read_property_this(&data, this_ptr, SL("_data"), PH_NOISY_CC); } if (Z_TYPE_P(entity) == IS_OBJECT) { ZEPHIR_CALL_METHOD(NULL, this_ptr, "bind", NULL, 0, data, entity); zephir_check_call_status(); } else { ZEPHIR_OBS_VAR(_1$$6); zephir_read_property_this(&_1$$6, this_ptr, SL("_entity"), PH_NOISY_CC); if (Z_TYPE_P(_1$$6) == IS_OBJECT) { _2$$7 = zephir_fetch_nproperty_this(this_ptr, SL("_entity"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(NULL, this_ptr, "bind", NULL, 0, data, _2$$7); zephir_check_call_status(); } } if ((zephir_method_exists_ex(this_ptr, SS("beforevalidation") TSRMLS_CC) == SUCCESS)) { ZEPHIR_CALL_METHOD(&_3$$8, this_ptr, "beforevalidation", NULL, 0, data, entity); zephir_check_call_status(); if (ZEPHIR_IS_FALSE_IDENTICAL(_3$$8)) { RETURN_MM_BOOL(0); } } validationStatus = 1; ZEPHIR_CALL_METHOD(&validation, this_ptr, "getvalidation", NULL, 0); zephir_check_call_status(); _4 = Z_TYPE_P(validation) != IS_OBJECT; if (!(_4)) { _4 = !((zephir_instance_of_ev(validation, phalcon_validationinterface_ce TSRMLS_CC))); } if (_4) { ZEPHIR_INIT_NVAR(validation); object_init_ex(validation, phalcon_validation_ce); ZEPHIR_CALL_METHOD(NULL, validation, "__construct", NULL, 227); zephir_check_call_status(); } _5 = zephir_fetch_nproperty_this(this_ptr, SL("_elements"), PH_NOISY_CC); zephir_is_iterable(_5, &_7, &_6, 0, 0, "phalcon/forms/form.zep", 338); for ( ; zend_hash_get_current_data_ex(_7, (void**) &_8, &_6) == SUCCESS ; zend_hash_move_forward_ex(_7, &_6) ) { ZEPHIR_GET_HVALUE(element, _8); ZEPHIR_CALL_METHOD(&validators, element, "getvalidators", NULL, 0); zephir_check_call_status(); _9$$11 = Z_TYPE_P(validators) != IS_ARRAY; if (!(_9$$11)) { _9$$11 = zephir_fast_count_int(validators TSRMLS_CC) == 0; } if (_9$$11) { continue; } ZEPHIR_CALL_METHOD(&name, element, "getname", NULL, 0); zephir_check_call_status(); zephir_is_iterable(validators, &_11$$11, &_10$$11, 0, 0, "phalcon/forms/form.zep", 325); for ( ; zend_hash_get_current_data_ex(_11$$11, (void**) &_12$$11, &_10$$11) == SUCCESS ; zend_hash_move_forward_ex(_11$$11, &_10$$11) ) { ZEPHIR_GET_HVALUE(validator, _12$$11); ZEPHIR_CALL_METHOD(NULL, validation, "add", &_13, 228, name, validator); zephir_check_call_status(); } ZEPHIR_CALL_METHOD(&filters, element, "getfilters", NULL, 0); zephir_check_call_status(); if (Z_TYPE_P(filters) == IS_ARRAY) { ZEPHIR_CALL_METHOD(NULL, validation, "setfilters", &_14, 229, name, filters); zephir_check_call_status(); } } ZEPHIR_CALL_METHOD(&messages, validation, "validate", NULL, 230, data, entity); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&_15, messages, "count", NULL, 0); zephir_check_call_status(); if (zephir_is_true(_15)) { _16$$15 = zephir_get_iterator(messages TSRMLS_CC); _16$$15->funcs->rewind(_16$$15 TSRMLS_CC); for (;_16$$15->funcs->valid(_16$$15 TSRMLS_CC) == SUCCESS && !EG(exception); _16$$15->funcs->move_forward(_16$$15 TSRMLS_CC)) { { zval **ZEPHIR_TMP_ITERATOR_PTR; _16$$15->funcs->get_current_data(_16$$15, &ZEPHIR_TMP_ITERATOR_PTR TSRMLS_CC); ZEPHIR_CPY_WRT(elementMessage, (*ZEPHIR_TMP_ITERATOR_PTR)); } ZEPHIR_CALL_METHOD(&_18$$16, elementMessage, "getfield", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&_17$$16, this_ptr, "get", &_19, 0, _18$$16); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, _17$$16, "appendmessage", NULL, 0, elementMessage); zephir_check_call_status(); } _16$$15->funcs->dtor(_16$$15 TSRMLS_CC); ZEPHIR_CALL_METHOD(NULL, messages, "rewind", NULL, 0); zephir_check_call_status(); validationStatus = 0; } if (!(validationStatus)) { zephir_update_property_this(getThis(), SL("_messages"), messages TSRMLS_CC); } if ((zephir_method_exists_ex(this_ptr, SS("aftervalidation") TSRMLS_CC) == SUCCESS)) { ZEPHIR_CALL_METHOD(NULL, this_ptr, "aftervalidation", NULL, 0, messages); zephir_check_call_status(); } RETURN_MM_BOOL(validationStatus); }
/** * Dispatches a handle action taking into account the routing parameters * * @return object */ PHP_METHOD(Phalcon_Dispatcher, dispatch) { zval *_18 = NULL; zephir_fcall_cache_entry *_4 = NULL, *_5 = NULL, *_8 = NULL, *_10 = NULL, *_11 = NULL, *_12 = NULL, *_13 = NULL, *_14 = NULL, *_16 = NULL, *_19 = NULL; zval *value, *handler = NULL, *dependencyInjector = NULL, *namespaceName = NULL, *handlerName = NULL, *actionName = NULL, *camelizedClass = NULL, *params = NULL, *eventsManager = NULL, *handlerSuffix, *actionSuffix, *handlerClass = NULL, *status = NULL, *actionMethod = NULL, *e = NULL, *_0, *_1 = NULL, *_2 = NULL, *_3 = NULL, *_6, *_7 = NULL, *_9 = NULL, *_15 = NULL, *_17; int numberDispatches, ZEPHIR_LAST_CALL_STATUS; zend_bool hasService, wasFresh = 0; ZEPHIR_MM_GROW(); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_dependencyInjector"), PH_NOISY_CC); ZEPHIR_CPY_WRT(dependencyInjector, _0); if (Z_TYPE_P(dependencyInjector) != IS_OBJECT) { ZEPHIR_INIT_VAR(_1); ZVAL_STRING(_1, "A dependency injection container is required to access related dispatching services", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_VAR(_2); ZVAL_LONG(_2, 0); ZEPHIR_CALL_METHOD(NULL, this_ptr, "_throwdispatchexception", NULL, _1, _2); zephir_check_temp_parameter(_1); zephir_check_call_status(); RETURN_MM_BOOL(0); } _0 = zephir_fetch_nproperty_this(this_ptr, SL("_eventsManager"), PH_NOISY_CC); ZEPHIR_CPY_WRT(eventsManager, _0); if (Z_TYPE_P(eventsManager) == IS_OBJECT) { ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "dispatch:beforeDispatchLoop", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_3, eventsManager, "fire", NULL, _1, this_ptr); zephir_check_temp_parameter(_1); zephir_check_call_status(); if (ZEPHIR_IS_FALSE_IDENTICAL(_3)) { RETURN_MM_BOOL(0); } } ZEPHIR_INIT_VAR(value); ZVAL_NULL(value); ZEPHIR_INIT_VAR(handler); ZVAL_NULL(handler); numberDispatches = 0; ZEPHIR_OBS_VAR(handlerSuffix); zephir_read_property_this(&handlerSuffix, this_ptr, SL("_handlerSuffix"), PH_NOISY_CC); ZEPHIR_OBS_VAR(actionSuffix); zephir_read_property_this(&actionSuffix, this_ptr, SL("_actionSuffix"), PH_NOISY_CC); zephir_update_property_this(this_ptr, SL("_finished"), (0) ? ZEPHIR_GLOBAL(global_true) : ZEPHIR_GLOBAL(global_false) TSRMLS_CC); while (1) { _0 = zephir_fetch_nproperty_this(this_ptr, SL("_finished"), PH_NOISY_CC); if (!(!(zephir_is_true(_0)))) { break; } numberDispatches++; if (numberDispatches == 256) { ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "Dispatcher has detected a cyclic routing causing stability problems", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_2); ZVAL_LONG(_2, 1); ZEPHIR_CALL_METHOD(NULL, this_ptr, "_throwdispatchexception", &_4, _1, _2); zephir_check_temp_parameter(_1); zephir_check_call_status(); break; } zephir_update_property_this(this_ptr, SL("_finished"), (1) ? ZEPHIR_GLOBAL(global_true) : ZEPHIR_GLOBAL(global_false) TSRMLS_CC); ZEPHIR_OBS_NVAR(namespaceName); zephir_read_property_this(&namespaceName, this_ptr, SL("_namespaceName"), PH_NOISY_CC); if (!(zephir_is_true(namespaceName))) { ZEPHIR_OBS_NVAR(namespaceName); zephir_read_property_this(&namespaceName, this_ptr, SL("_defaultNamespace"), PH_NOISY_CC); zephir_update_property_this(this_ptr, SL("_namespaceName"), namespaceName TSRMLS_CC); } ZEPHIR_OBS_NVAR(handlerName); zephir_read_property_this(&handlerName, this_ptr, SL("_handlerName"), PH_NOISY_CC); if (!(zephir_is_true(handlerName))) { ZEPHIR_OBS_NVAR(handlerName); zephir_read_property_this(&handlerName, this_ptr, SL("_defaultHandler"), PH_NOISY_CC); zephir_update_property_this(this_ptr, SL("_handlerName"), handlerName TSRMLS_CC); } ZEPHIR_OBS_NVAR(actionName); zephir_read_property_this(&actionName, this_ptr, SL("_actionName"), PH_NOISY_CC); if (!(zephir_is_true(actionName))) { ZEPHIR_OBS_NVAR(actionName); zephir_read_property_this(&actionName, this_ptr, SL("_defaultAction"), PH_NOISY_CC); zephir_update_property_this(this_ptr, SL("_actionName"), actionName TSRMLS_CC); } if (Z_TYPE_P(eventsManager) == IS_OBJECT) { ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "dispatch:beforeDispatch", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_3, eventsManager, "fire", &_5, _1, this_ptr); zephir_check_temp_parameter(_1); zephir_check_call_status(); if (ZEPHIR_IS_FALSE_IDENTICAL(_3)) { continue; } _6 = zephir_fetch_nproperty_this(this_ptr, SL("_finished"), PH_NOISY_CC); if (ZEPHIR_IS_FALSE_IDENTICAL(_6)) { continue; } } if (!(zephir_memnstr_str(handlerName, SL("\\"), "phalcon/dispatcher.zep", 390))) { ZEPHIR_INIT_NVAR(camelizedClass); zephir_camelize(camelizedClass, handlerName); } else { ZEPHIR_CPY_WRT(camelizedClass, handlerName); } if (zephir_is_true(namespaceName)) { ZEPHIR_INIT_NVAR(handlerClass); if (zephir_end_with_str(namespaceName, SL("\\"))) { ZEPHIR_CONCAT_VVV(handlerClass, namespaceName, camelizedClass, handlerSuffix); } else { ZEPHIR_CONCAT_VSVV(handlerClass, namespaceName, "\\", camelizedClass, handlerSuffix); } } else { ZEPHIR_INIT_NVAR(handlerClass); ZEPHIR_CONCAT_VV(handlerClass, camelizedClass, handlerSuffix); } ZEPHIR_CALL_METHOD(&_7, dependencyInjector, "has", &_8, handlerClass); zephir_check_call_status(); hasService = zephir_get_boolval(_7); if (!(hasService)) { hasService = zephir_class_exists(handlerClass, 1 TSRMLS_CC); } if (!(hasService)) { ZEPHIR_INIT_LNVAR(_9); ZEPHIR_CONCAT_VS(_9, handlerClass, " handler class cannot be loaded"); ZEPHIR_INIT_NVAR(_1); ZVAL_LONG(_1, 2); ZEPHIR_CALL_METHOD(&status, this_ptr, "_throwdispatchexception", &_10, _9, _1); zephir_check_call_status(); if (ZEPHIR_IS_FALSE_IDENTICAL(status)) { _6 = zephir_fetch_nproperty_this(this_ptr, SL("_finished"), PH_NOISY_CC); if (ZEPHIR_IS_FALSE_IDENTICAL(_6)) { continue; } } break; } ZEPHIR_CALL_METHOD(&handler, dependencyInjector, "getshared", &_11, handlerClass); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&_7, dependencyInjector, "wasfreshinstance", &_12); zephir_check_call_status(); if (ZEPHIR_IS_TRUE_IDENTICAL(_7)) { wasFresh = 1; } if (Z_TYPE_P(handler) != IS_OBJECT) { ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "Invalid handler returned from the services container", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_2); ZVAL_LONG(_2, 3); ZEPHIR_CALL_METHOD(&status, this_ptr, "_throwdispatchexception", &_13, _1, _2); zephir_check_temp_parameter(_1); zephir_check_call_status(); if (ZEPHIR_IS_FALSE_IDENTICAL(status)) { _6 = zephir_fetch_nproperty_this(this_ptr, SL("_finished"), PH_NOISY_CC); if (ZEPHIR_IS_FALSE_IDENTICAL(_6)) { continue; } } break; } zephir_update_property_this(this_ptr, SL("_activeHandler"), handler TSRMLS_CC); ZEPHIR_OBS_NVAR(params); zephir_read_property_this(¶ms, this_ptr, SL("_params"), PH_NOISY_CC); if (Z_TYPE_P(params) != IS_ARRAY) { ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "Action parameters must be an Array", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_2); ZVAL_LONG(_2, 4); ZEPHIR_CALL_METHOD(&status, this_ptr, "_throwdispatchexception", &_14, _1, _2); zephir_check_temp_parameter(_1); zephir_check_call_status(); if (ZEPHIR_IS_FALSE_IDENTICAL(status)) { _6 = zephir_fetch_nproperty_this(this_ptr, SL("_finished"), PH_NOISY_CC); if (ZEPHIR_IS_FALSE_IDENTICAL(_6)) { continue; } } break; } ZEPHIR_INIT_NVAR(actionMethod); ZEPHIR_CONCAT_VV(actionMethod, actionName, actionSuffix); if (!((zephir_method_exists(handler, actionMethod TSRMLS_CC) == SUCCESS))) { if (Z_TYPE_P(eventsManager) == IS_OBJECT) { ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "dispatch:beforeNotFoundAction", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_15, eventsManager, "fire", &_5, _1, this_ptr); zephir_check_temp_parameter(_1); zephir_check_call_status(); if (ZEPHIR_IS_FALSE_IDENTICAL(_15)) { continue; } _6 = zephir_fetch_nproperty_this(this_ptr, SL("_finished"), PH_NOISY_CC); if (ZEPHIR_IS_FALSE_IDENTICAL(_6)) { continue; } } ZEPHIR_INIT_LNVAR(_9); ZEPHIR_CONCAT_SVSVS(_9, "Action '", actionName, "' was not found on handler '", handlerName, "'"); ZEPHIR_INIT_NVAR(_1); ZVAL_LONG(_1, 5); ZEPHIR_CALL_METHOD(&status, this_ptr, "_throwdispatchexception", &_16, _9, _1); zephir_check_call_status(); if (ZEPHIR_IS_FALSE_IDENTICAL(status)) { _17 = zephir_fetch_nproperty_this(this_ptr, SL("_finished"), PH_NOISY_CC); if (ZEPHIR_IS_FALSE_IDENTICAL(_17)) { continue; } } break; } if (Z_TYPE_P(eventsManager) == IS_OBJECT) { ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "dispatch:beforeExecuteRoute", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_15, eventsManager, "fire", &_5, _1, this_ptr); zephir_check_temp_parameter(_1); zephir_check_call_status(); if (ZEPHIR_IS_FALSE_IDENTICAL(_15)) { continue; } _6 = zephir_fetch_nproperty_this(this_ptr, SL("_finished"), PH_NOISY_CC); if (ZEPHIR_IS_FALSE_IDENTICAL(_6)) { continue; } } if ((zephir_method_exists_ex(handler, SS("beforeexecuteroute") TSRMLS_CC) == SUCCESS)) { ZEPHIR_CALL_METHOD(&_15, handler, "beforeexecuteroute", NULL, this_ptr); zephir_check_call_status(); if (ZEPHIR_IS_FALSE_IDENTICAL(_15)) { continue; } _6 = zephir_fetch_nproperty_this(this_ptr, SL("_finished"), PH_NOISY_CC); if (ZEPHIR_IS_FALSE_IDENTICAL(_6)) { continue; } } if (wasFresh == 1) { if ((zephir_method_exists_ex(handler, SS("initialize") TSRMLS_CC) == SUCCESS)) { ZEPHIR_CALL_METHOD(NULL, handler, "initialize", NULL); zephir_check_call_status(); } if (zephir_is_true(eventsManager)) { ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "dispatch:afterInitialize", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_15, eventsManager, "fire", &_5, _1, this_ptr); zephir_check_temp_parameter(_1); zephir_check_call_status(); if (ZEPHIR_IS_FALSE_IDENTICAL(_15)) { continue; } _6 = zephir_fetch_nproperty_this(this_ptr, SL("_finished"), PH_NOISY_CC); if (ZEPHIR_IS_FALSE_IDENTICAL(_6)) { continue; } } } /* try_start_1: */ ZEPHIR_INIT_NVAR(_1); ZEPHIR_INIT_NVAR(_18); zephir_create_array(_18, 2, 0 TSRMLS_CC); zephir_array_fast_append(_18, handler); zephir_array_fast_append(_18, actionMethod); ZEPHIR_CALL_USER_FUNC_ARRAY(_1, _18, params); zephir_check_call_status_or_jump(try_end_1); zephir_update_property_this(this_ptr, SL("_returnedValue"), _1 TSRMLS_CC); zephir_update_property_this(this_ptr, SL("_lastHandler"), handler TSRMLS_CC); try_end_1: if (EG(exception)) { ZEPHIR_CPY_WRT(e, EG(exception)); if (zephir_instance_of_ev(e, zend_exception_get_default(TSRMLS_C) TSRMLS_CC)) { zend_clear_exception(TSRMLS_C); ZEPHIR_CALL_METHOD(&_15, this_ptr, "_handleexception", &_19, e); zephir_check_call_status(); if (ZEPHIR_IS_FALSE_IDENTICAL(_15)) { _6 = zephir_fetch_nproperty_this(this_ptr, SL("_finished"), PH_NOISY_CC); if (ZEPHIR_IS_FALSE_IDENTICAL(_6)) { continue; } } else { zephir_throw_exception_debug(e, "phalcon/dispatcher.zep", 550 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } } } if (Z_TYPE_P(eventsManager) == IS_OBJECT) { ZEPHIR_INIT_NVAR(_2); ZVAL_STRING(_2, "dispatch:afterExecuteRoute", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_15, eventsManager, "fire", &_5, _2, this_ptr, value); zephir_check_temp_parameter(_2); zephir_check_call_status(); if (ZEPHIR_IS_FALSE_IDENTICAL(_15)) { continue; } _6 = zephir_fetch_nproperty_this(this_ptr, SL("_finished"), PH_NOISY_CC); if (ZEPHIR_IS_FALSE_IDENTICAL(_6)) { continue; } ZEPHIR_INIT_NVAR(_2); ZVAL_STRING(_2, "dispatch:afterDispatch", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, eventsManager, "fire", &_5, _2, this_ptr); zephir_check_temp_parameter(_2); zephir_check_call_status(); } if ((zephir_method_exists_ex(handler, SS("afterexecuteroute") TSRMLS_CC) == SUCCESS)) { ZEPHIR_CALL_METHOD(&_15, handler, "afterexecuteroute", NULL, this_ptr, value); zephir_check_call_status(); if (ZEPHIR_IS_FALSE_IDENTICAL(_15)) { continue; } _6 = zephir_fetch_nproperty_this(this_ptr, SL("_finished"), PH_NOISY_CC); if (ZEPHIR_IS_FALSE_IDENTICAL(_6)) { continue; } } } if (Z_TYPE_P(eventsManager) == IS_OBJECT) { ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "dispatch:afterDispatchLoop", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, eventsManager, "fire", &_5, _1, this_ptr); zephir_check_temp_parameter(_1); zephir_check_call_status(); } RETURN_CCTOR(handler); }
/** * Updates every record in the resultset * * @param array data * @param \Closure conditionCallback * @return boolean */ PHP_METHOD(Phalcon_Mvc_Model_Resultset, update) { zval *_2$$6 = NULL; zend_object_iterator *_0; zend_bool transaction = 0; int ZEPHIR_LAST_CALL_STATUS; zval *data, *conditionCallback = NULL, *record = NULL, *connection = NULL, *_1$$6 = NULL, *_3$$3 = NULL, *_4$$8 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &data, &conditionCallback); if (!conditionCallback) { conditionCallback = ZEPHIR_GLOBAL(global_null); } ZEPHIR_INIT_VAR(connection); ZVAL_NULL(connection); transaction = 0; _0 = zephir_get_iterator(this_ptr TSRMLS_CC); _0->funcs->rewind(_0 TSRMLS_CC); for (;_0->funcs->valid(_0 TSRMLS_CC) == SUCCESS && !EG(exception); _0->funcs->move_forward(_0 TSRMLS_CC)) { { zval **ZEPHIR_TMP_ITERATOR_PTR; _0->funcs->get_current_data(_0, &ZEPHIR_TMP_ITERATOR_PTR TSRMLS_CC); ZEPHIR_CPY_WRT(record, (*ZEPHIR_TMP_ITERATOR_PTR)); } if (transaction == 0) { if (!((zephir_method_exists_ex(record, SS("getwriteconnection") TSRMLS_CC) == SUCCESS))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "The returned record is not valid", "phalcon/mvc/model/resultset.zep", 414); return; } ZEPHIR_CALL_METHOD(&connection, record, "getwriteconnection", NULL, 0); zephir_check_call_status(); transaction = 1; ZEPHIR_CALL_METHOD(NULL, connection, "begin", NULL, 0); zephir_check_call_status(); } if (Z_TYPE_P(conditionCallback) == IS_OBJECT) { ZEPHIR_INIT_NVAR(_1$$6); ZEPHIR_INIT_NVAR(_2$$6); zephir_create_array(_2$$6, 1, 0 TSRMLS_CC); zephir_array_fast_append(_2$$6, record); ZEPHIR_CALL_USER_FUNC_ARRAY(_1$$6, conditionCallback, _2$$6); zephir_check_call_status(); if (ZEPHIR_IS_FALSE_IDENTICAL(_1$$6)) { continue; } } ZEPHIR_CALL_METHOD(&_3$$3, record, "save", NULL, 0, data); zephir_check_call_status(); if (!(zephir_is_true(_3$$3))) { ZEPHIR_CALL_METHOD(&_4$$8, record, "getmessages", NULL, 0); zephir_check_call_status(); zephir_update_property_this(this_ptr, SL("_errorMessages"), _4$$8 TSRMLS_CC); ZEPHIR_CALL_METHOD(NULL, connection, "rollback", NULL, 0); zephir_check_call_status(); transaction = 0; break; } } _0->funcs->dtor(_0 TSRMLS_CC); if (transaction == 1) { ZEPHIR_CALL_METHOD(NULL, connection, "commit", NULL, 0); zephir_check_call_status(); } RETURN_MM_BOOL(1); }
/** * Validate a set of data according to a set of rules * * @param array|object data * @param object entity * @return Phalcon\Validation\Message\Group */ PHP_METHOD(Phalcon_Validation, validate) { HashTable *_2; HashPosition _1; zend_bool _0; int ZEPHIR_LAST_CALL_STATUS; zval *data = NULL, *entity = NULL, *validators, *messages = NULL, *scope = NULL, *field = NULL, *validator = NULL, *status = NULL, **_3, *_4 = NULL, *_5 = NULL, *_6 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 2, &data, &entity); if (!data) { data = ZEPHIR_GLOBAL(global_null); } if (!entity) { entity = ZEPHIR_GLOBAL(global_null); } ZEPHIR_OBS_VAR(validators); zephir_read_property_this(&validators, this_ptr, SL("_validators"), PH_NOISY_CC); if (Z_TYPE_P(validators) != IS_ARRAY) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_validation_exception_ce, "There are no validators to validate", "phalcon/validation.zep", 83); return; } zephir_update_property_this(this_ptr, SL("_values"), ZEPHIR_GLOBAL(global_null) TSRMLS_CC); ZEPHIR_INIT_VAR(messages); object_init_ex(messages, phalcon_validation_message_group_ce); ZEPHIR_CALL_METHOD(NULL, messages, "__construct", NULL, 173); zephir_check_call_status(); if ((zephir_method_exists_ex(this_ptr, SS("beforevalidation") TSRMLS_CC) == SUCCESS)) { ZEPHIR_CALL_METHOD(&status, this_ptr, "beforevalidation", NULL, 0, data, entity, messages); zephir_check_call_status(); if (ZEPHIR_IS_FALSE_IDENTICAL(status)) { RETURN_CCTOR(status); } } zephir_update_property_this(this_ptr, SL("_messages"), messages TSRMLS_CC); _0 = Z_TYPE_P(data) == IS_ARRAY; if (!(_0)) { _0 = Z_TYPE_P(data) == IS_OBJECT; } if (_0) { zephir_update_property_this(this_ptr, SL("_data"), data TSRMLS_CC); } zephir_is_iterable(validators, &_2, &_1, 0, 0, "phalcon/validation.zep", 138); for ( ; zephir_hash_get_current_data_ex(_2, (void**) &_3, &_1) == SUCCESS ; zephir_hash_move_forward_ex(_2, &_1) ) { ZEPHIR_GET_HVALUE(scope, _3); if (Z_TYPE_P(scope) != IS_ARRAY) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_validation_exception_ce, "The validator scope is not valid", "phalcon/validation.zep", 115); return; } ZEPHIR_OBS_NVAR(field); zephir_array_fetch_long(&field, scope, 0, PH_NOISY, "phalcon/validation.zep", 118 TSRMLS_CC); ZEPHIR_OBS_NVAR(validator); zephir_array_fetch_long(&validator, scope, 1, PH_NOISY, "phalcon/validation.zep", 119 TSRMLS_CC); if (Z_TYPE_P(validator) != IS_OBJECT) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_validation_exception_ce, "One of the validators is not valid", "phalcon/validation.zep", 122); return; } ZEPHIR_CALL_METHOD(&_4, validator, "validate", NULL, 0, this_ptr, field); zephir_check_call_status(); if (ZEPHIR_IS_FALSE_IDENTICAL(_4)) { ZEPHIR_INIT_NVAR(_6); ZVAL_STRING(_6, "cancelOnFail", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_5, validator, "getoption", NULL, 0, _6); zephir_check_temp_parameter(_6); zephir_check_call_status(); if (zephir_is_true(_5)) { break; } } } ZEPHIR_OBS_NVAR(messages); zephir_read_property_this(&messages, this_ptr, SL("_messages"), PH_NOISY_CC); if ((zephir_method_exists_ex(this_ptr, SS("aftervalidation") TSRMLS_CC) == SUCCESS)) { ZEPHIR_CALL_METHOD(NULL, this_ptr, "aftervalidation", NULL, 0, data, entity, messages); zephir_check_call_status(); } RETURN_CCTOR(messages); }
/** * Gets the a value to validate in the array/object data source * * @param string field * @return mixed */ PHP_METHOD(Phalcon_Validation, getValue) { zend_bool _0$$10; zephir_fcall_cache_entry *_1 = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; zval *field_param = NULL, *entity = NULL, *method = NULL, *value = NULL, *data = NULL, *values = NULL, *filters = NULL, *fieldFilters = NULL, *dependencyInjector = NULL, *filterService = NULL, *camelizedField = NULL, *_2$$20, *_3$$20 = NULL, *_4$$28 = NULL; zval *field = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &field_param); zephir_get_strval(field, field_param); ZEPHIR_OBS_VAR(entity); zephir_read_property_this(&entity, this_ptr, SL("_entity"), PH_NOISY_CC); if (Z_TYPE_P(entity) == IS_OBJECT) { ZEPHIR_INIT_VAR(camelizedField); zephir_camelize(camelizedField, field, NULL ); ZEPHIR_INIT_VAR(method); ZEPHIR_CONCAT_SV(method, "get", camelizedField); if ((zephir_method_exists(entity, method TSRMLS_CC) == SUCCESS)) { ZEPHIR_CALL_METHOD_ZVAL(&value, entity, method, NULL, 0); zephir_check_call_status(); } else { if ((zephir_method_exists_ex(entity, SS("readattribute") TSRMLS_CC) == SUCCESS)) { ZEPHIR_CALL_METHOD(&value, entity, "readattribute", NULL, 0, field); zephir_check_call_status(); } else { ZEPHIR_INIT_NVAR(value); if (zephir_isset_property_zval(entity, field TSRMLS_CC)) { zephir_read_property_zval(&value, entity, field, PH_NOISY_CC); } else { ZVAL_NULL(value); } } } } else { ZEPHIR_OBS_VAR(data); zephir_read_property_this(&data, this_ptr, SL("_data"), PH_NOISY_CC); _0$$10 = Z_TYPE_P(data) != IS_ARRAY; if (_0$$10) { _0$$10 = Z_TYPE_P(data) != IS_OBJECT; } if (_0$$10) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_validation_exception_ce, "There is no data to validate", "phalcon/validation.zep", 499); return; } ZEPHIR_OBS_VAR(values); zephir_read_property_this(&values, this_ptr, SL("_values"), PH_NOISY_CC); ZEPHIR_OBS_NVAR(value); if (zephir_array_isset_fetch(&value, values, field, 0 TSRMLS_CC)) { RETURN_CCTOR(value); } ZEPHIR_INIT_NVAR(value); ZVAL_NULL(value); if (Z_TYPE_P(data) == IS_ARRAY) { if (zephir_array_isset(data, field)) { ZEPHIR_OBS_NVAR(value); zephir_array_fetch(&value, data, field, PH_NOISY, "phalcon/validation.zep", 511 TSRMLS_CC); } } else { if (Z_TYPE_P(data) == IS_OBJECT) { if (zephir_isset_property_zval(data, field TSRMLS_CC)) { ZEPHIR_OBS_NVAR(value); zephir_read_property_zval(&value, data, field, PH_NOISY_CC); } } } } if (Z_TYPE_P(value) == IS_NULL) { RETURN_MM_NULL(); } ZEPHIR_OBS_VAR(filters); zephir_read_property_this(&filters, this_ptr, SL("_filters"), PH_NOISY_CC); ZEPHIR_OBS_VAR(fieldFilters); if (zephir_array_isset_fetch(&fieldFilters, filters, field, 0 TSRMLS_CC)) { if (zephir_is_true(fieldFilters)) { ZEPHIR_CALL_METHOD(&dependencyInjector, this_ptr, "getdi", NULL, 0); zephir_check_call_status(); if (Z_TYPE_P(dependencyInjector) != IS_OBJECT) { ZEPHIR_CALL_CE_STATIC(&dependencyInjector, phalcon_di_ce, "getdefault", &_1, 1); zephir_check_call_status(); if (Z_TYPE_P(dependencyInjector) != IS_OBJECT) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_validation_exception_ce, "A dependency injector is required to obtain the 'filter' service", "phalcon/validation.zep", 536); return; } } ZEPHIR_INIT_VAR(_2$$20); ZVAL_STRING(_2$$20, "filter", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&filterService, dependencyInjector, "getshared", NULL, 0, _2$$20); zephir_check_temp_parameter(_2$$20); zephir_check_call_status(); if (Z_TYPE_P(filterService) != IS_OBJECT) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_validation_exception_ce, "Returned 'filter' service is invalid", "phalcon/validation.zep", 542); return; } ZEPHIR_CALL_METHOD(&_3$$20, filterService, "sanitize", NULL, 0, value, fieldFilters); zephir_check_call_status(); ZEPHIR_CPY_WRT(value, _3$$20); if (Z_TYPE_P(entity) == IS_OBJECT) { ZEPHIR_INIT_NVAR(method); ZEPHIR_CONCAT_SV(method, "set", camelizedField); if ((zephir_method_exists(entity, method TSRMLS_CC) == SUCCESS)) { ZEPHIR_CALL_METHOD_ZVAL(NULL, entity, method, NULL, 0, value); zephir_check_call_status(); } else { if ((zephir_method_exists_ex(entity, SS("writeattribute") TSRMLS_CC) == SUCCESS)) { ZEPHIR_CALL_METHOD(NULL, entity, "writeattribute", NULL, 0, field, value); zephir_check_call_status(); } else { ZEPHIR_CALL_FUNCTION(&_4$$28, "property_exists", NULL, 329, entity, field); zephir_check_call_status(); if (zephir_is_true(_4$$28)) { zephir_update_property_zval_zval(entity, field, value TSRMLS_CC); } } } } RETURN_CCTOR(value); } } if (Z_TYPE_P(entity) != IS_OBJECT) { zephir_update_property_array(this_ptr, SL("_values"), field, value TSRMLS_CC); } RETURN_CCTOR(value); }
/** * Validate a set of data according to a set of rules * * @param array|object data * @param object entity * @return \Phalcon\Validation\Message\Group */ PHP_METHOD(Phalcon_Validation, validate) { zend_bool _0$$7; HashTable *_2, *_10; HashPosition _1, _9; zephir_fcall_cache_entry *_5 = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; zval *data = NULL, *entity = NULL, *validators = NULL, *messages = NULL, *scope = NULL, *field = NULL, *validator = NULL, *status = NULL, *combinedFieldsValidators = NULL, **_3, **_11, *_4$$10 = NULL, *_6$$10 = NULL, *_7$$14 = NULL, *_8$$14 = NULL, *_12$$16 = NULL, *_13$$16 = NULL, *_14$$20 = NULL, *_15$$20 = NULL, *_16$$22; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 2, &data, &entity); if (!data) { data = ZEPHIR_GLOBAL(global_null); } if (!entity) { entity = ZEPHIR_GLOBAL(global_null); } ZEPHIR_OBS_VAR(validators); zephir_read_property_this(&validators, this_ptr, SL("_validators"), PH_NOISY_CC); ZEPHIR_OBS_VAR(combinedFieldsValidators); zephir_read_property_this(&combinedFieldsValidators, this_ptr, SL("_combinedFieldsValidators"), PH_NOISY_CC); if (Z_TYPE_P(validators) != IS_ARRAY) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_validation_exception_ce, "There are no validators to validate", "phalcon/validation.zep", 94); return; } zephir_update_property_this(getThis(), SL("_values"), ZEPHIR_GLOBAL(global_null) TSRMLS_CC); ZEPHIR_INIT_VAR(messages); object_init_ex(messages, phalcon_validation_message_group_ce); ZEPHIR_CALL_METHOD(NULL, messages, "__construct", NULL, 3); zephir_check_call_status(); if (Z_TYPE_P(entity) != IS_NULL) { ZEPHIR_CALL_METHOD(NULL, this_ptr, "setentity", NULL, 0, entity); zephir_check_call_status(); } if ((zephir_method_exists_ex(this_ptr, SS("beforevalidation") TSRMLS_CC) == SUCCESS)) { ZEPHIR_CALL_METHOD(&status, this_ptr, "beforevalidation", NULL, 0, data, entity, messages); zephir_check_call_status(); if (ZEPHIR_IS_FALSE_IDENTICAL(status)) { RETURN_CCTOR(status); } } zephir_update_property_this(getThis(), SL("_messages"), messages TSRMLS_CC); if (Z_TYPE_P(data) != IS_NULL) { _0$$7 = Z_TYPE_P(data) == IS_ARRAY; if (!(_0$$7)) { _0$$7 = Z_TYPE_P(data) == IS_OBJECT; } if (_0$$7) { zephir_update_property_this(getThis(), SL("_data"), data TSRMLS_CC); } else { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_validation_exception_ce, "Invalid data to validate", "phalcon/validation.zep", 127); return; } } zephir_is_iterable(validators, &_2, &_1, 0, 0, "phalcon/validation.zep", 161); for ( ; zend_hash_get_current_data_ex(_2, (void**) &_3, &_1) == SUCCESS ; zend_hash_move_forward_ex(_2, &_1) ) { ZEPHIR_GET_HVALUE(scope, _3); if (Z_TYPE_P(scope) != IS_ARRAY) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_validation_exception_ce, "The validator scope is not valid", "phalcon/validation.zep", 134); return; } ZEPHIR_OBS_NVAR(field); zephir_array_fetch_long(&field, scope, 0, PH_NOISY, "phalcon/validation.zep", 137 TSRMLS_CC); ZEPHIR_OBS_NVAR(validator); zephir_array_fetch_long(&validator, scope, 1, PH_NOISY, "phalcon/validation.zep", 138 TSRMLS_CC); if (Z_TYPE_P(validator) != IS_OBJECT) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_validation_exception_ce, "One of the validators is not valid", "phalcon/validation.zep", 141); return; } ZEPHIR_CALL_METHOD(&_4$$10, this_ptr, "prechecking", &_5, 0, field, validator); zephir_check_call_status(); if (zephir_is_true(_4$$10)) { continue; } ZEPHIR_CALL_METHOD(&_6$$10, validator, "validate", NULL, 0, this_ptr, field); zephir_check_call_status(); if (ZEPHIR_IS_FALSE_IDENTICAL(_6$$10)) { ZEPHIR_INIT_NVAR(_8$$14); ZVAL_STRING(_8$$14, "cancelOnFail", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_7$$14, validator, "getoption", NULL, 0, _8$$14); zephir_check_temp_parameter(_8$$14); zephir_check_call_status(); if (zephir_is_true(_7$$14)) { break; } } } zephir_is_iterable(combinedFieldsValidators, &_10, &_9, 0, 0, "phalcon/validation.zep", 193); for ( ; zend_hash_get_current_data_ex(_10, (void**) &_11, &_9) == SUCCESS ; zend_hash_move_forward_ex(_10, &_9) ) { ZEPHIR_GET_HVALUE(scope, _11); if (Z_TYPE_P(scope) != IS_ARRAY) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_validation_exception_ce, "The validator scope is not valid", "phalcon/validation.zep", 163); return; } ZEPHIR_OBS_NVAR(field); zephir_array_fetch_long(&field, scope, 0, PH_NOISY, "phalcon/validation.zep", 166 TSRMLS_CC); ZEPHIR_OBS_NVAR(validator); zephir_array_fetch_long(&validator, scope, 1, PH_NOISY, "phalcon/validation.zep", 167 TSRMLS_CC); if (Z_TYPE_P(validator) != IS_OBJECT) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_validation_exception_ce, "One of the validators is not valid", "phalcon/validation.zep", 170); return; } ZEPHIR_CALL_METHOD(&_12$$16, this_ptr, "prechecking", &_5, 0, field, validator); zephir_check_call_status(); if (zephir_is_true(_12$$16)) { continue; } ZEPHIR_CALL_METHOD(&_13$$16, validator, "validate", NULL, 0, this_ptr, field); zephir_check_call_status(); if (ZEPHIR_IS_FALSE_IDENTICAL(_13$$16)) { ZEPHIR_INIT_NVAR(_15$$20); ZVAL_STRING(_15$$20, "cancelOnFail", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_14$$20, validator, "getoption", NULL, 0, _15$$20); zephir_check_temp_parameter(_15$$20); zephir_check_call_status(); if (zephir_is_true(_14$$20)) { break; } } } if ((zephir_method_exists_ex(this_ptr, SS("aftervalidation") TSRMLS_CC) == SUCCESS)) { _16$$22 = zephir_fetch_nproperty_this(this_ptr, SL("_messages"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(NULL, this_ptr, "aftervalidation", NULL, 0, data, entity, _16$$22); zephir_check_call_status(); } RETURN_MM_MEMBER(getThis(), "_messages"); }
/** * Updates every record in the resultset * * @param array data * @param \Closure conditionCallback * @return boolean */ PHP_METHOD(Phalcon_Mvc_Model_Resultset, update) { zval *_4$$6 = NULL; zend_bool transaction = 0; zephir_fcall_cache_entry *_1 = NULL, *_2 = NULL, *_5 = NULL; int ZEPHIR_LAST_CALL_STATUS; zval *data, *conditionCallback = NULL, *record = NULL, *connection = NULL, *_0 = NULL, *_3$$6 = NULL, *_6$$3 = NULL, *_7$$8 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &data, &conditionCallback); if (!conditionCallback) { conditionCallback = ZEPHIR_GLOBAL(global_null); } ZEPHIR_INIT_VAR(connection); ZVAL_NULL(connection); transaction = 0; ZEPHIR_CALL_METHOD(NULL, this_ptr, "rewind", NULL, 78); zephir_check_call_status(); while (1) { ZEPHIR_CALL_METHOD(&_0, this_ptr, "valid", &_1, 0); zephir_check_call_status(); if (!(zephir_is_true(_0))) { break; } ZEPHIR_CALL_METHOD(&record, this_ptr, "current", &_2, 0); zephir_check_call_status(); if (transaction == 0) { if (!((zephir_method_exists_ex(record, SS("getwriteconnection") TSRMLS_CC) == SUCCESS))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "The returned record is not valid", "phalcon/mvc/model/resultset.zep", 434); return; } ZEPHIR_CALL_METHOD(&connection, record, "getwriteconnection", NULL, 0); zephir_check_call_status(); transaction = 1; ZEPHIR_CALL_METHOD(NULL, connection, "begin", NULL, 0); zephir_check_call_status(); } if (Z_TYPE_P(conditionCallback) == IS_OBJECT) { ZEPHIR_INIT_NVAR(_3$$6); ZEPHIR_INIT_NVAR(_4$$6); zephir_create_array(_4$$6, 1, 0 TSRMLS_CC); zephir_array_fast_append(_4$$6, record); ZEPHIR_CALL_USER_FUNC_ARRAY(_3$$6, conditionCallback, _4$$6); zephir_check_call_status(); if (ZEPHIR_IS_FALSE_IDENTICAL(_3$$6)) { ZEPHIR_CALL_METHOD(NULL, this_ptr, "next", &_5, 0); zephir_check_call_status(); continue; } } ZEPHIR_CALL_METHOD(&_6$$3, record, "save", NULL, 0, data); zephir_check_call_status(); if (!(zephir_is_true(_6$$3))) { ZEPHIR_CALL_METHOD(&_7$$8, record, "getmessages", NULL, 0); zephir_check_call_status(); zephir_update_property_this(this_ptr, SL("_errorMessages"), _7$$8 TSRMLS_CC); ZEPHIR_CALL_METHOD(NULL, connection, "rollback", NULL, 0); zephir_check_call_status(); transaction = 0; break; } ZEPHIR_CALL_METHOD(NULL, this_ptr, "next", &_5, 0); zephir_check_call_status(); } if (transaction == 1) { ZEPHIR_CALL_METHOD(NULL, connection, "commit", NULL, 0); zephir_check_call_status(); } RETURN_MM_BOOL(1); }
/** * Internal validations, if it returns true, then skip the current validator */ PHP_METHOD(Phalcon_Validation, preChecking) { HashTable *_1$$3, *_7$$9; HashPosition _0$$3, _6$$9; zephir_fcall_cache_entry *_3 = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; zval *field, *validator, *singleField = NULL, *allowEmpty = NULL, *emptyValue = NULL, *value = NULL, *result = NULL, **_2$$3, *_4$$6, *_5$$6, **_8$$9; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &field, &validator); if (Z_TYPE_P(field) == IS_ARRAY) { zephir_is_iterable(field, &_1$$3, &_0$$3, 0, 0, "phalcon/validation.zep", 590); for ( ; zend_hash_get_current_data_ex(_1$$3, (void**) &_2$$3, &_0$$3) == SUCCESS ; zend_hash_move_forward_ex(_1$$3, &_0$$3) ) { ZEPHIR_GET_HVALUE(singleField, _2$$3); ZEPHIR_CALL_METHOD(&result, this_ptr, "prechecking", &_3, 469, singleField, validator); zephir_check_call_status(); if (zephir_is_true(result)) { RETURN_CCTOR(result); } } } else { ZEPHIR_INIT_VAR(_4$$6); ZVAL_STRING(_4$$6, "allowEmpty", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_VAR(_5$$6); ZVAL_BOOL(_5$$6, 0); ZEPHIR_CALL_METHOD(&allowEmpty, validator, "getoption", NULL, 0, _4$$6, _5$$6); zephir_check_temp_parameter(_4$$6); zephir_check_call_status(); if (zephir_is_true(allowEmpty)) { if ((zephir_method_exists_ex(validator, SS("isallowempty") TSRMLS_CC) == SUCCESS)) { ZEPHIR_RETURN_CALL_METHOD(validator, "isallowempty", NULL, 0, this_ptr, field); zephir_check_call_status(); RETURN_MM(); } ZEPHIR_CALL_METHOD(&value, this_ptr, "getvalue", NULL, 0, field); zephir_check_call_status(); if (Z_TYPE_P(allowEmpty) == IS_ARRAY) { zephir_is_iterable(allowEmpty, &_7$$9, &_6$$9, 0, 0, "phalcon/validation.zep", 604); for ( ; zend_hash_get_current_data_ex(_7$$9, (void**) &_8$$9, &_6$$9) == SUCCESS ; zend_hash_move_forward_ex(_7$$9, &_6$$9) ) { ZEPHIR_GET_HVALUE(emptyValue, _8$$9); if (ZEPHIR_IS_IDENTICAL(emptyValue, value)) { RETURN_MM_BOOL(1); } } RETURN_MM_BOOL(0); } RETURN_MM_BOOL(ZEPHIR_IS_EMPTY(value)); } } RETURN_MM_BOOL(0); }
/** * Initialize the metadata for certain table */ PHP_METHOD(Phalcon_Mvc_Model_MetaData, _initialize) { zend_long ZEPHIR_LAST_CALL_STATUS; zval *model, model_sub, *key, key_sub, *table, table_sub, *schema, schema_sub, strategy, className, metaData, data, modelMetadata, modelColumnMap, dependencyInjector, keyName, prefixKey, _2, _0$$8, _1$$8; zval *this_ptr = getThis(); ZVAL_UNDEF(&model_sub); ZVAL_UNDEF(&key_sub); ZVAL_UNDEF(&table_sub); ZVAL_UNDEF(&schema_sub); ZVAL_UNDEF(&strategy); ZVAL_UNDEF(&className); ZVAL_UNDEF(&metaData); ZVAL_UNDEF(&data); ZVAL_UNDEF(&modelMetadata); ZVAL_UNDEF(&modelColumnMap); ZVAL_UNDEF(&dependencyInjector); ZVAL_UNDEF(&keyName); ZVAL_UNDEF(&prefixKey); ZVAL_UNDEF(&_2); ZVAL_UNDEF(&_0$$8); ZVAL_UNDEF(&_1$$8); ZEPHIR_MM_GROW(); zephir_fetch_params(1, 4, 0, &model, &key, &table, &schema); ZEPHIR_INIT_VAR(&strategy); ZVAL_NULL(&strategy); ZEPHIR_INIT_VAR(&className); zephir_get_class(&className, model, 0 TSRMLS_CC); if (Z_TYPE_P(key) != IS_NULL) { ZEPHIR_OBS_VAR(&metaData); zephir_read_property(&metaData, this_ptr, SL("_metaData"), PH_NOISY_CC); if (!(zephir_array_isset(&metaData, key))) { ZEPHIR_INIT_VAR(&prefixKey); ZEPHIR_CONCAT_SV(&prefixKey, "meta-", key); ZEPHIR_CALL_METHOD(&data, this_ptr, "read", NULL, 0, &prefixKey); zephir_check_call_status(); if (Z_TYPE_P(&data) != IS_NULL) { zephir_update_property_array(this_ptr, SL("_metaData"), key, &data TSRMLS_CC); } else { if ((zephir_method_exists_ex(model, SL("metadata") TSRMLS_CC) == SUCCESS)) { ZEPHIR_CALL_METHOD(&modelMetadata, model, "metadata", NULL, 0); zephir_check_call_status(); if (Z_TYPE_P(&modelMetadata) != IS_ARRAY) { ZEPHIR_INIT_VAR(&_0$$8); object_init_ex(&_0$$8, phalcon_mvc_model_exception_ce); ZEPHIR_INIT_VAR(&_1$$8); ZEPHIR_CONCAT_SV(&_1$$8, "Invalid meta-data for model ", &className); ZEPHIR_CALL_METHOD(NULL, &_0$$8, "__construct", NULL, 4, &_1$$8); zephir_check_call_status(); zephir_throw_exception_debug(&_0$$8, "phalcon/mvc/model/metadata.zep", 113 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } } else { ZEPHIR_OBS_VAR(&dependencyInjector); zephir_read_property(&dependencyInjector, this_ptr, SL("_dependencyInjector"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(&strategy, this_ptr, "getstrategy", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&modelMetadata, &strategy, "getmetadata", NULL, 0, model, &dependencyInjector); zephir_check_call_status(); } zephir_update_property_array(this_ptr, SL("_metaData"), key, &modelMetadata TSRMLS_CC); ZEPHIR_CALL_METHOD(NULL, this_ptr, "write", NULL, 0, &prefixKey, &modelMetadata); zephir_check_call_status(); } } } if (!(ZEPHIR_GLOBAL(orm).column_renaming)) { RETURN_MM_NULL(); } ZEPHIR_INIT_VAR(&keyName); zephir_fast_strtolower(&keyName, &className); zephir_read_property(&_2, this_ptr, SL("_columnMap"), PH_NOISY_CC | PH_READONLY); if (zephir_array_isset(&_2, &keyName)) { RETURN_MM_NULL(); } ZEPHIR_INIT_NVAR(&prefixKey); ZEPHIR_CONCAT_SV(&prefixKey, "map-", &keyName); ZEPHIR_CALL_METHOD(&data, this_ptr, "read", NULL, 0, &prefixKey); zephir_check_call_status(); if (Z_TYPE_P(&data) != IS_NULL) { zephir_update_property_array(this_ptr, SL("_columnMap"), &keyName, &data TSRMLS_CC); RETURN_MM_NULL(); } if (Z_TYPE_P(&strategy) != IS_OBJECT) { ZEPHIR_OBS_NVAR(&dependencyInjector); zephir_read_property(&dependencyInjector, this_ptr, SL("_dependencyInjector"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(&strategy, this_ptr, "getstrategy", NULL, 0); zephir_check_call_status(); } ZEPHIR_CALL_METHOD(&modelColumnMap, &strategy, "getcolumnmaps", NULL, 0, model, &dependencyInjector); zephir_check_call_status(); zephir_update_property_array(this_ptr, SL("_columnMap"), &keyName, &modelColumnMap TSRMLS_CC); ZEPHIR_CALL_METHOD(NULL, this_ptr, "write", NULL, 0, &prefixKey, &modelColumnMap); zephir_check_call_status(); ZEPHIR_MM_RESTORE(); }