/** * Magic method to pass variables to the views * *<code> * $this->view->products = $products; *</code> */ PHP_METHOD(Phalcon_Mvc_View_Simple, __set) { zval *key_param = NULL, *value; zval *key = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &key_param, &value); if (UNEXPECTED(Z_TYPE_P(key_param) != IS_STRING && Z_TYPE_P(key_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'key' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (EXPECTED(Z_TYPE_P(key_param) == IS_STRING)) { zephir_get_strval(key, key_param); } else { ZEPHIR_INIT_VAR(key); ZVAL_EMPTY_STRING(key); } zephir_update_property_array(this_ptr, SL("_viewParams"), key, value TSRMLS_CC); ZEPHIR_MM_RESTORE(); }
/** * Sets a value in the session bag * *<code> * $user->set('name', 'Kimbra'); *</code> * * @param string property * @param string value */ PHP_METHOD(Phalcon_Session_Bag, set) { int ZEPHIR_LAST_CALL_STATUS; zval *property_param = NULL, *value, *_0, *_1, *_2, *_3; zval *property = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &property_param, &value); if (unlikely(Z_TYPE_P(property_param) != IS_STRING && Z_TYPE_P(property_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'property' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(property_param) == IS_STRING)) { zephir_get_strval(property, property_param); } else { ZEPHIR_INIT_VAR(property); ZVAL_EMPTY_STRING(property); } _0 = zephir_fetch_nproperty_this(this_ptr, SL("_initalized"), PH_NOISY_CC); if (ZEPHIR_IS_FALSE_IDENTICAL(_0)) { ZEPHIR_CALL_METHOD(NULL, this_ptr, "initialize", NULL); zephir_check_call_status(); } zephir_update_property_array(this_ptr, SL("_data"), property, value TSRMLS_CC); _1 = zephir_fetch_nproperty_this(this_ptr, SL("_session"), PH_NOISY_CC); _2 = zephir_fetch_nproperty_this(this_ptr, SL("_name"), PH_NOISY_CC); _3 = zephir_fetch_nproperty_this(this_ptr, SL("_data"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(NULL, _1, "set", NULL, _2, _3); zephir_check_call_status(); ZEPHIR_MM_RESTORE(); }
/** * Adds a converter to perform an additional transformation for certain parameter */ PHP_METHOD(Phalcon_Mvc_Router_Route, convert) { zval *name_param = NULL, *converter; zval *name = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &name_param, &converter); if (unlikely(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 (likely(Z_TYPE_P(name_param) == IS_STRING)) { zephir_get_strval(name, name_param); } else { ZEPHIR_INIT_VAR(name); ZVAL_EMPTY_STRING(name); } zephir_update_property_array(this_ptr, SL("_converters"), name, converter TSRMLS_CC); RETURN_THIS(); }
/** * Sets an element in the registry */ PHP_METHOD(Phalcon_Registry, offsetSet) { zval *offset_param = NULL, *value; zval *offset = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &offset_param, &value); if (unlikely(Z_TYPE_P(offset_param) != IS_STRING && Z_TYPE_P(offset_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'offset' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(offset_param) == IS_STRING)) { zephir_get_strval(offset, offset_param); } else { ZEPHIR_INIT_VAR(offset); ZVAL_EMPTY_STRING(offset); } zephir_update_property_array(this_ptr, SL("_data"), offset, value TSRMLS_CC); ZEPHIR_MM_RESTORE(); }
PHP_METHOD(Yb_Factory_Shared, __get) { int ZEPHIR_LAST_CALL_STATUS; zval *name_param = NULL, *production = NULL, *_0, *_1; zval *name = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &name_param); zephir_get_strval(name, name_param); ZEPHIR_OBS_VAR(production); _0 = zephir_fetch_nproperty_this(this_ptr, SL("productions"), PH_NOISY_CC); if (zephir_array_isset_fetch(&production, _0, name, 0 TSRMLS_CC)) { RETURN_CCTOR(production); } _1 = zephir_fetch_nproperty_this(this_ptr, SL("factory"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(&production, _1, "__get", NULL, 0, name); zephir_check_call_status(); zephir_update_property_array(this_ptr, SL("productions"), name, production TSRMLS_CC); RETURN_CCTOR(production); }
/** * Detach the listener from the events manager * * @param string eventType * @param object handler */ PHP_METHOD(Phalcon_Events_Manager, detach) { zephir_fcall_cache_entry *_3 = NULL, *_4 = NULL, *_8 = NULL; int ZEPHIR_LAST_CALL_STATUS; zval *eventType_param = NULL, *handler, *priorityQueue = NULL, *newPriorityQueue = NULL, *key = NULL, *data = NULL, *_0, *_1$$5 = NULL, *_2$$5 = NULL, *_5$$6, *_6$$7, *_7$$7; zval *eventType = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &eventType_param, &handler); if (unlikely(Z_TYPE_P(eventType_param) != IS_STRING && Z_TYPE_P(eventType_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'eventType' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(eventType_param) == IS_STRING)) { zephir_get_strval(eventType, eventType_param); } else { ZEPHIR_INIT_VAR(eventType); ZVAL_EMPTY_STRING(eventType); } if (Z_TYPE_P(handler) != IS_OBJECT) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_events_exception_ce, "Event handler must be an Object", "phalcon/events/manager.zep", 99); return; } ZEPHIR_OBS_VAR(priorityQueue); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_events"), PH_NOISY_CC); if (zephir_array_isset_fetch(&priorityQueue, _0, eventType, 0 TSRMLS_CC)) { if (Z_TYPE_P(priorityQueue) == IS_OBJECT) { ZEPHIR_INIT_VAR(newPriorityQueue); object_init_ex(newPriorityQueue, spl_ce_SplPriorityQueue); if (zephir_has_constructor(newPriorityQueue TSRMLS_CC)) { ZEPHIR_CALL_METHOD(NULL, newPriorityQueue, "__construct", NULL, 0); zephir_check_call_status(); } ZEPHIR_INIT_VAR(_1$$5); ZVAL_LONG(_1$$5, 1); ZEPHIR_CALL_METHOD(NULL, newPriorityQueue, "setextractflags", NULL, 190, _1$$5); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_1$$5); ZVAL_LONG(_1$$5, 3); ZEPHIR_CALL_METHOD(NULL, priorityQueue, "setextractflags", NULL, 0, _1$$5); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, priorityQueue, "top", NULL, 0); zephir_check_call_status(); while (1) { ZEPHIR_CALL_METHOD(&_2$$5, priorityQueue, "valid", NULL, 0); zephir_check_call_status(); if (!(zephir_is_true(_2$$5))) { break; } ZEPHIR_CALL_METHOD(&data, priorityQueue, "current", &_3, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, priorityQueue, "next", &_4, 0); zephir_check_call_status(); zephir_array_fetch_string(&_5$$6, data, SL("data"), PH_NOISY | PH_READONLY, "phalcon/events/manager.zep", 116 TSRMLS_CC); if (!ZEPHIR_IS_IDENTICAL(_5$$6, handler)) { zephir_array_fetch_string(&_6$$7, data, SL("data"), PH_NOISY | PH_READONLY, "phalcon/events/manager.zep", 117 TSRMLS_CC); zephir_array_fetch_string(&_7$$7, data, SL("priority"), PH_NOISY | PH_READONLY, "phalcon/events/manager.zep", 117 TSRMLS_CC); ZEPHIR_CALL_METHOD(NULL, newPriorityQueue, "insert", &_8, 191, _6$$7, _7$$7); zephir_check_call_status(); } } zephir_update_property_array(this_ptr, SL("_events"), eventType, newPriorityQueue TSRMLS_CC); } else { ZEPHIR_CALL_FUNCTION(&key, "array_search", NULL, 192, handler, priorityQueue, ZEPHIR_GLOBAL(global_true)); zephir_check_call_status(); if (!ZEPHIR_IS_FALSE_IDENTICAL(key)) { zephir_array_unset(&priorityQueue, key, PH_SEPARATE); } zephir_update_property_array(this_ptr, SL("_events"), eventType, priorityQueue TSRMLS_CC); } } ZEPHIR_MM_RESTORE(); }
/** * Sets the conditions parameter in the criteria */ PHP_METHOD(Phalcon_Mvc_Model_Criteria, where) { zval *conditions_param = NULL, *bindParams = NULL, *bindTypes = NULL, *currentBindParams = NULL, *currentBindTypes = NULL, *_0, *_1$$3, *_2$$4, *_3$$4, *_4$$5, *_5$$6, *_6$$7, *_7$$7, *_8$$8; zval *conditions = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 2, &conditions_param, &bindParams, &bindTypes); if (unlikely(Z_TYPE_P(conditions_param) != IS_STRING && Z_TYPE_P(conditions_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'conditions' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(conditions_param) == IS_STRING)) { zephir_get_strval(conditions, conditions_param); } else { ZEPHIR_INIT_VAR(conditions); ZVAL_EMPTY_STRING(conditions); } if (!bindParams) { bindParams = ZEPHIR_GLOBAL(global_null); } if (!bindTypes) { bindTypes = ZEPHIR_GLOBAL(global_null); } ZEPHIR_INIT_VAR(_0); ZVAL_STRING(_0, "conditions", 1); zephir_update_property_array(this_ptr, SL("_params"), _0, conditions TSRMLS_CC); if (Z_TYPE_P(bindParams) == IS_ARRAY) { ZEPHIR_OBS_VAR(currentBindParams); _1$$3 = zephir_fetch_nproperty_this(this_ptr, SL("_params"), PH_NOISY_CC); if (zephir_array_isset_string_fetch(¤tBindParams, _1$$3, SS("bind"), 0 TSRMLS_CC)) { ZEPHIR_INIT_VAR(_2$$4); zephir_fast_array_merge(_2$$4, &(currentBindParams), &(bindParams) TSRMLS_CC); ZEPHIR_INIT_VAR(_3$$4); ZVAL_STRING(_3$$4, "bind", 1); zephir_update_property_array(this_ptr, SL("_params"), _3$$4, _2$$4 TSRMLS_CC); } else { ZEPHIR_INIT_VAR(_4$$5); ZVAL_STRING(_4$$5, "bind", 1); zephir_update_property_array(this_ptr, SL("_params"), _4$$5, bindParams TSRMLS_CC); } } if (Z_TYPE_P(bindTypes) == IS_ARRAY) { ZEPHIR_OBS_VAR(currentBindTypes); _5$$6 = zephir_fetch_nproperty_this(this_ptr, SL("_params"), PH_NOISY_CC); if (zephir_array_isset_string_fetch(¤tBindTypes, _5$$6, SS("bindTypes"), 0 TSRMLS_CC)) { ZEPHIR_INIT_VAR(_6$$7); zephir_fast_array_merge(_6$$7, &(currentBindTypes), &(bindTypes) TSRMLS_CC); ZEPHIR_INIT_VAR(_7$$7); ZVAL_STRING(_7$$7, "bindTypes", 1); zephir_update_property_array(this_ptr, SL("_params"), _7$$7, _6$$7 TSRMLS_CC); } else { ZEPHIR_INIT_VAR(_8$$8); ZVAL_STRING(_8$$8, "bindTypes", 1); zephir_update_property_array(this_ptr, SL("_params"), _8$$8, bindTypes TSRMLS_CC); } } RETURN_THIS(); }
/** * 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(); }
/** * Unregisters one or all listeners for an event. * * @param string|\Xpl\Event\Event event Event ID or object. * @param callable callback [Optional] Callback to remove. If no callback is given, * then all of the event's listeners are removed. * @return \Xpl\Event\Manager * * @throws \InvalidArgumentException if event is not a string or Event instance. */ PHP_METHOD(Xpl_Event_Manager, off) { HashTable *_6$$8; HashPosition _5$$8; int ZEPHIR_LAST_CALL_STATUS; zval *event, *callback = NULL, *id = NULL, *listeners = NULL, *_4, *_0$$4, *_1$$5, *_2$$5, *_3$$5, *i$$8 = NULL, *listener$$8 = NULL, **_7$$8, *_8$$9 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &event, &callback); if (!callback) { callback = ZEPHIR_GLOBAL(global_null); } if (Z_TYPE_P(event) == IS_STRING) { ZEPHIR_CPY_WRT(id, event); } else if (zephir_instance_of_ev(event, xpl_event_event_ce TSRMLS_CC)) { ZEPHIR_OBS_VAR(_0$$4); zephir_read_property(&_0$$4, event, SL("id"), PH_NOISY_CC); ZEPHIR_CPY_WRT(id, _0$$4); } else { ZEPHIR_INIT_VAR(_1$$5); object_init_ex(_1$$5, spl_ce_InvalidArgumentException); ZEPHIR_INIT_VAR(_2$$5); zephir_gettype(_2$$5, event TSRMLS_CC); ZEPHIR_INIT_VAR(_3$$5); ZEPHIR_CONCAT_SV(_3$$5, "Event must be string or instance of Event, given: ", _2$$5); ZEPHIR_CALL_METHOD(NULL, _1$$5, "__construct", NULL, 5, _3$$5); zephir_check_call_status(); zephir_throw_exception_debug(_1$$5, "xpl/event/manager.zep", 118 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } ZEPHIR_OBS_VAR(listeners); _4 = zephir_fetch_nproperty_this(this_ptr, SL("listeners"), PH_NOISY_CC); if (zephir_array_isset_fetch(&listeners, _4, id, 0 TSRMLS_CC)) { if (Z_TYPE_P(callback) == IS_NULL) { zephir_array_unset(&listeners, id, PH_SEPARATE); } else { zephir_is_iterable(listeners, &_6$$8, &_5$$8, 1, 0, "xpl/event/manager.zep", 137); for ( ; zephir_hash_get_current_data_ex(_6$$8, (void**) &_7$$8, &_5$$8) == SUCCESS ; zephir_hash_move_forward_ex(_6$$8, &_5$$8) ) { ZEPHIR_GET_HMKEY(i$$8, _6$$8, _5$$8); ZEPHIR_GET_HVALUE(listener$$8, _7$$8); ZEPHIR_OBS_NVAR(_8$$9); zephir_read_property(&_8$$9, listener$$8, SL("callback"), PH_NOISY_CC); if (ZEPHIR_IS_EQUAL(callback, _8$$9)) { zephir_array_unset(&listeners, i$$8, PH_SEPARATE); } } zend_hash_destroy(_6$$8); FREE_HASHTABLE(_6$$8); } zephir_update_property_array(this_ptr, SL("listeners"), id, listeners TSRMLS_CC); } RETURN_THIS(); }
/** * Get modified params for handler using reflection */ PHP_METHOD(Phalcon_Mvc_Model_Binder, getParamsFromReflection) { zend_class_entry *_8$$10, *_9$$14, *_13$$16, *_14$$18; HashTable *_2; HashPosition _1; zephir_fcall_cache_entry *_7 = NULL, *_12 = NULL; int ZEPHIR_LAST_CALL_STATUS; zval *cacheKey = NULL; zval *params = NULL; zval *handler, *params_param = NULL, *cacheKey_param = NULL, *methodName, *methodParams = NULL, *reflection = NULL, *paramKey = NULL, *methodParam = NULL, *paramsCache = NULL, *className = NULL, *realClasses = NULL, *boundModel = NULL, *cache = NULL, *handlerClass = NULL, *reflectionClass = NULL, *paramsKeys = NULL, *paramValue = NULL, *_0, **_3, *_4$$7, _5$$5 = zval_used_for_init, *_6$$5 = NULL, *_10$$15 = NULL, *_11$$15 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 4, 0, &handler, ¶ms_param, &cacheKey_param, &methodName); zephir_get_arrval(params, params_param); zephir_get_strval(cacheKey, cacheKey_param); ZEPHIR_INIT_VAR(realClasses); ZVAL_NULL(realClasses); ZEPHIR_INIT_VAR(paramsCache); array_init(paramsCache); ZEPHIR_INIT_VAR(reflection); if (Z_TYPE_P(methodName) != IS_NULL) { object_init_ex(reflection, zephir_get_internal_ce(SS("reflectionmethod") TSRMLS_CC)); ZEPHIR_CALL_METHOD(NULL, reflection, "__construct", NULL, 324, handler, methodName); zephir_check_call_status(); } else { object_init_ex(reflection, zephir_get_internal_ce(SS("reflectionfunction") TSRMLS_CC)); ZEPHIR_CALL_METHOD(NULL, reflection, "__construct", NULL, 82, handler); zephir_check_call_status(); } _0 = zephir_fetch_nproperty_this(this_ptr, SL("cache"), PH_NOISY_CC); ZEPHIR_CPY_WRT(cache, _0); ZEPHIR_CALL_METHOD(&methodParams, reflection, "getparameters", NULL, 83); zephir_check_call_status(); ZEPHIR_INIT_VAR(paramsKeys); zephir_array_keys(paramsKeys, params TSRMLS_CC); zephir_is_iterable(methodParams, &_2, &_1, 0, 0, "phalcon/mvc/model/binder.zep", 197); for ( ; zend_hash_get_current_data_ex(_2, (void**) &_3, &_1) == SUCCESS ; zend_hash_move_forward_ex(_2, &_1) ) { ZEPHIR_GET_HMKEY(paramKey, _2, _1); ZEPHIR_GET_HVALUE(methodParam, _3); ZEPHIR_CALL_METHOD(&reflectionClass, methodParam, "getclass", NULL, 0); zephir_check_call_status(); if (!(zephir_is_true(reflectionClass))) { continue; } ZEPHIR_CALL_METHOD(&className, reflectionClass, "getname", NULL, 0); zephir_check_call_status(); if (!(zephir_array_isset(params, paramKey))) { zephir_array_fetch(&_4$$7, paramsKeys, paramKey, PH_NOISY | PH_READONLY, "phalcon/mvc/model/binder.zep", 157 TSRMLS_CC); ZEPHIR_CPY_WRT(paramKey, _4$$7); } ZEPHIR_INIT_NVAR(boundModel); ZVAL_NULL(boundModel); ZEPHIR_OBS_NVAR(paramValue); zephir_array_fetch(¶mValue, params, paramKey, PH_NOISY, "phalcon/mvc/model/binder.zep", 160 TSRMLS_CC); ZEPHIR_SINIT_NVAR(_5$$5); ZVAL_STRING(&_5$$5, "Phalcon\\Mvc\\Model", 0); ZEPHIR_CALL_FUNCTION(&_6$$5, "is_subclass_of", &_7, 325, className, &_5$$5); zephir_check_call_status(); if (ZEPHIR_IS_STRING(className, "Phalcon\\Mvc\\Model")) { if (Z_TYPE_P(realClasses) == IS_NULL) { if (zephir_instance_of_ev(handler, phalcon_mvc_controller_bindmodelinterface_ce TSRMLS_CC)) { ZEPHIR_INIT_NVAR(handlerClass); zephir_get_class(handlerClass, handler, 0 TSRMLS_CC); _8$$10 = zephir_fetch_class(handlerClass TSRMLS_CC); ZEPHIR_CALL_CE_STATIC(&realClasses, _8$$10, "getmodelname", NULL, 0); zephir_check_call_status(); } else if (zephir_instance_of_ev(handler, phalcon_mvc_model_binder_bindableinterface_ce TSRMLS_CC)) { ZEPHIR_CALL_METHOD(&realClasses, handler, "getmodelname", NULL, 0); zephir_check_call_status(); } else { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Handler must implement Phalcon\\Mvc\\Model\\Binder\\BindableInterface in order to use Phalcon\\Mvc\\Model as parameter", "phalcon/mvc/model/binder.zep", 170); return; } } if (Z_TYPE_P(realClasses) == IS_ARRAY) { ZEPHIR_OBS_NVAR(className); if (zephir_array_isset_fetch(&className, realClasses, paramKey, 0 TSRMLS_CC)) { _9$$14 = zephir_fetch_class(className TSRMLS_CC); ZEPHIR_CALL_CE_STATIC(&boundModel, _9$$14, "findfirst", NULL, 0, paramValue); zephir_check_call_status(); } else { ZEPHIR_INIT_NVAR(_10$$15); object_init_ex(_10$$15, phalcon_mvc_model_exception_ce); ZEPHIR_INIT_LNVAR(_11$$15); ZEPHIR_CONCAT_SVS(_11$$15, "You should provide model class name for ", paramKey, " parameter"); ZEPHIR_CALL_METHOD(NULL, _10$$15, "__construct", &_12, 9, _11$$15); zephir_check_call_status(); zephir_throw_exception_debug(_10$$15, "phalcon/mvc/model/binder.zep", 177 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } } else if (Z_TYPE_P(realClasses) == IS_STRING) { _13$$16 = zephir_fetch_class(realClasses TSRMLS_CC); ZEPHIR_CALL_CE_STATIC(&boundModel, _13$$16, "findfirst", NULL, 0, paramValue); zephir_check_call_status(); ZEPHIR_CPY_WRT(className, realClasses); } else { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "getModelName should return array or string", "phalcon/mvc/model/binder.zep", 183); return; } } else if (zephir_is_true(_6$$5)) { _14$$18 = zephir_fetch_class(className TSRMLS_CC); ZEPHIR_CALL_CE_STATIC(&boundModel, _14$$18, "findfirst", NULL, 0, paramValue); zephir_check_call_status(); } if (Z_TYPE_P(boundModel) != IS_NULL) { zephir_update_property_array(this_ptr, SL("originalValues"), paramKey, paramValue TSRMLS_CC); zephir_array_update_zval(¶ms, paramKey, &boundModel, PH_COPY | PH_SEPARATE); zephir_update_property_array(this_ptr, SL("boundModels"), paramKey, boundModel TSRMLS_CC); zephir_array_update_zval(¶msCache, paramKey, &className, PH_COPY | PH_SEPARATE); } } if (Z_TYPE_P(cache) != IS_NULL) { ZEPHIR_CALL_METHOD(NULL, cache, "save", NULL, 0, cacheKey, paramsCache); zephir_check_call_status(); } zephir_update_property_array(this_ptr, SL("internalCache"), cacheKey, paramsCache TSRMLS_CC); RETURN_CTOR(params); }
/** * Phalcon\Translate\Adapter\Csv constructor */ PHP_METHOD(Phalcon_Translate_Adapter_Csv, __construct) { zend_bool _12; zephir_fcall_cache_entry *_9 = NULL; int ZEPHIR_LAST_CALL_STATUS; zval *options_param = NULL, *data = NULL, *file = NULL, *_0, *_2, _3 = zval_used_for_init, *_4 = NULL, *_5, *_6, *_7, *_8, *_10, _11 = zval_used_for_init, *_13, *_14 = NULL; zval *options = NULL, *_1; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &options_param); options = options_param; if (!(zephir_array_isset_string(options, SS("content")))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_translate_exception_ce, "Parameter 'content' is required", "phalcon/translate/adapter/csv.zep", 43); return; } ZEPHIR_INIT_VAR(_0); ZEPHIR_INIT_VAR(_1); zephir_create_array(_1, 3, 0 TSRMLS_CC); add_assoc_stringl_ex(_1, SS("delimiter"), SL(";"), 1); add_assoc_long_ex(_1, SS("length"), 0); add_assoc_stringl_ex(_1, SS("enclosure"), SL("\""), 1); zephir_fast_array_merge(_0, &(_1), &(options) TSRMLS_CC); ZEPHIR_CPY_WRT(options, _0); zephir_array_fetch_string(&_2, options, SL("content"), PH_NOISY | PH_READONLY, "phalcon/translate/adapter/csv.zep", 52 TSRMLS_CC); ZEPHIR_SINIT_VAR(_3); ZVAL_STRING(&_3, "rb", 0); ZEPHIR_CALL_FUNCTION(&file, "fopen", NULL, 291, _2, &_3); zephir_check_call_status(); if (Z_TYPE_P(file) != IS_RESOURCE) { ZEPHIR_INIT_VAR(_4); object_init_ex(_4, phalcon_translate_exception_ce); zephir_array_fetch_string(&_5, options, SL("content"), PH_NOISY | PH_READONLY, "phalcon/translate/adapter/csv.zep", 55 TSRMLS_CC); ZEPHIR_INIT_VAR(_6); ZEPHIR_CONCAT_SVS(_6, "Error opening translation file '", _5, "'"); ZEPHIR_CALL_METHOD(NULL, _4, "__construct", NULL, 9, _6); zephir_check_call_status(); zephir_throw_exception_debug(_4, "phalcon/translate/adapter/csv.zep", 55 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } while (1) { zephir_array_fetch_string(&_5, options, SL("length"), PH_NOISY | PH_READONLY, "phalcon/translate/adapter/csv.zep", 60 TSRMLS_CC); zephir_array_fetch_string(&_7, options, SL("delimiter"), PH_NOISY | PH_READONLY, "phalcon/translate/adapter/csv.zep", 60 TSRMLS_CC); zephir_array_fetch_string(&_8, options, SL("enclosure"), PH_NOISY | PH_READONLY, "phalcon/translate/adapter/csv.zep", 60 TSRMLS_CC); ZEPHIR_CALL_FUNCTION(&data, "fgetcsv", &_9, 422, file, _5, _7, _8); zephir_check_call_status(); if (ZEPHIR_IS_FALSE_IDENTICAL(data)) { break; } zephir_array_fetch_long(&_10, data, 0, PH_NOISY | PH_READONLY, "phalcon/translate/adapter/csv.zep", 65 TSRMLS_CC); ZEPHIR_SINIT_NVAR(_3); ZVAL_LONG(&_3, 0); ZEPHIR_SINIT_NVAR(_11); ZVAL_LONG(&_11, 1); ZEPHIR_INIT_NVAR(_4); zephir_substr(_4, _10, 0 , 1 , 0); _12 = ZEPHIR_IS_STRING_IDENTICAL(_4, "#"); if (!(_12)) { _12 = !(zephir_array_isset_long(data, 1)); } if (_12) { continue; } zephir_array_fetch_long(&_13, data, 1, PH_NOISY | PH_READONLY, "phalcon/translate/adapter/csv.zep", 69 TSRMLS_CC); ZEPHIR_OBS_NVAR(_14); zephir_array_fetch_long(&_14, data, 0, PH_NOISY, "phalcon/translate/adapter/csv.zep", 69 TSRMLS_CC); zephir_update_property_array(this_ptr, SL("_translate"), _14, _13 TSRMLS_CC); } zephir_fclose(file TSRMLS_CC); ZEPHIR_MM_RESTORE(); }
/** * Adds access to resources * * @param array|string accessList */ PHP_METHOD(Phalcon_Acl_Adapter_Memory, addResourceAccess) { HashTable *_5; HashPosition _4; int ZEPHIR_LAST_CALL_STATUS; zend_bool exists, _3; zval *resourceName_param = NULL, *accessList, *accessName = NULL, *accessKey = NULL, *_0, *_1 = NULL, **_6; zval *resourceName = NULL, *_2; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &resourceName_param, &accessList); zephir_get_strval(resourceName, resourceName_param); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_resourcesNames"), PH_NOISY_CC); if (!(zephir_array_isset(_0, resourceName))) { ZEPHIR_INIT_VAR(_1); object_init_ex(_1, phalcon_acl_exception_ce); ZEPHIR_INIT_VAR(_2); ZEPHIR_CONCAT_SVS(_2, "Resource '", resourceName, "' does not exist in ACL"); ZEPHIR_CALL_METHOD(NULL, _1, "__construct", NULL, 9, _2); zephir_check_call_status(); zephir_throw_exception_debug(_1, "phalcon/acl/adapter/memory.zep", 298 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } _3 = Z_TYPE_P(accessList) != IS_ARRAY; if (_3) { _3 = Z_TYPE_P(accessList) != IS_STRING; } if (_3) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_acl_exception_ce, "Invalid value for accessList", "phalcon/acl/adapter/memory.zep", 302); return; } exists = 1; if (Z_TYPE_P(accessList) == IS_ARRAY) { zephir_is_iterable(accessList, &_5, &_4, 0, 0, "phalcon/acl/adapter/memory.zep", 313); for ( ; zephir_hash_get_current_data_ex(_5, (void**) &_6, &_4) == SUCCESS ; zephir_hash_move_forward_ex(_5, &_4) ) { ZEPHIR_GET_HVALUE(accessName, _6); ZEPHIR_INIT_NVAR(accessKey); ZEPHIR_CONCAT_VSV(accessKey, resourceName, "!", accessName); if (!(zephir_array_isset(accessList, accessKey))) { ZEPHIR_INIT_NVAR(_1); ZVAL_BOOL(_1, exists); zephir_update_property_array(this_ptr, SL("_accessList"), accessKey, _1 TSRMLS_CC); } } } else { ZEPHIR_INIT_NVAR(accessKey); ZEPHIR_CONCAT_VSV(accessKey, resourceName, "!", accessList); if (!(zephir_array_isset(accessList, accessKey))) { ZEPHIR_INIT_NVAR(_1); ZVAL_BOOL(_1, exists); zephir_update_property_array(this_ptr, SL("_accessList"), accessKey, _1 TSRMLS_CC); } } RETURN_MM_BOOL(1); }
PHP_METHOD(PhalconPlus_Logger_Formatter_LinePlus, format) { zephir_fcall_cache_entry *_13 = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; zval *message, message_sub, *type, type_sub, *timestamp, timestamp_sub, *context = NULL, context_sub, __$null, _0, _1, _2, _3, matches, result, _4, _5, _6, replace0, replace1, val1, val2, processors, *_10, logStr, _15, _16, _7$$3, _8$$3, _9$$3, _11$$4, _12$$5, _14$$6; zval *this_ptr = getThis(); ZVAL_UNDEF(&message_sub); ZVAL_UNDEF(&type_sub); ZVAL_UNDEF(×tamp_sub); ZVAL_UNDEF(&context_sub); ZVAL_NULL(&__$null); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); ZVAL_UNDEF(&_2); ZVAL_UNDEF(&_3); ZVAL_UNDEF(&matches); ZVAL_UNDEF(&result); ZVAL_UNDEF(&_4); ZVAL_UNDEF(&_5); ZVAL_UNDEF(&_6); ZVAL_UNDEF(&replace0); ZVAL_UNDEF(&replace1); ZVAL_UNDEF(&val1); ZVAL_UNDEF(&val2); ZVAL_UNDEF(&processors); ZVAL_UNDEF(&logStr); ZVAL_UNDEF(&_15); ZVAL_UNDEF(&_16); ZVAL_UNDEF(&_7$$3); ZVAL_UNDEF(&_8$$3); ZVAL_UNDEF(&_9$$3); ZVAL_UNDEF(&_11$$4); ZVAL_UNDEF(&_12$$5); ZVAL_UNDEF(&_14$$6); ZEPHIR_MM_GROW(); zephir_fetch_params(1, 3, 1, &message, &type, ×tamp, &context); if (!context) { context = &context_sub; context = &__$null; } ZEPHIR_INIT_VAR(&_0); ZVAL_STRING(&_0, "message"); zephir_update_property_array(this_ptr, SL("processors"), &_0, message TSRMLS_CC); ZEPHIR_INIT_VAR(&_1); ZVAL_STRING(&_1, "Y-m-d H:i:s"); ZEPHIR_CALL_FUNCTION(&_2, "date", NULL, 33, &_1, timestamp); zephir_check_call_status(); ZEPHIR_INIT_NVAR(&_1); ZVAL_STRING(&_1, "date"); zephir_update_property_array(this_ptr, SL("processors"), &_1, &_2 TSRMLS_CC); ZEPHIR_CALL_METHOD(&_2, this_ptr, "gettypestring", NULL, 0, type); zephir_check_call_status(); ZEPHIR_INIT_VAR(&_3); ZVAL_STRING(&_3, "type"); zephir_update_property_array(this_ptr, SL("processors"), &_3, &_2 TSRMLS_CC); ZEPHIR_INIT_VAR(&matches); array_init(&matches); zephir_read_property(&_4, this_ptr, SL("formatString"), PH_NOISY_CC | PH_READONLY); ZEPHIR_INIT_VAR(&_5); ZVAL_STRING(&_5, "/%(\\w+)%/"); ZEPHIR_INIT_VAR(&_6); ZVAL_STRING(&_6, "/%(\\w+)%/"); ZEPHIR_INIT_VAR(&result); zephir_preg_match(&result, &_6, &_4, &matches, 1, 0 , 0 TSRMLS_CC); if (ZEPHIR_IS_FALSE(&result)) { ZEPHIR_INIT_VAR(&_7$$3); object_init_ex(&_7$$3, spl_ce_InvalidArgumentException); zephir_read_property(&_8$$3, this_ptr, SL("formatString"), PH_NOISY_CC | PH_READONLY); ZEPHIR_INIT_VAR(&_9$$3); ZEPHIR_CONCAT_SV(&_9$$3, "Logger format is not valid: ", &_8$$3); ZEPHIR_CALL_METHOD(NULL, &_7$$3, "__construct", NULL, 15, &_9$$3); zephir_check_call_status(); zephir_throw_exception_debug(&_7$$3, "phalconplus/Logger/Formatter/LinePlus.zep", 29 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } ZEPHIR_MAKE_REF(&matches); ZEPHIR_CALL_FUNCTION(&replace0, "reset", NULL, 47, &matches); ZEPHIR_UNREF(&matches); zephir_check_call_status(); ZEPHIR_MAKE_REF(&matches); ZEPHIR_CALL_FUNCTION(&replace1, "end", NULL, 31, &matches); ZEPHIR_UNREF(&matches); zephir_check_call_status(); ZEPHIR_INIT_VAR(&processors); array_init(&processors); zephir_is_iterable(&replace1, 0, "phalconplus/Logger/Formatter/LinePlus.zep", 46); ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&replace1), _10) { ZEPHIR_INIT_NVAR(&val1); ZVAL_COPY(&val1, _10); ZEPHIR_OBS_NVAR(&val2); zephir_read_property(&_11$$4, this_ptr, SL("processors"), PH_NOISY_CC | PH_READONLY); if (zephir_array_isset_fetch(&val2, &_11$$4, &val1, 0 TSRMLS_CC)) { ZEPHIR_CALL_FUNCTION(&_12$$5, "strval", &_13, 27, &val2); zephir_check_call_status(); zephir_array_update_zval(&processors, &val1, &_12$$5, PH_COPY | PH_SEPARATE); } else { ZEPHIR_INIT_NVAR(&_14$$6); ZVAL_STRING(&_14$$6, "undefined"); zephir_array_update_zval(&processors, &val1, &_14$$6, PH_COPY | PH_SEPARATE); } } ZEND_HASH_FOREACH_END();
/** * Checks if a role has access to a resource */ PHP_METHOD(Phalcon_Acl_Adapter_Memory, _allowOrDeny) { HashTable *_7$$5, *_12$$5; HashPosition _6$$5, _11$$5; int ZEPHIR_LAST_CALL_STATUS; zval *roleName_param = NULL, *resourceName_param = NULL, *access, *action, *func = NULL, *accessList = NULL, *accessName = NULL, *accessKey = NULL, *_0, *_3, *_1$$3, *_4$$4, **_8$$5, **_13$$5, *_9$$7 = NULL, *_10$$7 = NULL, *_14$$12, *_15$$12; zval *roleName = NULL, *resourceName = NULL, *_2$$3, *_5$$4; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 4, 1, &roleName_param, &resourceName_param, &access, &action, &func); zephir_get_strval(roleName, roleName_param); zephir_get_strval(resourceName, resourceName_param); if (!func) { func = ZEPHIR_GLOBAL(global_null); } _0 = zephir_fetch_nproperty_this(this_ptr, SL("_rolesNames"), PH_NOISY_CC); if (!(zephir_array_isset(_0, roleName))) { ZEPHIR_INIT_VAR(_1$$3); object_init_ex(_1$$3, phalcon_acl_exception_ce); ZEPHIR_INIT_VAR(_2$$3); ZEPHIR_CONCAT_SVS(_2$$3, "Role '", roleName, "' does not exist in ACL"); ZEPHIR_CALL_METHOD(NULL, _1$$3, "__construct", NULL, 9, _2$$3); zephir_check_call_status(); zephir_throw_exception_debug(_1$$3, "phalcon/acl/adapter/memory.zep", 408 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } _3 = zephir_fetch_nproperty_this(this_ptr, SL("_resourcesNames"), PH_NOISY_CC); if (!(zephir_array_isset(_3, resourceName))) { ZEPHIR_INIT_VAR(_4$$4); object_init_ex(_4$$4, phalcon_acl_exception_ce); ZEPHIR_INIT_VAR(_5$$4); ZEPHIR_CONCAT_SVS(_5$$4, "Resource '", resourceName, "' does not exist in ACL"); ZEPHIR_CALL_METHOD(NULL, _4$$4, "__construct", NULL, 9, _5$$4); zephir_check_call_status(); zephir_throw_exception_debug(_4$$4, "phalcon/acl/adapter/memory.zep", 412 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } ZEPHIR_OBS_VAR(accessList); zephir_read_property_this(&accessList, this_ptr, SL("_accessList"), PH_NOISY_CC); if (Z_TYPE_P(access) == IS_ARRAY) { zephir_is_iterable(access, &_7$$5, &_6$$5, 0, 0, "phalcon/acl/adapter/memory.zep", 426); for ( ; zephir_hash_get_current_data_ex(_7$$5, (void**) &_8$$5, &_6$$5) == SUCCESS ; zephir_hash_move_forward_ex(_7$$5, &_6$$5) ) { ZEPHIR_GET_HVALUE(accessName, _8$$5); ZEPHIR_INIT_NVAR(accessKey); ZEPHIR_CONCAT_VSV(accessKey, resourceName, "!", accessName); if (!(zephir_array_isset(accessList, accessKey))) { ZEPHIR_INIT_NVAR(_9$$7); object_init_ex(_9$$7, phalcon_acl_exception_ce); ZEPHIR_INIT_LNVAR(_10$$7); ZEPHIR_CONCAT_SVSVS(_10$$7, "Access '", accessName, "' does not exist in resource '", resourceName, "'"); ZEPHIR_CALL_METHOD(NULL, _9$$7, "__construct", NULL, 9, _10$$7); zephir_check_call_status(); zephir_throw_exception_debug(_9$$7, "phalcon/acl/adapter/memory.zep", 422 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } } zephir_is_iterable(access, &_12$$5, &_11$$5, 0, 0, "phalcon/acl/adapter/memory.zep", 435); for ( ; zephir_hash_get_current_data_ex(_12$$5, (void**) &_13$$5, &_11$$5) == SUCCESS ; zephir_hash_move_forward_ex(_12$$5, &_11$$5) ) { ZEPHIR_GET_HVALUE(accessName, _13$$5); ZEPHIR_INIT_NVAR(accessKey); ZEPHIR_CONCAT_VSVSV(accessKey, roleName, "!", resourceName, "!", accessName); zephir_update_property_array(this_ptr, SL("_access"), accessKey, action TSRMLS_CC); if (Z_TYPE_P(func) != IS_NULL) { zephir_update_property_array(this_ptr, SL("_func"), accessKey, func TSRMLS_CC); } } } else { if (!ZEPHIR_IS_STRING(access, "*")) { ZEPHIR_INIT_NVAR(accessKey); ZEPHIR_CONCAT_VSV(accessKey, resourceName, "!", access); if (!(zephir_array_isset(accessList, accessKey))) { ZEPHIR_INIT_VAR(_14$$12); object_init_ex(_14$$12, phalcon_acl_exception_ce); ZEPHIR_INIT_VAR(_15$$12); ZEPHIR_CONCAT_SVSVS(_15$$12, "Access '", access, "' does not exist in resource '", resourceName, "'"); ZEPHIR_CALL_METHOD(NULL, _14$$12, "__construct", NULL, 9, _15$$12); zephir_check_call_status(); zephir_throw_exception_debug(_14$$12, "phalcon/acl/adapter/memory.zep", 440 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } } ZEPHIR_INIT_NVAR(accessKey); ZEPHIR_CONCAT_VSVSV(accessKey, roleName, "!", resourceName, "!", access); zephir_update_property_array(this_ptr, SL("_access"), accessKey, action TSRMLS_CC); if (Z_TYPE_P(func) != IS_NULL) { zephir_update_property_array(this_ptr, SL("_func"), accessKey, func TSRMLS_CC); } } ZEPHIR_MM_RESTORE(); }
/** * Attach a listener to the events manager * * @param string eventType * @param object|callable handler * @param int priority */ PHP_METHOD(Phalcon_Events_Manager, attach) { int priority, ZEPHIR_LAST_CALL_STATUS; zval *eventType_param = NULL, *handler, *priority_param = NULL, *priorityQueue = NULL, *_0, *_1$$4, *_2$$5, *_3$$7; zval *eventType = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 1, &eventType_param, &handler, &priority_param); if (unlikely(Z_TYPE_P(eventType_param) != IS_STRING && Z_TYPE_P(eventType_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'eventType' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(eventType_param) == IS_STRING)) { zephir_get_strval(eventType, eventType_param); } else { ZEPHIR_INIT_VAR(eventType); ZVAL_EMPTY_STRING(eventType); } if (!priority_param) { priority = 100; } else { if (unlikely(Z_TYPE_P(priority_param) != IS_LONG)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'priority' must be a int") TSRMLS_CC); RETURN_MM_NULL(); } priority = Z_LVAL_P(priority_param); } if (Z_TYPE_P(handler) != IS_OBJECT) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_events_exception_ce, "Event handler must be an Object", "phalcon/events/manager.zep", 56); return; } ZEPHIR_OBS_VAR(priorityQueue); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_events"), PH_NOISY_CC); if (!(zephir_array_isset_fetch(&priorityQueue, _0, eventType, 0 TSRMLS_CC))) { _1$$4 = zephir_fetch_nproperty_this(this_ptr, SL("_enablePriorities"), PH_NOISY_CC); ZEPHIR_INIT_NVAR(priorityQueue); if (zephir_is_true(_1$$4)) { object_init_ex(priorityQueue, spl_ce_SplPriorityQueue); if (zephir_has_constructor(priorityQueue TSRMLS_CC)) { ZEPHIR_CALL_METHOD(NULL, priorityQueue, "__construct", NULL, 0); zephir_check_call_status(); } ZEPHIR_INIT_VAR(_2$$5); ZVAL_LONG(_2$$5, 1); ZEPHIR_CALL_METHOD(NULL, priorityQueue, "setextractflags", NULL, 190, _2$$5); zephir_check_call_status(); zephir_update_property_array(this_ptr, SL("_events"), eventType, priorityQueue TSRMLS_CC); } else { array_init(priorityQueue); } } if (Z_TYPE_P(priorityQueue) == IS_OBJECT) { ZEPHIR_INIT_VAR(_3$$7); ZVAL_LONG(_3$$7, priority); ZEPHIR_CALL_METHOD(NULL, priorityQueue, "insert", NULL, 191, handler, _3$$7); zephir_check_call_status(); } else { zephir_array_append(&priorityQueue, handler, PH_SEPARATE, "phalcon/events/manager.zep", 82); zephir_update_property_array(this_ptr, SL("_events"), eventType, priorityQueue TSRMLS_CC); } ZEPHIR_MM_RESTORE(); }
/** * Registers a set of PSR-4 directories for a given namespace, either * appending or prepending to the ones previously set for this namespace. * * @param string $prefix The prefix/namespace, with trailing "\\" * @param array|string $paths The PSR-0 base directories * @param bool $prepend Whether to prepend the directories * @throws \InvalidArgumentException */ PHP_METHOD(Xpl_ClassLoader, addPsr4) { zend_bool prepend; zval *prefix, *paths = NULL, *prepend_param = NULL, *firstChar = NULL, *prefixDirs = NULL, *_4, *_0$$5, *_1$$5, *_2$$6, *_3$$6, _5$$7, _6$$7, *_7$$7, *_8$$10, *_9$$11; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 1, &prefix, &paths, &prepend_param); ZEPHIR_SEPARATE_PARAM(paths); if (!prepend_param) { prepend = 0; } else { prepend = zephir_get_boolval(prepend_param); } if (Z_TYPE_P(paths) == IS_STRING) { ZEPHIR_INIT_NVAR(paths); zephir_create_array(paths, 1, 0 TSRMLS_CC); zephir_array_fast_append(paths, paths); } if (Z_TYPE_P(prefix) != IS_STRING) { if (prepend) { ZEPHIR_INIT_VAR(_0$$5); _1$$5 = zephir_fetch_nproperty_this(this_ptr, SL("fallbackDirsPsr4"), PH_NOISY_CC); zephir_fast_array_merge(_0$$5, &(paths), &(_1$$5) TSRMLS_CC); zephir_update_property_this(this_ptr, SL("fallbackDirsPsr4"), _0$$5 TSRMLS_CC); } else { ZEPHIR_INIT_VAR(_2$$6); _3$$6 = zephir_fetch_nproperty_this(this_ptr, SL("fallbackDirsPsr4"), PH_NOISY_CC); zephir_fast_array_merge(_2$$6, &(_3$$6), &(paths) TSRMLS_CC); zephir_update_property_this(this_ptr, SL("fallbackDirsPsr4"), _2$$6 TSRMLS_CC); } RETURN_MM_NULL(); } ZEPHIR_OBS_VAR(prefixDirs); _4 = zephir_fetch_nproperty_this(this_ptr, SL("prefixDirsPsr4"), PH_NOISY_CC); if (!(zephir_array_isset_fetch(&prefixDirs, _4, prefix, 0 TSRMLS_CC))) { ZEPHIR_SINIT_VAR(_5$$7); ZVAL_LONG(&_5$$7, 0); ZEPHIR_SINIT_VAR(_6$$7); ZVAL_LONG(&_6$$7, 1); ZEPHIR_INIT_VAR(firstChar); zephir_substr(firstChar, prefix, 0 , 1 , 0); if (!(zephir_end_with_str(prefix, SL("\\")))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(spl_ce_InvalidArgumentException, "A non-empty PSR-4 prefix must end with a namespace separator.", "xpl/classloader.zep", 310); return; } ZEPHIR_INIT_VAR(_7$$7); ZVAL_LONG(_7$$7, zephir_fast_strlen_ev(prefix)); zephir_update_property_array_multi(this_ptr, SL("prefixLengthsPsr4"), &_7$$7 TSRMLS_CC, SL("zz"), 2, firstChar, prefix); zephir_update_property_array(this_ptr, SL("prefixDirsPsr4"), prefix, paths TSRMLS_CC); } else { if (prepend) { ZEPHIR_INIT_VAR(_8$$10); zephir_fast_array_merge(_8$$10, &(paths), &(prefixDirs) TSRMLS_CC); zephir_update_property_array(this_ptr, SL("prefixDirsPsr4"), prefix, _8$$10 TSRMLS_CC); } else { ZEPHIR_INIT_VAR(_9$$11); zephir_fast_array_merge(_9$$11, &(prefixDirs), &(paths) TSRMLS_CC); zephir_update_property_array(this_ptr, SL("prefixDirsPsr4"), prefix, _9$$11 TSRMLS_CC); } } ZEPHIR_MM_RESTORE(); }
/** * Do a role inherit from another existing role */ PHP_METHOD(Phalcon_Acl_Adapter_Memory, addInherit) { zephir_fcall_cache_entry *_8 = NULL; HashTable *_6; HashPosition _5; int ZEPHIR_LAST_CALL_STATUS; zval *roleName_param = NULL, *roleToInherit, *roleInheritName = NULL, *rolesNames, *deepInheritName = NULL, *_0 = NULL, *_2, *_3, *_4, **_7, *_9; zval *roleName = NULL, *_1; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &roleName_param, &roleToInherit); zephir_get_strval(roleName, roleName_param); ZEPHIR_OBS_VAR(rolesNames); zephir_read_property_this(&rolesNames, this_ptr, SL("_rolesNames"), PH_NOISY_CC); if (!(zephir_array_isset(rolesNames, roleName))) { ZEPHIR_INIT_VAR(_0); object_init_ex(_0, phalcon_acl_exception_ce); ZEPHIR_INIT_VAR(_1); ZEPHIR_CONCAT_SVS(_1, "Role '", roleName, "' does not exist in the role list"); ZEPHIR_CALL_METHOD(NULL, _0, "__construct", NULL, 9, _1); zephir_check_call_status(); zephir_throw_exception_debug(_0, "phalcon/acl/adapter/memory.zep", 194 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } if (Z_TYPE_P(roleToInherit) == IS_OBJECT) { ZEPHIR_CALL_METHOD(&roleInheritName, roleToInherit, "getname", NULL, 0); zephir_check_call_status(); } else { ZEPHIR_CPY_WRT(roleInheritName, roleToInherit); } _2 = zephir_fetch_nproperty_this(this_ptr, SL("_roleInherits"), PH_NOISY_CC); if (zephir_array_isset(_2, roleInheritName)) { _3 = zephir_fetch_nproperty_this(this_ptr, SL("_roleInherits"), PH_NOISY_CC); zephir_array_fetch(&_4, _3, roleInheritName, PH_NOISY | PH_READONLY, "phalcon/acl/adapter/memory.zep", 207 TSRMLS_CC); zephir_is_iterable(_4, &_6, &_5, 0, 0, "phalcon/acl/adapter/memory.zep", 210); for ( ; zephir_hash_get_current_data_ex(_6, (void**) &_7, &_5) == SUCCESS ; zephir_hash_move_forward_ex(_6, &_5) ) { ZEPHIR_GET_HVALUE(deepInheritName, _7); ZEPHIR_CALL_METHOD(NULL, this_ptr, "addinherit", &_8, 80, roleName, deepInheritName); zephir_check_call_status(); } } if (!(zephir_array_isset(rolesNames, roleInheritName))) { ZEPHIR_INIT_NVAR(_0); object_init_ex(_0, phalcon_acl_exception_ce); ZEPHIR_INIT_VAR(_9); ZEPHIR_CONCAT_SVS(_9, "Role '", roleInheritName, "' (to inherit) does not exist in the role list"); ZEPHIR_CALL_METHOD(NULL, _0, "__construct", NULL, 9, _9); zephir_check_call_status(); zephir_throw_exception_debug(_0, "phalcon/acl/adapter/memory.zep", 216 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } if (ZEPHIR_IS_EQUAL(roleName, roleInheritName)) { RETURN_MM_BOOL(0); } _3 = zephir_fetch_nproperty_this(this_ptr, SL("_roleInherits"), PH_NOISY_CC); if (!(zephir_array_isset(_3, roleName))) { zephir_update_property_array(this_ptr, SL("_roleInherits"), roleName, ZEPHIR_GLOBAL(global_true) TSRMLS_CC); } zephir_update_property_array_multi(this_ptr, SL("_roleInherits"), &roleInheritName TSRMLS_CC, SL("za"), 2, roleName); RETURN_MM_BOOL(1); }
/** * Finds the path to the file where the class is defined. * * @param string $class The name of the class * * @return string|false The path if found, false otherwise */ PHP_METHOD(Xpl_ClassLoader, findFile) { zephir_fcall_cache_entry *_4 = NULL; int ZEPHIR_LAST_CALL_STATUS; zval *className_param = NULL, *file = NULL, *_0, _1, *_2, *_3, _5$$5, *_6$$5 = NULL, *_7$$6; zval *className = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &className_param); if (unlikely(Z_TYPE_P(className_param) != IS_STRING && Z_TYPE_P(className_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'className' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(className_param) == IS_STRING)) { zephir_get_strval(className, className_param); } else { ZEPHIR_INIT_VAR(className); ZVAL_EMPTY_STRING(className); } ZEPHIR_INIT_VAR(_0); ZEPHIR_SINIT_VAR(_1); ZVAL_STRING(&_1, "\\", 0); zephir_fast_trim(_0, className, &_1, ZEPHIR_TRIM_LEFT TSRMLS_CC); zephir_get_strval(className, _0); ZEPHIR_OBS_VAR(file); _2 = zephir_fetch_nproperty_this(this_ptr, SL("classMap"), PH_NOISY_CC); if (zephir_array_isset_fetch(&file, _2, className, 0 TSRMLS_CC)) { RETURN_CCTOR(file); } ZEPHIR_INIT_VAR(_3); ZVAL_STRING(_3, ".php", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&file, this_ptr, "findfilewithextension", &_4, 0, className, _3); zephir_check_temp_parameter(_3); zephir_check_call_status(); if (Z_TYPE_P(file) == IS_STRING) { zephir_update_property_array(this_ptr, SL("classMap"), className, file TSRMLS_CC); } else { ZEPHIR_SINIT_VAR(_5$$5); ZVAL_STRING(&_5$$5, "HHVM_VERSION", 0); ZEPHIR_CALL_FUNCTION(&_6$$5, "defined", NULL, 55, &_5$$5); zephir_check_call_status(); if (zephir_is_true(_6$$5)) { ZEPHIR_INIT_VAR(_7$$6); ZVAL_STRING(_7$$6, ".hh", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&file, this_ptr, "findfilewithextension", &_4, 0, className, _7$$6); zephir_check_temp_parameter(_7$$6); zephir_check_call_status(); if (Z_TYPE_P(file) == IS_STRING) { zephir_update_property_array(this_ptr, SL("classMap"), className, file TSRMLS_CC); RETURN_CCTOR(file); } } ZEPHIR_INIT_NVAR(file); ZVAL_BOOL(file, 0); zephir_update_property_array(this_ptr, SL("classMap"), className, file TSRMLS_CC); } RETURN_CCTOR(file); }
/** * Checks if a role has access to a resource */ PHP_METHOD(Phalcon_Acl_Adapter_Memory, _allowOrDeny) { HashTable *_5, *_9; HashPosition _4, _8; int ZEPHIR_LAST_CALL_STATUS; zval *roleName_param = NULL, *resourceName_param = NULL, *access, *action, *defaultAccess, *accessList, *accessName = NULL, *accessKey = NULL, *accessKeyAll = NULL, *internalAccess, *_0, *_1 = NULL, *_3, **_6, *_7 = NULL, **_10, *_11; zval *roleName = NULL, *resourceName = NULL, *_2 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 4, 0, &roleName_param, &resourceName_param, &access, &action); zephir_get_strval(roleName, roleName_param); zephir_get_strval(resourceName, resourceName_param); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_rolesNames"), PH_NOISY_CC); if (!(zephir_array_isset(_0, roleName))) { ZEPHIR_INIT_VAR(_1); object_init_ex(_1, phalcon_acl_exception_ce); ZEPHIR_INIT_VAR(_2); ZEPHIR_CONCAT_SVS(_2, "Role '", roleName, "' does not exist in ACL"); ZEPHIR_CALL_METHOD(NULL, _1, "__construct", NULL, 9, _2); zephir_check_call_status(); zephir_throw_exception_debug(_1, "phalcon/acl/adapter/memory.zep", 357 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } _3 = zephir_fetch_nproperty_this(this_ptr, SL("_resourcesNames"), PH_NOISY_CC); if (!(zephir_array_isset(_3, resourceName))) { ZEPHIR_INIT_NVAR(_1); object_init_ex(_1, phalcon_acl_exception_ce); ZEPHIR_INIT_LNVAR(_2); ZEPHIR_CONCAT_SVS(_2, "Resource '", resourceName, "' does not exist in ACL"); ZEPHIR_CALL_METHOD(NULL, _1, "__construct", NULL, 9, _2); zephir_check_call_status(); zephir_throw_exception_debug(_1, "phalcon/acl/adapter/memory.zep", 361 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } ZEPHIR_OBS_VAR(defaultAccess); zephir_read_property_this(&defaultAccess, this_ptr, SL("_defaultAccess"), PH_NOISY_CC); ZEPHIR_OBS_VAR(accessList); zephir_read_property_this(&accessList, this_ptr, SL("_accessList"), PH_NOISY_CC); ZEPHIR_OBS_VAR(internalAccess); zephir_read_property_this(&internalAccess, this_ptr, SL("_access"), PH_NOISY_CC); if (Z_TYPE_P(access) == IS_ARRAY) { zephir_is_iterable(access, &_5, &_4, 0, 0, "phalcon/acl/adapter/memory.zep", 377); for ( ; zephir_hash_get_current_data_ex(_5, (void**) &_6, &_4) == SUCCESS ; zephir_hash_move_forward_ex(_5, &_4) ) { ZEPHIR_GET_HVALUE(accessName, _6); ZEPHIR_INIT_NVAR(accessKey); ZEPHIR_CONCAT_VSV(accessKey, resourceName, "!", accessName); if (!(zephir_array_isset(accessList, accessKey))) { ZEPHIR_INIT_NVAR(_1); object_init_ex(_1, phalcon_acl_exception_ce); ZEPHIR_INIT_LNVAR(_7); ZEPHIR_CONCAT_SVSVS(_7, "Access '", accessName, "' does not exist in resource '", resourceName, "'"); ZEPHIR_CALL_METHOD(NULL, _1, "__construct", NULL, 9, _7); zephir_check_call_status(); zephir_throw_exception_debug(_1, "phalcon/acl/adapter/memory.zep", 373 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } } zephir_is_iterable(access, &_9, &_8, 0, 0, "phalcon/acl/adapter/memory.zep", 390); for ( ; zephir_hash_get_current_data_ex(_9, (void**) &_10, &_8) == SUCCESS ; zephir_hash_move_forward_ex(_9, &_8) ) { ZEPHIR_GET_HVALUE(accessName, _10); ZEPHIR_INIT_NVAR(accessKey); ZEPHIR_CONCAT_VSVSV(accessKey, roleName, "!", resourceName, "!", accessName); zephir_update_property_array(this_ptr, SL("_access"), accessKey, action TSRMLS_CC); if (!ZEPHIR_IS_STRING(accessName, "*")) { ZEPHIR_INIT_LNVAR(_2); ZEPHIR_CONCAT_VSVS(_2, roleName, "!", resourceName, "!*"); ZEPHIR_CPY_WRT(accessKeyAll, _2); if (zephir_array_isset(internalAccess, accessKeyAll)) { zephir_update_property_array(this_ptr, SL("_access"), accessKeyAll, defaultAccess TSRMLS_CC); } } } } else { if (!ZEPHIR_IS_STRING(access, "*")) { ZEPHIR_INIT_NVAR(accessKey); ZEPHIR_CONCAT_VSV(accessKey, resourceName, "!", access); if (!(zephir_array_isset(accessList, accessKey))) { ZEPHIR_INIT_NVAR(_1); object_init_ex(_1, phalcon_acl_exception_ce); ZEPHIR_INIT_LNVAR(_7); ZEPHIR_CONCAT_SVSVS(_7, "Access '", access, "' does not exist in resource '", resourceName, "'"); ZEPHIR_CALL_METHOD(NULL, _1, "__construct", NULL, 9, _7); zephir_check_call_status(); zephir_throw_exception_debug(_1, "phalcon/acl/adapter/memory.zep", 395 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } } ZEPHIR_INIT_NVAR(accessKey); ZEPHIR_CONCAT_VSVSV(accessKey, roleName, "!", resourceName, "!", access); zephir_update_property_array(this_ptr, SL("_access"), accessKey, action TSRMLS_CC); if (!ZEPHIR_IS_STRING(access, "*")) { ZEPHIR_INIT_LNVAR(_2); ZEPHIR_CONCAT_VSVS(_2, roleName, "!", resourceName, "!*"); ZEPHIR_CPY_WRT(accessKey, _2); if (!(zephir_array_isset(internalAccess, accessKey))) { _11 = zephir_fetch_nproperty_this(this_ptr, SL("_defaultAccess"), PH_NOISY_CC); zephir_update_property_array(this_ptr, SL("_access"), accessKey, _11 TSRMLS_CC); } } } ZEPHIR_MM_RESTORE(); }
/** * Adds a INNER join to the query * *<code> * $criteria->join('Robots'); * $criteria->join('Robots', 'r.id = RobotsParts.robots_id'); * $criteria->join('Robots', 'r.id = RobotsParts.robots_id', 'r'); * $criteria->join('Robots', 'r.id = RobotsParts.robots_id', 'r', 'LEFT'); *</code> */ PHP_METHOD(Phalcon_Mvc_Model_Criteria, join) { zval *_1$$4; zval *model_param = NULL, *conditions = NULL, *alias = NULL, *type = NULL, *join = NULL, *mergedJoins = NULL, *currentJoins = NULL, *_0, *_2; zval *model = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 3, &model_param, &conditions, &alias, &type); if (unlikely(Z_TYPE_P(model_param) != IS_STRING && Z_TYPE_P(model_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'model' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(model_param) == IS_STRING)) { zephir_get_strval(model, model_param); } else { ZEPHIR_INIT_VAR(model); ZVAL_EMPTY_STRING(model); } if (!conditions) { conditions = ZEPHIR_GLOBAL(global_null); } if (!alias) { alias = ZEPHIR_GLOBAL(global_null); } if (!type) { type = ZEPHIR_GLOBAL(global_null); } ZEPHIR_INIT_VAR(join); zephir_create_array(join, 4, 0 TSRMLS_CC); zephir_array_fast_append(join, model); zephir_array_fast_append(join, conditions); zephir_array_fast_append(join, alias); zephir_array_fast_append(join, type); ZEPHIR_OBS_VAR(currentJoins); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_params"), PH_NOISY_CC); if (zephir_array_isset_string_fetch(¤tJoins, _0, SS("joins"), 0 TSRMLS_CC)) { if (Z_TYPE_P(currentJoins) == IS_ARRAY) { ZEPHIR_INIT_VAR(_1$$4); zephir_create_array(_1$$4, 1, 0 TSRMLS_CC); zephir_array_fast_append(_1$$4, join); ZEPHIR_INIT_VAR(mergedJoins); zephir_fast_array_merge(mergedJoins, &(currentJoins), &(_1$$4) TSRMLS_CC); } else { ZEPHIR_INIT_NVAR(mergedJoins); zephir_create_array(mergedJoins, 1, 0 TSRMLS_CC); zephir_array_fast_append(mergedJoins, join); } } else { ZEPHIR_INIT_NVAR(mergedJoins); zephir_create_array(mergedJoins, 1, 0 TSRMLS_CC); zephir_array_fast_append(mergedJoins, join); } ZEPHIR_INIT_VAR(_2); ZVAL_STRING(_2, "joins", 1); zephir_update_property_array(this_ptr, SL("_params"), _2, mergedJoins TSRMLS_CC); RETURN_THIS(); }
/** * Bind models into params in proper handler */ PHP_METHOD(Phalcon_Mvc_Model_Binder, bindToHandler) { zend_class_entry *_6$$5; HashTable *_4$$4; HashPosition _3$$4; zend_bool _1; int ZEPHIR_LAST_CALL_STATUS; zval *cacheKey = NULL; zval *params = NULL; zval *handler, *params_param = NULL, *cacheKey_param = NULL, *methodName = NULL, *paramKey = NULL, *className = NULL, *boundModel = NULL, *paramsCache = NULL, *paramValue = NULL, *_0, *_2$$3, **_5$$4; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 3, 1, &handler, ¶ms_param, &cacheKey_param, &methodName); zephir_get_arrval(params, params_param); zephir_get_strval(cacheKey, cacheKey_param); if (!methodName) { methodName = ZEPHIR_GLOBAL(global_null); } ZEPHIR_INIT_VAR(_0); array_init(_0); zephir_update_property_this(this_ptr, SL("originalValues"), _0 TSRMLS_CC); _1 = zephir_instance_of_ev(handler, zend_ce_closure TSRMLS_CC); if (!(_1)) { _1 = Z_TYPE_P(methodName) != IS_NULL; } if (_1) { ZEPHIR_INIT_VAR(_2$$3); array_init(_2$$3); zephir_update_property_this(this_ptr, SL("boundModels"), _2$$3 TSRMLS_CC); ZEPHIR_CALL_METHOD(¶msCache, this_ptr, "getparamsfromcache", NULL, 0, cacheKey); zephir_check_call_status(); if (Z_TYPE_P(paramsCache) == IS_ARRAY) { zephir_is_iterable(paramsCache, &_4$$4, &_3$$4, 0, 0, "phalcon/mvc/model/binder.zep", 102); for ( ; zend_hash_get_current_data_ex(_4$$4, (void**) &_5$$4, &_3$$4) == SUCCESS ; zend_hash_move_forward_ex(_4$$4, &_3$$4) ) { ZEPHIR_GET_HMKEY(paramKey, _4$$4, _3$$4); ZEPHIR_GET_HVALUE(className, _5$$4); ZEPHIR_OBS_NVAR(paramValue); zephir_array_fetch(¶mValue, params, paramKey, PH_NOISY, "phalcon/mvc/model/binder.zep", 95 TSRMLS_CC); _6$$5 = zephir_fetch_class(className TSRMLS_CC); ZEPHIR_CALL_CE_STATIC(&boundModel, _6$$5, "findfirst", NULL, 0, paramValue); zephir_check_call_status(); zephir_update_property_array(this_ptr, SL("originalValues"), paramKey, paramValue TSRMLS_CC); zephir_array_update_zval(¶ms, paramKey, &boundModel, PH_COPY | PH_SEPARATE); zephir_update_property_array(this_ptr, SL("boundModels"), paramKey, boundModel TSRMLS_CC); } RETURN_CTOR(params); } ZEPHIR_RETURN_CALL_METHOD(this_ptr, "getparamsfromreflection", NULL, 0, handler, params, cacheKey, methodName); zephir_check_call_status(); RETURN_MM(); } ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "You must specify methodName for handler or pass Closure as handler", "phalcon/mvc/model/binder.zep", 107); return; }
/** * Appends a condition to the current conditions using an OR operator */ PHP_METHOD(Phalcon_Mvc_Model_Criteria, orWhere) { zval *conditions_param = NULL, *bindParams = NULL, *bindTypes = NULL, *currentBindParams = NULL, *mergedParams = NULL, *mergedParamsTypes = NULL, *currentBindTypes = NULL, *params = NULL, *currentConditions = NULL, *_0$$3, *_1$$3, *_2$$4, *_3$$5, *_4$$8; zval *conditions = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 2, &conditions_param, &bindParams, &bindTypes); if (unlikely(Z_TYPE_P(conditions_param) != IS_STRING && Z_TYPE_P(conditions_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'conditions' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(conditions_param) == IS_STRING)) { zephir_get_strval(conditions, conditions_param); } else { ZEPHIR_INIT_VAR(conditions); ZVAL_EMPTY_STRING(conditions); } if (!bindParams) { bindParams = ZEPHIR_GLOBAL(global_null); } if (!bindTypes) { bindTypes = ZEPHIR_GLOBAL(global_null); } ZEPHIR_OBS_VAR(params); zephir_read_property_this(¶ms, this_ptr, SL("_params"), PH_NOISY_CC); ZEPHIR_OBS_VAR(currentConditions); if (zephir_array_isset_string_fetch(¤tConditions, params, SS("conditions"), 0 TSRMLS_CC)) { ZEPHIR_INIT_VAR(_0$$3); ZEPHIR_CONCAT_SVSVS(_0$$3, "(", currentConditions, ") OR (", conditions, ")"); ZEPHIR_INIT_VAR(_1$$3); ZVAL_STRING(_1$$3, "conditions", 1); zephir_update_property_array(this_ptr, SL("_params"), _1$$3, _0$$3 TSRMLS_CC); } else { ZEPHIR_INIT_VAR(_2$$4); ZVAL_STRING(_2$$4, "conditions", 1); zephir_update_property_array(this_ptr, SL("_params"), _2$$4, conditions TSRMLS_CC); } if (Z_TYPE_P(bindParams) == IS_ARRAY) { ZEPHIR_OBS_VAR(currentBindParams); if (zephir_array_isset_string_fetch(¤tBindParams, params, SS("bind"), 0 TSRMLS_CC)) { ZEPHIR_INIT_VAR(mergedParams); zephir_fast_array_merge(mergedParams, &(currentBindParams), &(bindParams) TSRMLS_CC); } else { ZEPHIR_CPY_WRT(mergedParams, bindParams); } ZEPHIR_INIT_VAR(_3$$5); ZVAL_STRING(_3$$5, "bind", 1); zephir_update_property_array(this_ptr, SL("_params"), _3$$5, mergedParams TSRMLS_CC); } if (Z_TYPE_P(bindTypes) == IS_ARRAY) { ZEPHIR_OBS_VAR(currentBindTypes); if (zephir_array_isset_string_fetch(¤tBindTypes, params, SS("bindTypes"), 0 TSRMLS_CC)) { ZEPHIR_INIT_VAR(mergedParamsTypes); zephir_fast_array_merge(mergedParamsTypes, &(currentBindTypes), &(bindTypes) TSRMLS_CC); } else { ZEPHIR_CPY_WRT(mergedParamsTypes, bindTypes); } ZEPHIR_INIT_VAR(_4$$8); ZVAL_STRING(_4$$8, "bindTypes", 1); zephir_update_property_array(this_ptr, SL("_params"), _4$$8, mergedParamsTypes TSRMLS_CC); } RETURN_THIS(); }
/** * Adds an element to the form */ PHP_METHOD(Phalcon_Forms_Form, add) { HashTable *_4$$4; HashPosition _3$$4; zend_long ZEPHIR_LAST_CALL_STATUS; zend_bool type, _0; zval *position = NULL; zval *element, *position_param = NULL, *type_param = NULL, *name = NULL, *key = NULL, *value = NULL, *elements = NULL, *_1, *_2$$4, **_5$$4; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 2, &element, &position_param, &type_param); if (!position_param) { ZEPHIR_INIT_VAR(position); ZVAL_EMPTY_STRING(position); } else { zephir_get_strval(position, position_param); } if (!type_param) { type = 0; } else { type = zephir_get_boolval(type_param); } ZEPHIR_CALL_METHOD(&name, element, "getname", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, element, "setform", NULL, 0, this_ptr); zephir_check_call_status(); _0 = ZEPHIR_IS_STRING(position, ""); if (!(_0)) { _1 = zephir_fetch_nproperty_this(this_ptr, SL("_elements"), PH_NOISY_CC); _0 = ZEPHIR_IS_EMPTY(_1); } if (_0) { zephir_update_property_array(this_ptr, SL("_elements"), name, element TSRMLS_CC); } else { ZEPHIR_INIT_VAR(elements); array_init(elements); _2$$4 = zephir_fetch_nproperty_this(this_ptr, SL("_elements"), PH_NOISY_CC); zephir_is_iterable(_2$$4, &_4$$4, &_3$$4, 0, 0, "phalcon/forms/form.zep", 449); for ( ; zend_hash_get_current_data_ex(_4$$4, (void**) &_5$$4, &_3$$4) == SUCCESS ; zend_hash_move_forward_ex(_4$$4, &_3$$4) ) { ZEPHIR_GET_HMKEY(key, _4$$4, _3$$4); ZEPHIR_GET_HVALUE(value, _5$$4); if (ZEPHIR_IS_EQUAL(key, position)) { if (type) { zephir_array_update_zval(&elements, name, &element, PH_COPY | PH_SEPARATE); zephir_array_update_zval(&elements, key, &value, PH_COPY | PH_SEPARATE); } else { zephir_array_update_zval(&elements, key, &value, PH_COPY | PH_SEPARATE); zephir_array_update_zval(&elements, name, &element, PH_COPY | PH_SEPARATE); } } else { zephir_array_update_zval(&elements, key, &value, PH_COPY | PH_SEPARATE); } } zephir_update_property_this(getThis(), SL("_elements"), elements TSRMLS_CC); } RETURN_THIS(); }
/** * Sets a cookie to be sent at the end of the request * This method overrides any cookie set before with the same name */ PHP_METHOD(Phalcon_Http_Response_Cookies, set) { zval *_3$$3; zend_bool secure, httpOnly; int expire, ZEPHIR_LAST_CALL_STATUS; zval *name_param = NULL, *value = NULL, *expire_param = NULL, *path_param = NULL, *secure_param = NULL, *domain_param = NULL, *httpOnly_param = NULL, *cookie = NULL, *encryption = NULL, *dependencyInjector = NULL, *response = NULL, *_0, *_8, *_1$$3, *_2$$3 = NULL, *_4$$3 = NULL, *_5$$3, *_6$$5 = NULL, *_7$$5, *_9$$6; zval *name = NULL, *path = NULL, *domain = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 6, &name_param, &value, &expire_param, &path_param, &secure_param, &domain_param, &httpOnly_param); if (unlikely(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 (likely(Z_TYPE_P(name_param) == IS_STRING)) { zephir_get_strval(name, name_param); } else { ZEPHIR_INIT_VAR(name); ZVAL_EMPTY_STRING(name); } if (!value) { value = ZEPHIR_GLOBAL(global_null); } if (!expire_param) { expire = 0; } else { expire = zephir_get_intval(expire_param); } if (!path_param) { ZEPHIR_INIT_VAR(path); ZVAL_STRING(path, "/", 1); } else { zephir_get_strval(path, path_param); } if (!secure_param) { secure = 0; } else { secure = zephir_get_boolval(secure_param); } if (!domain_param) { ZEPHIR_INIT_VAR(domain); ZVAL_EMPTY_STRING(domain); } else { if (unlikely(Z_TYPE_P(domain_param) != IS_STRING && Z_TYPE_P(domain_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'domain' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(domain_param) == IS_STRING)) { zephir_get_strval(domain, domain_param); } else { ZEPHIR_INIT_VAR(domain); ZVAL_EMPTY_STRING(domain); } } if (!httpOnly_param) { httpOnly = 0; } else { httpOnly = zephir_get_boolval(httpOnly_param); } ZEPHIR_OBS_VAR(encryption); zephir_read_property_this(&encryption, this_ptr, SL("_useEncryption"), PH_NOISY_CC); ZEPHIR_OBS_VAR(cookie); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_cookies"), PH_NOISY_CC); if (!(zephir_array_isset_fetch(&cookie, _0, name, 0 TSRMLS_CC))) { _1$$3 = zephir_fetch_nproperty_this(this_ptr, SL("_dependencyInjector"), PH_NOISY_CC); ZEPHIR_INIT_VAR(_3$$3); zephir_create_array(_3$$3, 7, 0 TSRMLS_CC); zephir_array_fast_append(_3$$3, name); zephir_array_fast_append(_3$$3, value); ZEPHIR_INIT_VAR(_4$$3); ZVAL_LONG(_4$$3, expire); zephir_array_fast_append(_3$$3, _4$$3); zephir_array_fast_append(_3$$3, path); ZEPHIR_INIT_NVAR(_4$$3); ZVAL_BOOL(_4$$3, secure); zephir_array_fast_append(_3$$3, _4$$3); zephir_array_fast_append(_3$$3, domain); ZEPHIR_INIT_NVAR(_4$$3); ZVAL_BOOL(_4$$3, httpOnly); zephir_array_fast_append(_3$$3, _4$$3); ZEPHIR_INIT_NVAR(_4$$3); ZVAL_STRING(_4$$3, "Phalcon\\Http\\Cookie", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_2$$3, _1$$3, "get", NULL, 0, _4$$3, _3$$3); zephir_check_temp_parameter(_4$$3); zephir_check_call_status(); ZEPHIR_CPY_WRT(cookie, _2$$3); _5$$3 = zephir_fetch_nproperty_this(this_ptr, SL("_dependencyInjector"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(NULL, cookie, "setdi", NULL, 0, _5$$3); zephir_check_call_status(); if (zephir_is_true(encryption)) { ZEPHIR_CALL_METHOD(NULL, cookie, "useencryption", NULL, 0, encryption); zephir_check_call_status(); } zephir_update_property_array(this_ptr, SL("_cookies"), name, cookie TSRMLS_CC); } else { ZEPHIR_CALL_METHOD(NULL, cookie, "setvalue", NULL, 0, value); zephir_check_call_status(); ZEPHIR_INIT_VAR(_6$$5); ZVAL_LONG(_6$$5, expire); ZEPHIR_CALL_METHOD(NULL, cookie, "setexpiration", NULL, 0, _6$$5); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, cookie, "setpath", NULL, 0, path); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_6$$5); if (secure) { ZVAL_BOOL(_6$$5, 1); } else { ZVAL_BOOL(_6$$5, 0); } ZEPHIR_CALL_METHOD(NULL, cookie, "setsecure", NULL, 0, _6$$5); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, cookie, "setdomain", NULL, 0, domain); zephir_check_call_status(); ZEPHIR_INIT_VAR(_7$$5); if (httpOnly) { ZVAL_BOOL(_7$$5, 1); } else { ZVAL_BOOL(_7$$5, 0); } ZEPHIR_CALL_METHOD(NULL, cookie, "sethttponly", NULL, 0, _7$$5); zephir_check_call_status(); } _8 = zephir_fetch_nproperty_this(this_ptr, SL("_registered"), PH_NOISY_CC); if (ZEPHIR_IS_FALSE_IDENTICAL(_8)) { ZEPHIR_OBS_VAR(dependencyInjector); zephir_read_property_this(&dependencyInjector, this_ptr, SL("_dependencyInjector"), PH_NOISY_CC); if (Z_TYPE_P(dependencyInjector) != IS_OBJECT) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_http_cookie_exception_ce, "A dependency injection object is required to access the 'response' service", "phalcon/http/response/cookies.zep", 130); return; } ZEPHIR_INIT_VAR(_9$$6); ZVAL_STRING(_9$$6, "response", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&response, dependencyInjector, "getshared", NULL, 0, _9$$6); zephir_check_temp_parameter(_9$$6); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, response, "setcookies", NULL, 0, this_ptr); zephir_check_call_status(); if (1) { zephir_update_property_this(this_ptr, SL("_registered"), ZEPHIR_GLOBAL(global_true) TSRMLS_CC); } else { zephir_update_property_this(this_ptr, SL("_registered"), ZEPHIR_GLOBAL(global_false) TSRMLS_CC); } } RETURN_THIS(); }
/** * Executes the event listeners; sorts, calls, and returns result. * * @param \Xpl\Event\Event event Event object. * @param array listeners Array of Listener objects. * @param array args Callback arguments. * @return array Array of event callback results. */ PHP_METHOD(Xpl_Event_Manager, execute) { HashTable *_3; HashPosition _2; zephir_fcall_cache_entry *_7 = NULL; int ZEPHIR_LAST_CALL_STATUS; zval *listeners = NULL, *args = NULL, *_0, *_8; zval *event, *listeners_param = NULL, *args_param = NULL, *results = NULL, *listener = NULL, *value = NULL, *_1, **_4, *_9 = NULL, *_5$$4 = NULL, *_6$$3 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 1, &event, &listeners_param, &args_param); ZEPHIR_SEPARATE_PARAM(event); listeners = listeners_param; if (!args_param) { ZEPHIR_INIT_VAR(args); array_init(args); } else { args = args_param; } ZEPHIR_INIT_VAR(results); array_init(results); ZEPHIR_INIT_VAR(_0); zephir_create_array(_0, 2, 0 TSRMLS_CC); zephir_array_fast_append(_0, this_ptr); ZEPHIR_OBS_VAR(_1); zephir_read_property_this(&_1, this_ptr, SL("sortFunction"), PH_NOISY_CC); zephir_array_fast_append(_0, _1); ZEPHIR_MAKE_REF(listeners); ZEPHIR_CALL_FUNCTION(NULL, "usort", NULL, 85, listeners, _0); ZEPHIR_UNREF(listeners); zephir_check_call_status(); ZEPHIR_MAKE_REF(args); ZEPHIR_CALL_FUNCTION(NULL, "array_unshift", NULL, 80, args, event); ZEPHIR_UNREF(args); zephir_check_call_status(); zephir_is_iterable(listeners, &_3, &_2, 0, 0, "xpl/event/manager.zep", 427); for ( ; zephir_hash_get_current_data_ex(_3, (void**) &_4, &_2) == SUCCESS ; zephir_hash_move_forward_ex(_3, &_2) ) { ZEPHIR_GET_HVALUE(listener, _4); ZEPHIR_CALL_ZVAL_FUNCTION(&value, listener, NULL, 0, args); zephir_check_call_status(); zephir_array_append(&results, value, PH_SEPARATE, "xpl/event/manager.zep", 408); if (Z_TYPE_P(value) != IS_NULL) { ZEPHIR_OBS_NVAR(_5$$4); zephir_read_property(&_5$$4, event, SL("value"), PH_NOISY_CC); if (!ZEPHIR_IS_IDENTICAL(value, _5$$4)) { zephir_update_property_zval(event, SL("value"), value TSRMLS_CC); } } ZEPHIR_INIT_NVAR(value); ZVAL_NULL(value); ZEPHIR_CALL_METHOD(&_6$$3, event, "ispropagationstopped", &_7, 105); zephir_check_call_status(); if (zephir_is_true(_6$$3)) { break; } } ZEPHIR_INIT_VAR(_8); zephir_create_array(_8, 2, 0 TSRMLS_CC); zephir_array_update_string(&_8, SL("event"), &event, PH_COPY | PH_SEPARATE); zephir_array_update_string(&_8, SL("result"), &results, PH_COPY | PH_SEPARATE); ZEPHIR_CALL_METHOD(&_9, event, "getid", NULL, 0); zephir_check_call_status(); zephir_update_property_array(this_ptr, SL("completed"), _9, _8 TSRMLS_CC); RETURN_CCTOR(results); }
/** * Sets a cookie to be sent at the end of the request * This method overrides any cookie set before with the same name * * @param string name * @param mixed value * @param int expire * @param string path * @param boolean secure * @param string domain * @param boolean httpOnly * @return Phalcon\Http\Response\Cookies */ PHP_METHOD(Phalcon_Http_Response_Cookies, set) { int expire, ZEPHIR_LAST_CALL_STATUS; zval *name_param = NULL, *value = NULL, *expire_param = NULL, *path_param = NULL, *secure = NULL, *domain_param = NULL, *httpOnly = NULL, *cookie = NULL, *encryption, *dependencyInjector, *response = NULL, *_0, *_1 = NULL, *_2; zval *name = NULL, *path = NULL, *domain = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 6, &name_param, &value, &expire_param, &path_param, &secure, &domain_param, &httpOnly); if (unlikely(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 (likely(Z_TYPE_P(name_param) == IS_STRING)) { zephir_get_strval(name, name_param); } else { ZEPHIR_INIT_VAR(name); ZVAL_EMPTY_STRING(name); } if (!value) { value = ZEPHIR_GLOBAL(global_null); } if (!expire_param) { expire = 0; } else { expire = zephir_get_intval(expire_param); } if (!path_param) { ZEPHIR_INIT_VAR(path); ZVAL_STRING(path, "/", 1); } else { zephir_get_strval(path, path_param); } if (!secure) { secure = ZEPHIR_GLOBAL(global_null); } if (!domain_param) { ZEPHIR_INIT_VAR(domain); ZVAL_EMPTY_STRING(domain); } else { if (unlikely(Z_TYPE_P(domain_param) != IS_STRING && Z_TYPE_P(domain_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'domain' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(domain_param) == IS_STRING)) { zephir_get_strval(domain, domain_param); } else { ZEPHIR_INIT_VAR(domain); ZVAL_EMPTY_STRING(domain); } } if (!httpOnly) { httpOnly = ZEPHIR_GLOBAL(global_null); } ZEPHIR_OBS_VAR(encryption); zephir_read_property_this(&encryption, this_ptr, SL("_useEncryption"), PH_NOISY_CC); ZEPHIR_OBS_VAR(cookie); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_cookies"), PH_NOISY_CC); if (!(zephir_array_isset_fetch(&cookie, _0, name, 0 TSRMLS_CC))) { ZEPHIR_INIT_NVAR(cookie); object_init_ex(cookie, phalcon_http_cookie_ce); ZEPHIR_INIT_VAR(_1); ZVAL_LONG(_1, expire); ZEPHIR_CALL_METHOD(NULL, cookie, "__construct", NULL, 215, name, value, _1, path, secure, domain, httpOnly); zephir_check_call_status(); _2 = zephir_fetch_nproperty_this(this_ptr, SL("_dependencyInjector"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(NULL, cookie, "setdi", NULL, 216, _2); zephir_check_call_status(); if (zephir_is_true(encryption)) { ZEPHIR_CALL_METHOD(NULL, cookie, "useencryption", NULL, 217, encryption); zephir_check_call_status(); } zephir_update_property_array(this_ptr, SL("_cookies"), name, cookie TSRMLS_CC); } else { ZEPHIR_CALL_METHOD(NULL, cookie, "setvalue", NULL, 218, value); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_1); ZVAL_LONG(_1, expire); ZEPHIR_CALL_METHOD(NULL, cookie, "setexpiration", NULL, 219, _1); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, cookie, "setpath", NULL, 220, path); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, cookie, "setsecure", NULL, 221, secure); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, cookie, "setdomain", NULL, 222, domain); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, cookie, "sethttponly", NULL, 223, httpOnly); zephir_check_call_status(); } _2 = zephir_fetch_nproperty_this(this_ptr, SL("_registered"), PH_NOISY_CC); if (ZEPHIR_IS_FALSE_IDENTICAL(_2)) { ZEPHIR_OBS_VAR(dependencyInjector); zephir_read_property_this(&dependencyInjector, this_ptr, SL("_dependencyInjector"), PH_NOISY_CC); if (Z_TYPE_P(dependencyInjector) != IS_OBJECT) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_http_cookie_exception_ce, "A dependency injection object is required to access the 'response' service", "phalcon/http/response/cookies.zep", 138); return; } ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "response", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&response, dependencyInjector, "getshared", NULL, 0, _1); zephir_check_temp_parameter(_1); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, response, "setcookies", NULL, 0, this_ptr); zephir_check_call_status(); } RETURN_THIS(); }
/** * 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); }
/** * 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(); }