/** * Sets field name related to message */ PHP_METHOD(Phalcon_Validation_Message, setField) { zval *field_param = NULL; zval *field = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &field_param); if (unlikely(Z_TYPE_P(field_param) != IS_STRING && Z_TYPE_P(field_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'field' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(field_param) == IS_STRING)) { zephir_get_strval(field, field_param); } else { ZEPHIR_INIT_VAR(field); ZVAL_EMPTY_STRING(field); } zephir_update_property_this(this_ptr, SL("_field"), field TSRMLS_CC); RETURN_THIS(); }
/** * Set a single view parameter * *<code> * $this->view->setVar("products", $products); *</code> */ PHP_METHOD(Phalcon_Mvc_View_Simple, setVar) { 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); RETURN_THIS(); }
/** * Applies a callback function to each item in the object * * @param callable callback * @param mixed userdata [Optional] */ PHP_METHOD(Xpl_Collection_ArrayObject, walk) { int ZEPHIR_LAST_CALL_STATUS; zval *callback, *userdata = NULL, *data = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &callback, &userdata); if (!userdata) { userdata = ZEPHIR_GLOBAL(global_null); } ZEPHIR_CALL_METHOD(&data, this_ptr, "getarraycopy", NULL, 0); zephir_check_call_status(); ZEPHIR_MAKE_REF(data); ZEPHIR_CALL_FUNCTION(NULL, "array_walk", NULL, 72, data, callback, userdata); ZEPHIR_UNREF(data); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, this_ptr, "exchangearray", NULL, 0, data); zephir_check_call_status(); RETURN_THIS(); }
/** * Sets a hostname restriction to the route * *<code> * $route->setHostname('localhost'); *</code> */ PHP_METHOD(Phalcon_Mvc_Router_Route, setHostname) { zval *hostname_param = NULL; zval *hostname = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &hostname_param); if (unlikely(Z_TYPE_P(hostname_param) != IS_STRING && Z_TYPE_P(hostname_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'hostname' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(hostname_param) == IS_STRING)) { zephir_get_strval(hostname, hostname_param); } else { ZEPHIR_INIT_VAR(hostname); ZVAL_EMPTY_STRING(hostname); } zephir_update_property_this(this_ptr, SL("_hostname"), hostname TSRMLS_CC); RETURN_THIS(); }
/** * 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 the element name */ PHP_METHOD(Phalcon_Forms_Element, setName) { zval *name_param = NULL; 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_update_property_this(getThis(), SL("_name"), name TSRMLS_CC); RETURN_THIS(); }
/** * Sets a prefix for all routes added to the collection */ PHP_METHOD(Phalcon_Mvc_Micro_Collection, setPrefix) { zval *prefix_param = NULL; zval *prefix = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &prefix_param); if (UNEXPECTED(Z_TYPE_P(prefix_param) != IS_STRING && Z_TYPE_P(prefix_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'prefix' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (EXPECTED(Z_TYPE_P(prefix_param) == IS_STRING)) { zephir_get_strval(prefix, prefix_param); } else { ZEPHIR_INIT_VAR(prefix); ZVAL_EMPTY_STRING(prefix); } zephir_update_property_this(getThis(), SL("_prefix"), prefix TSRMLS_CC); RETURN_THIS(); }
/** * Externally sets the view content * *<code> * $this->view->setContent("<h1>hello</h1>"); *</code> */ PHP_METHOD(Phalcon_Mvc_View_Simple, setContent) { zval *content_param = NULL; zval *content = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &content_param); if (unlikely(Z_TYPE_P(content_param) != IS_STRING && Z_TYPE_P(content_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'content' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(content_param) == IS_STRING)) { zephir_get_strval(content, content_param); } else { ZEPHIR_INIT_VAR(content); ZVAL_EMPTY_STRING(content); } zephir_update_property_this(this_ptr, SL("_content"), content TSRMLS_CC); RETURN_THIS(); }
/** * Sets the form's action */ PHP_METHOD(Phalcon_Forms_Form, setAction) { zval *action_param = NULL; zval *action = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &action_param); if (UNEXPECTED(Z_TYPE_P(action_param) != IS_STRING && Z_TYPE_P(action_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'action' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (EXPECTED(Z_TYPE_P(action_param) == IS_STRING)) { zephir_get_strval(action, action_param); } else { ZEPHIR_INIT_VAR(action); ZVAL_EMPTY_STRING(action); } zephir_update_property_this(this_ptr, SL("_action"), action TSRMLS_CC); RETURN_THIS(); }
/** * Sets a base path for all the generated paths * *<code> * $url->setBasePath("/var/www/htdocs/"); *</code> */ PHP_METHOD(Phalcon_Mvc_Url, setBasePath) { zval *basePath_param = NULL; zval *basePath = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &basePath_param); if (UNEXPECTED(Z_TYPE_P(basePath_param) != IS_STRING && Z_TYPE_P(basePath_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'basePath' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (EXPECTED(Z_TYPE_P(basePath_param) == IS_STRING)) { zephir_get_strval(basePath, basePath_param); } else { ZEPHIR_INIT_VAR(basePath); ZVAL_EMPTY_STRING(basePath); } zephir_update_property_this(getThis(), SL("_basePath"), basePath TSRMLS_CC); RETURN_THIS(); }
/** * Sets the cipher algorithm */ PHP_METHOD(Phalcon_Crypt, setCipher) { zval *cipher_param = NULL; zval *cipher = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &cipher_param); if (UNEXPECTED(Z_TYPE_P(cipher_param) != IS_STRING && Z_TYPE_P(cipher_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'cipher' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (EXPECTED(Z_TYPE_P(cipher_param) == IS_STRING)) { zephir_get_strval(cipher, cipher_param); } else { ZEPHIR_INIT_VAR(cipher); ZVAL_EMPTY_STRING(cipher); } zephir_update_property_this(getThis(), SL("_cipher"), cipher TSRMLS_CC); RETURN_THIS(); }
/** * Sets verbose message */ PHP_METHOD(Phalcon_Mvc_Model_Message, setMessage) { zval *message_param = NULL; zval *message = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &message_param); if (unlikely(Z_TYPE_P(message_param) != IS_STRING && Z_TYPE_P(message_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'message' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(message_param) == IS_STRING)) { zephir_get_strval(message, message_param); } else { ZEPHIR_INIT_VAR(message); ZVAL_EMPTY_STRING(message); } zephir_update_property_this(this_ptr, SL("_message"), message TSRMLS_CC); RETURN_THIS(); }
/** * Sets a base source path for all the resources in this collection */ PHP_METHOD(Phalcon_Assets_Collection, setSourcePath) { zval *sourcePath_param = NULL; zval *sourcePath = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &sourcePath_param); if (unlikely(Z_TYPE_P(sourcePath_param) != IS_STRING && Z_TYPE_P(sourcePath_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'sourcePath' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(sourcePath_param) == IS_STRING)) { zephir_get_strval(sourcePath, sourcePath_param); } else { ZEPHIR_INIT_VAR(sourcePath); ZVAL_EMPTY_STRING(sourcePath); } zephir_update_property_this(this_ptr, SL("_sourcePath"), sourcePath TSRMLS_CC); RETURN_THIS(); }
/** * Sets event type. */ PHP_METHOD(Phalcon_Events_Event, setType) { zval *type_param = NULL; zval *type = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &type_param); if (unlikely(Z_TYPE_P(type_param) != IS_STRING && Z_TYPE_P(type_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'type' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(type_param) == IS_STRING)) { zephir_get_strval(type, type_param); } else { ZEPHIR_INIT_VAR(type); ZVAL_EMPTY_STRING(type); } zephir_update_property_this(this_ptr, SL("_type"), type 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(); }
/** * Binds data to the entity * * @param array data * @param object entity * @param array whitelist */ PHP_METHOD(Phalcon_Forms_Form, bind) { HashTable *_2; HashPosition _1; zephir_fcall_cache_entry *_5 = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; zval *data_param = NULL, *entity, *whitelist = NULL, *filter = NULL, *key = NULL, *value = NULL, *element = NULL, *filters = NULL, *dependencyInjector = NULL, *filteredValue = NULL, *method = NULL, *_0, **_3, *_4$$4, *_8$$4 = NULL, *_6$$9 = NULL, *_7$$9 = NULL; zval *data = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 1, &data_param, &entity, &whitelist); data = data_param; ZEPHIR_SEPARATE_PARAM(entity); if (!whitelist) { whitelist = ZEPHIR_GLOBAL(global_null); } _0 = zephir_fetch_nproperty_this(this_ptr, SL("_elements"), PH_NOISY_CC); if (ZEPHIR_IS_EMPTY(_0)) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_forms_exception_ce, "There are no elements in the form", "phalcon/forms/form.zep", 189); return; } ZEPHIR_INIT_VAR(filter); ZVAL_NULL(filter); zephir_is_iterable(data, &_2, &_1, 0, 0, "phalcon/forms/form.zep", 246); for ( ; zend_hash_get_current_data_ex(_2, (void**) &_3, &_1) == SUCCESS ; zend_hash_move_forward_ex(_2, &_1) ) { ZEPHIR_GET_HMKEY(key, _2, _1); ZEPHIR_GET_HVALUE(value, _3); ZEPHIR_OBS_NVAR(element); _4$$4 = zephir_fetch_nproperty_this(this_ptr, SL("_elements"), PH_NOISY_CC); if (!(zephir_array_isset_fetch(&element, _4$$4, key, 0 TSRMLS_CC))) { continue; } if (Z_TYPE_P(whitelist) == IS_ARRAY) { if (!(zephir_fast_in_array(key, whitelist TSRMLS_CC))) { continue; } } ZEPHIR_CALL_METHOD(&filters, element, "getfilters", NULL, 0); zephir_check_call_status(); if (zephir_is_true(filters)) { if (Z_TYPE_P(filter) != IS_OBJECT) { ZEPHIR_CALL_METHOD(&dependencyInjector, this_ptr, "getdi", &_5, 0); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_7$$9); ZVAL_STRING(_7$$9, "filter", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_6$$9, dependencyInjector, "getshared", NULL, 0, _7$$9); zephir_check_temp_parameter(_7$$9); zephir_check_call_status(); ZEPHIR_CPY_WRT(filter, _6$$9); } ZEPHIR_CALL_METHOD(&filteredValue, filter, "sanitize", NULL, 0, value, filters); zephir_check_call_status(); } else { ZEPHIR_CPY_WRT(filteredValue, value); } ZEPHIR_INIT_NVAR(_8$$4); zephir_camelize(_8$$4, key, NULL ); ZEPHIR_INIT_NVAR(method); ZEPHIR_CONCAT_SV(method, "set", _8$$4); if ((zephir_method_exists(entity, method TSRMLS_CC) == SUCCESS)) { ZEPHIR_CALL_METHOD_ZVAL(NULL, entity, method, NULL, 0, filteredValue); zephir_check_call_status(); continue; } zephir_update_property_zval_zval(entity, key, filteredValue TSRMLS_CC); } zephir_update_property_this(getThis(), SL("_data"), data TSRMLS_CC); RETURN_THIS(); }
/** * Clears every element in the form to its default value * * @param array fields */ PHP_METHOD(Phalcon_Forms_Form, clear) { HashTable *_1$$5, *_4$$10; HashPosition _0$$5, _3$$10; zend_long ZEPHIR_LAST_CALL_STATUS; zval *fields = NULL, *elements = NULL, *element = NULL, *data = NULL, *field = NULL, **_2$$5, **_5$$10, *_6$$13 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 1, &fields); if (!fields) { fields = ZEPHIR_GLOBAL(global_null); } ZEPHIR_OBS_VAR(data); zephir_read_property_this(&data, this_ptr, SL("_data"), PH_NOISY_CC); if (Z_TYPE_P(fields) == IS_NULL) { ZEPHIR_INIT_NVAR(data); array_init(data); } else { if (Z_TYPE_P(fields) == IS_ARRAY) { zephir_is_iterable(fields, &_1$$5, &_0$$5, 0, 0, "phalcon/forms/form.zep", 652); for ( ; zend_hash_get_current_data_ex(_1$$5, (void**) &_2$$5, &_0$$5) == SUCCESS ; zend_hash_move_forward_ex(_1$$5, &_0$$5) ) { ZEPHIR_GET_HVALUE(field, _2$$5); if (zephir_array_isset(data, field)) { zephir_array_unset(&data, field, PH_SEPARATE); } } } else { if (zephir_array_isset(data, field)) { zephir_array_unset(&data, field, PH_SEPARATE); } } } zephir_update_property_this(getThis(), SL("_data"), data TSRMLS_CC); ZEPHIR_OBS_VAR(elements); zephir_read_property_this(&elements, this_ptr, SL("_elements"), PH_NOISY_CC); if (Z_TYPE_P(elements) == IS_ARRAY) { zephir_is_iterable(elements, &_4$$10, &_3$$10, 0, 0, "phalcon/forms/form.zep", 672); for ( ; zend_hash_get_current_data_ex(_4$$10, (void**) &_5$$10, &_3$$10) == SUCCESS ; zend_hash_move_forward_ex(_4$$10, &_3$$10) ) { ZEPHIR_GET_HVALUE(element, _5$$10); if (Z_TYPE_P(fields) != IS_ARRAY) { ZEPHIR_CALL_METHOD(NULL, element, "clear", NULL, 0); zephir_check_call_status(); } else { ZEPHIR_CALL_METHOD(&_6$$13, element, "getname", NULL, 0); zephir_check_call_status(); if (zephir_fast_in_array(_6$$13, fields TSRMLS_CC)) { ZEPHIR_CALL_METHOD(NULL, element, "clear", NULL, 0); zephir_check_call_status(); } } } } RETURN_THIS(); }
/** * Logs messages to the internal logger. Appends logs to the logger */ PHP_METHOD(Phalcon_Logger_Adapter, log) { int ZEPHIR_LAST_CALL_STATUS; zend_bool _0, _1; zval *context = NULL; zval *type, *message = NULL, *context_param = NULL, *timestamp, *toggledMessage = NULL, *toggledType = NULL, *_2, *_3, *_4; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 2, &type, &message, &context_param); if (!message) { message = ZEPHIR_GLOBAL(global_null); } if (!context_param) { ZEPHIR_INIT_VAR(context); array_init(context); } else { context = context_param; } _0 = Z_TYPE_P(type) == IS_STRING; if (_0) { _0 = Z_TYPE_P(message) == IS_LONG; } if (_0) { ZEPHIR_CPY_WRT(toggledMessage, type); ZEPHIR_CPY_WRT(toggledType, message); } else { _1 = Z_TYPE_P(type) == IS_STRING; if (_1) { _1 = Z_TYPE_P(message) == IS_NULL; } if (_1) { ZEPHIR_CPY_WRT(toggledMessage, type); ZEPHIR_CPY_WRT(toggledType, message); } else { ZEPHIR_CPY_WRT(toggledMessage, message); ZEPHIR_CPY_WRT(toggledType, type); } } if (Z_TYPE_P(toggledType) == IS_NULL) { ZEPHIR_INIT_NVAR(toggledType); ZVAL_LONG(toggledType, 7); } _2 = zephir_fetch_nproperty_this(this_ptr, SL("_logLevel"), PH_NOISY_CC); if (ZEPHIR_GE(_2, toggledType)) { ZEPHIR_INIT_VAR(timestamp); zephir_time(timestamp); _3 = zephir_fetch_nproperty_this(this_ptr, SL("_transaction"), PH_NOISY_CC); if (zephir_is_true(_3)) { ZEPHIR_INIT_VAR(_4); object_init_ex(_4, phalcon_logger_item_ce); ZEPHIR_CALL_METHOD(NULL, _4, "__construct", NULL, 52, toggledMessage, toggledType, timestamp, context); zephir_check_call_status(); zephir_update_property_array_append(this_ptr, SL("_queue"), _4 TSRMLS_CC); } else { ZEPHIR_CALL_METHOD(NULL, this_ptr, "loginternal", NULL, 0, toggledMessage, toggledType, timestamp, context); zephir_check_call_status(); } } RETURN_THIS(); }
/** * Sets the expiration time for this cache item. * * @param int|\DateInterval time * The period of time from the present after which the item MUST be considered * expired. An integer parameter is understood to be the time in seconds until * expiration. If null is passed explicitly, a default value MAY be used. * If none is set, the value should be stored permanently or for as long as the * implementation allows. * * @return \Xpl\Cache\Item * The called object. */ PHP_METHOD(Xpl_Cache_Item, expiresAfter) { zend_class_entry *_6$$7; int ZEPHIR_LAST_CALL_STATUS; zval *time, *_0$$3, *_1$$3, *_2$$3, *_3$$5, *_4$$5, *_5$$7 = NULL, *_7$$7, *_8$$7 = NULL, *_9$$7 = NULL, *_10$$7 = NULL, *_11$$8, *_12$$8 = NULL, _13$$8, *_14$$8 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &time); if (Z_TYPE_P(time) == IS_NULL) { ZEPHIR_INIT_VAR(_0$$3); zephir_time(_0$$3); _1$$3 = zephir_fetch_nproperty_this(this_ptr, SL("defaultTtl"), PH_NOISY_CC); ZEPHIR_INIT_VAR(_2$$3); zephir_add_function(_2$$3, _0$$3, _1$$3); zephir_update_property_this(this_ptr, SL("expires"), _2$$3 TSRMLS_CC); } else { if (Z_TYPE_P(time) == IS_LONG) { ZEPHIR_INIT_VAR(_3$$5); zephir_time(_3$$5); ZEPHIR_INIT_VAR(_4$$5); zephir_add_function(_4$$5, _3$$5, time); zephir_update_property_this(this_ptr, SL("expires"), _4$$5 TSRMLS_CC); } else { if (zephir_instance_of_ev(time, zephir_get_internal_ce(SS("dateinterval") TSRMLS_CC) TSRMLS_CC)) { _6$$7 = zend_fetch_class(SL("DateTime"), ZEND_FETCH_CLASS_AUTO TSRMLS_CC); ZEPHIR_INIT_VAR(_7$$7); zephir_time(_7$$7); ZEPHIR_INIT_VAR(_8$$7); ZVAL_STRING(_8$$7, "U", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_CE_STATIC(&_5$$7, _6$$7, "createfromformat", NULL, 0, _8$$7, _7$$7); zephir_check_temp_parameter(_8$$7); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&_9$$7, _5$$7, "add", NULL, 0, time); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_8$$7); ZVAL_STRING(_8$$7, "U", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_10$$7, _9$$7, "format", NULL, 0, _8$$7); zephir_check_temp_parameter(_8$$7); zephir_check_call_status(); zephir_update_property_this(this_ptr, SL("expires"), _10$$7 TSRMLS_CC); } else { ZEPHIR_INIT_VAR(_11$$8); object_init_ex(_11$$8, xpl_cache_invalidargumentexception_ce); ZEPHIR_INIT_VAR(_12$$8); if (Z_TYPE_P(time) == IS_OBJECT) { ZEPHIR_INIT_NVAR(_12$$8); zephir_get_class(_12$$8, time, 0 TSRMLS_CC); } else { ZEPHIR_INIT_NVAR(_12$$8); zephir_gettype(_12$$8, time TSRMLS_CC); } ZEPHIR_SINIT_VAR(_13$$8); ZVAL_STRING(&_13$$8, "Expiration date must be integer, DateInterval or null, given: \"%s\".", 0); ZEPHIR_CALL_FUNCTION(&_14$$8, "sprintf", NULL, 41, &_13$$8, _12$$8); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, _11$$8, "__construct", NULL, 42, _14$$8); zephir_check_call_status(); zephir_throw_exception_debug(_11$$8, "xpl/cache/item.zep", 181 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } } } RETURN_THIS(); }
/** * Appends a NOT IN condition to the current conditions * *<code> * $criteria->notInWhere('id', [1, 2, 3]); *</code> * * @param string $expr * @param array $values * @return Phalcon\Mvc\Model\Query\Builder */ PHP_METHOD(Phalcon_Mvc_Model_Criteria, notInWhere){ zval *expr, *values, *hidden_param, *bind_params; zval *bind_keys, *value = NULL, *key = NULL, *query_key = NULL, *joined_keys; zval *conditions; HashTable *ah0; HashPosition hp0; zval **hd; PHALCON_MM_GROW(); phalcon_fetch_params(1, 2, 0, &expr, &values); if (Z_TYPE_P(values) != IS_ARRAY) { PHALCON_THROW_EXCEPTION_STR(phalcon_mvc_model_exception_ce, "Values must be an array"); return; } PHALCON_OBS_VAR(hidden_param); phalcon_read_property_this(&hidden_param, this_ptr, SL("_hiddenParamNumber"), PH_NOISY_CC); PHALCON_INIT_VAR(bind_params); array_init(bind_params); PHALCON_INIT_VAR(bind_keys); array_init(bind_keys); phalcon_is_iterable(values, &ah0, &hp0, 0, 0); while (zend_hash_get_current_data_ex(ah0, (void**) &hd, &hp0) == SUCCESS) { PHALCON_GET_HVALUE(value); /** * Key with auto bind-params */ PHALCON_INIT_NVAR(key); PHALCON_CONCAT_SV(key, "phi", hidden_param); PHALCON_INIT_NVAR(query_key); PHALCON_CONCAT_SVS(query_key, ":", key, ":"); phalcon_array_append(&bind_keys, query_key, PH_SEPARATE TSRMLS_CC); phalcon_array_update_zval(&bind_params, key, &value, PH_COPY | PH_SEPARATE TSRMLS_CC); PHALCON_SEPARATE(hidden_param); phalcon_increment(hidden_param); zend_hash_move_forward_ex(ah0, &hp0); } PHALCON_INIT_VAR(joined_keys); phalcon_fast_join_str(joined_keys, SL(", "), bind_keys TSRMLS_CC); /** * Create a standard IN condition with bind params */ PHALCON_INIT_VAR(conditions); PHALCON_CONCAT_VSVS(conditions, expr, " NOT IN (", joined_keys, ")"); /** * Append the IN to the current conditions using and 'and' */ phalcon_call_method_p2_noret(this_ptr, "andwhere", conditions, bind_params); phalcon_update_property_this(this_ptr, SL("_hiddenParamNumber"), hidden_param TSRMLS_CC); RETURN_THIS(); }
/** * Appends a condition to the current conditions using an OR operator * * @param string $conditions * @param array $bindParams * @param array $bindTypes * @return Phalcon\Mvc\Model\Criteria */ PHP_METHOD(Phalcon_Mvc_Model_Criteria, orWhere){ zval *conditions, *bind_params = NULL, *bind_types = NULL; zval *params = NULL, *current_conditions, *new_conditions = NULL; zval *current_bind_params, *merged_params = NULL; zval *current_bind_types, *merged_params_types = NULL; PHALCON_MM_GROW(); phalcon_fetch_params(1, 1, 2, &conditions, &bind_params, &bind_types); if (!bind_params) { PHALCON_INIT_VAR(bind_params); } if (!bind_types) { PHALCON_INIT_VAR(bind_types); } if (Z_TYPE_P(conditions) != IS_STRING) { PHALCON_THROW_EXCEPTION_STR(phalcon_mvc_model_exception_ce, "Conditions must be string"); return; } PHALCON_OBS_VAR(params); phalcon_read_property_this(¶ms, this_ptr, SL("_params"), PH_NOISY_CC); if (phalcon_array_isset_string(params, SS("conditions"))) { PHALCON_OBS_VAR(current_conditions); phalcon_array_fetch_string(¤t_conditions, params, SL("conditions"), PH_NOISY_CC); PHALCON_INIT_VAR(new_conditions); PHALCON_CONCAT_SVSVS(new_conditions, "(", current_conditions, ") OR (", conditions, ")"); } else { PHALCON_CPY_WRT(new_conditions, conditions); } phalcon_update_property_array_string(this_ptr, SL("_params"), SS("conditions"), new_conditions TSRMLS_CC); /** * Update or merge existing bound parameters */ if (Z_TYPE_P(bind_params) == IS_ARRAY) { PHALCON_OBS_NVAR(params); phalcon_read_property_this(¶ms, this_ptr, SL("_params"), PH_NOISY_CC); if (phalcon_array_isset_string(params, SS("bind"))) { PHALCON_OBS_VAR(current_bind_params); phalcon_array_fetch_string(¤t_bind_params, params, SL("bind"), PH_NOISY_CC); PHALCON_INIT_VAR(merged_params); phalcon_fast_array_merge(merged_params, ¤t_bind_params, &bind_params TSRMLS_CC); } else { PHALCON_CPY_WRT(merged_params, bind_params); } phalcon_update_property_array_string(this_ptr, SL("_params"), SS("bind"), merged_params TSRMLS_CC); } /** * Update or merge existing bind types parameters */ if (Z_TYPE_P(bind_types) == IS_ARRAY) { PHALCON_OBS_NVAR(params); phalcon_read_property_this(¶ms, this_ptr, SL("_params"), PH_NOISY_CC); if (phalcon_array_isset_string(params, SS("bindTypes"))) { PHALCON_OBS_VAR(current_bind_types); phalcon_array_fetch_string(¤t_bind_types, params, SL("bindTypes"), PH_NOISY_CC); PHALCON_INIT_VAR(merged_params_types); phalcon_fast_array_merge(merged_params_types, ¤t_bind_types, &bind_types TSRMLS_CC); } else { PHALCON_CPY_WRT(merged_params_types, bind_types); } phalcon_update_property_array_string(this_ptr, SL("_params"), SS("bindTypes"), merged_params_types TSRMLS_CC); } RETURN_THIS(); }
/** * Handles routing information received from command-line arguments * * @param array arguments */ PHP_METHOD(Phalcon_Cli_Router, handle) { zephir_fcall_cache_entry *_18 = NULL; zval *_15 = NULL; zval *_5 = NULL, *_10 = NULL; int ZEPHIR_LAST_CALL_STATUS; HashTable *_3, *_7; HashPosition _2, _6; zend_bool _0; zval *arguments = NULL, *moduleName = NULL, *taskName = NULL, *actionName = NULL, *params = NULL, *route = NULL, *parts = NULL, *pattern = NULL, *routeFound = NULL, *matches, *paths = NULL, *beforeMatch = NULL, *converters = NULL, *converter = NULL, *part = NULL, *position = NULL, *matchPosition = NULL, *strParams, *_1, **_4, **_8, *_9 = NULL, *_11, *_12, *_13, *_14, _16, *_17 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 1, &arguments); if (!arguments) { arguments = ZEPHIR_GLOBAL(global_null); } ZEPHIR_INIT_VAR(routeFound); ZVAL_BOOL(routeFound, 0); ZEPHIR_INIT_VAR(parts); array_init(parts); ZEPHIR_INIT_VAR(params); array_init(params); ZEPHIR_INIT_VAR(matches); ZVAL_NULL(matches); zephir_update_property_this(this_ptr, SL("_wasMatched"), (0) ? ZEPHIR_GLOBAL(global_true) : ZEPHIR_GLOBAL(global_false) TSRMLS_CC); zephir_update_property_this(this_ptr, SL("_matchedRoute"), ZEPHIR_GLOBAL(global_null) TSRMLS_CC); if (Z_TYPE_P(arguments) != IS_ARRAY) { _0 = Z_TYPE_P(arguments) != IS_STRING; if (_0) { _0 = Z_TYPE_P(arguments) != IS_NULL; } if (_0) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_cli_router_exception_ce, "Arguments must be an array or string", "phalcon/cli/router.zep", 204); return; } _1 = zephir_fetch_nproperty_this(this_ptr, SL("_routes"), PH_NOISY_CC); zephir_is_iterable(_1, &_3, &_2, 0, 1, "phalcon/cli/router.zep", 304); for ( ; zephir_hash_get_current_data_ex(_3, (void**) &_4, &_2) == SUCCESS ; zephir_hash_move_backwards_ex(_3, &_2) ) { ZEPHIR_GET_HVALUE(route, _4); ZEPHIR_CALL_METHOD(&pattern, route, "getcompiledpattern", NULL, 0); zephir_check_call_status(); if (zephir_memnstr_str(pattern, SL("^"), "phalcon/cli/router.zep", 214)) { ZEPHIR_INIT_NVAR(routeFound); zephir_preg_match(routeFound, pattern, arguments, matches, 0, 0 , 0 TSRMLS_CC); } else { ZEPHIR_INIT_NVAR(routeFound); ZVAL_BOOL(routeFound, ZEPHIR_IS_EQUAL(pattern, arguments)); } if (zephir_is_true(routeFound)) { ZEPHIR_CALL_METHOD(&beforeMatch, route, "getbeforematch", NULL, 0); zephir_check_call_status(); if (Z_TYPE_P(beforeMatch) != IS_NULL) { if (!(zephir_is_callable(beforeMatch TSRMLS_CC))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_cli_router_exception_ce, "Before-Match callback is not callable in matched route", "phalcon/cli/router.zep", 232); return; } ZEPHIR_INIT_NVAR(_5); zephir_create_array(_5, 3, 0 TSRMLS_CC); zephir_array_fast_append(_5, arguments); zephir_array_fast_append(_5, route); zephir_array_fast_append(_5, this_ptr); ZEPHIR_INIT_NVAR(routeFound); ZEPHIR_CALL_USER_FUNC_ARRAY(routeFound, beforeMatch, _5); zephir_check_call_status(); } } if (zephir_is_true(routeFound)) { ZEPHIR_CALL_METHOD(&paths, route, "getpaths", NULL, 0); zephir_check_call_status(); ZEPHIR_CPY_WRT(parts, paths); if (Z_TYPE_P(matches) == IS_ARRAY) { ZEPHIR_CALL_METHOD(&converters, route, "getconverters", NULL, 0); zephir_check_call_status(); zephir_is_iterable(paths, &_7, &_6, 0, 0, "phalcon/cli/router.zep", 293); for ( ; zephir_hash_get_current_data_ex(_7, (void**) &_8, &_6) == SUCCESS ; zephir_hash_move_forward_ex(_7, &_6) ) { ZEPHIR_GET_HMKEY(part, _7, _6); ZEPHIR_GET_HVALUE(position, _8); ZEPHIR_OBS_NVAR(matchPosition); if (zephir_array_isset_fetch(&matchPosition, matches, position, 0 TSRMLS_CC)) { if (Z_TYPE_P(converters) == IS_ARRAY) { ZEPHIR_OBS_NVAR(converter); if (zephir_array_isset_fetch(&converter, converters, part, 0 TSRMLS_CC)) { ZEPHIR_INIT_NVAR(_9); ZEPHIR_INIT_NVAR(_5); zephir_create_array(_5, 1, 0 TSRMLS_CC); zephir_array_fast_append(_5, matchPosition); ZEPHIR_CALL_USER_FUNC_ARRAY(_9, converter, _5); zephir_check_call_status(); zephir_array_update_zval(&parts, part, &_9, PH_COPY | PH_SEPARATE); continue; } } zephir_array_update_zval(&parts, part, &matchPosition, PH_COPY | PH_SEPARATE); } else { if (Z_TYPE_P(converters) == IS_ARRAY) { ZEPHIR_OBS_NVAR(converter); if (zephir_array_isset_fetch(&converter, converters, part, 0 TSRMLS_CC)) { ZEPHIR_INIT_NVAR(_9); ZEPHIR_INIT_NVAR(_10); zephir_create_array(_10, 1, 0 TSRMLS_CC); zephir_array_fast_append(_10, position); ZEPHIR_CALL_USER_FUNC_ARRAY(_9, converter, _10); zephir_check_call_status(); zephir_array_update_zval(&parts, part, &_9, PH_COPY | PH_SEPARATE); } } } } zephir_update_property_this(this_ptr, SL("_matches"), matches TSRMLS_CC); } zephir_update_property_this(this_ptr, SL("_matchedRoute"), route TSRMLS_CC); break; } } if (zephir_is_true(routeFound)) { zephir_update_property_this(this_ptr, SL("_wasMatched"), (1) ? ZEPHIR_GLOBAL(global_true) : ZEPHIR_GLOBAL(global_false) TSRMLS_CC); } else { zephir_update_property_this(this_ptr, SL("_wasMatched"), (0) ? ZEPHIR_GLOBAL(global_true) : ZEPHIR_GLOBAL(global_false) TSRMLS_CC); _11 = zephir_fetch_nproperty_this(this_ptr, SL("_defaultModule"), PH_NOISY_CC); zephir_update_property_this(this_ptr, SL("_module"), _11 TSRMLS_CC); _12 = zephir_fetch_nproperty_this(this_ptr, SL("_defaultTask"), PH_NOISY_CC); zephir_update_property_this(this_ptr, SL("_task"), _12 TSRMLS_CC); _13 = zephir_fetch_nproperty_this(this_ptr, SL("_defaultAction"), PH_NOISY_CC); zephir_update_property_this(this_ptr, SL("_action"), _13 TSRMLS_CC); _14 = zephir_fetch_nproperty_this(this_ptr, SL("_defaultParams"), PH_NOISY_CC); zephir_update_property_this(this_ptr, SL("_params"), _14 TSRMLS_CC); RETURN_THIS(); } } else { ZEPHIR_CPY_WRT(parts, arguments); } ZEPHIR_INIT_VAR(moduleName); ZVAL_NULL(moduleName); ZEPHIR_INIT_VAR(taskName); ZVAL_NULL(taskName); ZEPHIR_INIT_VAR(actionName); ZVAL_NULL(actionName); ZEPHIR_OBS_NVAR(moduleName); if (zephir_array_isset_string_fetch(&moduleName, parts, SS("module"), 0 TSRMLS_CC)) { zephir_array_unset_string(&parts, SS("module"), PH_SEPARATE); } else { ZEPHIR_OBS_NVAR(moduleName); zephir_read_property_this(&moduleName, this_ptr, SL("_defaultModule"), PH_NOISY_CC); } ZEPHIR_OBS_NVAR(taskName); if (zephir_array_isset_string_fetch(&taskName, parts, SS("task"), 0 TSRMLS_CC)) { zephir_array_unset_string(&parts, SS("task"), PH_SEPARATE); } else { ZEPHIR_OBS_NVAR(taskName); zephir_read_property_this(&taskName, this_ptr, SL("_defaultTask"), PH_NOISY_CC); } ZEPHIR_OBS_NVAR(actionName); if (zephir_array_isset_string_fetch(&actionName, parts, SS("action"), 0 TSRMLS_CC)) { zephir_array_unset_string(&parts, SS("action"), PH_SEPARATE); } else { ZEPHIR_OBS_NVAR(actionName); zephir_read_property_this(&actionName, this_ptr, SL("_defaultAction"), PH_NOISY_CC); } if (zephir_is_true(routeFound)) { ZEPHIR_OBS_NVAR(params); if (zephir_array_isset_string_fetch(¶ms, parts, SS("params"), 0 TSRMLS_CC)) { if (Z_TYPE_P(params) != IS_ARRAY) { zephir_get_strval(_15, params); ZEPHIR_SINIT_VAR(_16); ZVAL_LONG(&_16, 1); ZEPHIR_INIT_VAR(strParams); zephir_substr(strParams, _15, 1 , 0, ZEPHIR_SUBSTR_NO_LENGTH); if (zephir_is_true(strParams)) { ZEPHIR_CALL_CE_STATIC(&_17, phalcon_cli_router_route_ce, "getdelimiter", &_18, 121); zephir_check_call_status(); ZEPHIR_INIT_NVAR(params); zephir_fast_explode(params, _17, strParams, LONG_MAX TSRMLS_CC); } else { ZEPHIR_INIT_NVAR(params); array_init(params); } } zephir_array_unset_string(&parts, SS("params"), PH_SEPARATE); } if (zephir_fast_count_int(params TSRMLS_CC)) { ZEPHIR_INIT_NVAR(_9); zephir_fast_array_merge(_9, &(params), &(parts) TSRMLS_CC); ZEPHIR_CPY_WRT(params, _9); } else { ZEPHIR_CPY_WRT(params, parts); } } else { ZEPHIR_CPY_WRT(params, parts); } zephir_update_property_this(this_ptr, SL("_module"), moduleName TSRMLS_CC); zephir_update_property_this(this_ptr, SL("_task"), taskName TSRMLS_CC); zephir_update_property_this(this_ptr, SL("_action"), actionName TSRMLS_CC); zephir_update_property_this(this_ptr, SL("_params"), params TSRMLS_CC); ZEPHIR_MM_RESTORE(); }
/** * Sets a Expires header to use HTTP cache * *<code> * $this->response->setExpires(new DateTime()); *</code> * * @param DateTime $datetime * @return Phalcon\Http\ResponseInterface */ PHP_METHOD(Phalcon_Http_Response, setExpires){ zval *datetime, *headers, *date, *utc_zone, *timezone; zval *format, *utc_format, *utc_date, *expires_header; zend_class_entry *ce0; PHALCON_MM_GROW(); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &datetime) == FAILURE) { RETURN_MM_NULL(); } if (Z_TYPE_P(datetime) != IS_OBJECT) { PHALCON_THROW_EXCEPTION_STR(phalcon_http_response_exception_ce, "datetime parameter must be an instance of DateTime"); return; } PHALCON_INIT_VAR(headers); PHALCON_CALL_METHOD(headers, this_ptr, "getheaders"); PHALCON_INIT_VAR(date); if (phalcon_clone(date, datetime TSRMLS_CC) == FAILURE) { return; } /** * All the expiration times are sent in UTC */ PHALCON_INIT_VAR(utc_zone); ZVAL_STRING(utc_zone, "UTC", 1); ce0 = zend_fetch_class(SL("DateTimeZone"), ZEND_FETCH_CLASS_AUTO TSRMLS_CC); PHALCON_INIT_VAR(timezone); object_init_ex(timezone, ce0); if (phalcon_has_constructor(timezone TSRMLS_CC)) { PHALCON_CALL_METHOD_PARAMS_1_NORETURN(timezone, "__construct", utc_zone); } /** * Change the timezone to utc */ PHALCON_CALL_METHOD_PARAMS_1_NORETURN(date, "settimezone", timezone); PHALCON_INIT_VAR(format); ZVAL_STRING(format, "D, d M Y H:i:s", 1); PHALCON_INIT_VAR(utc_format); PHALCON_CALL_METHOD_PARAMS_1(utc_format, date, "format", format); PHALCON_INIT_VAR(utc_date); PHALCON_CONCAT_VS(utc_date, utc_format, " GMT"); /** * The 'Expires' header set this info */ PHALCON_INIT_VAR(expires_header); ZVAL_STRING(expires_header, "Expires", 1); PHALCON_CALL_METHOD_PARAMS_2_NORETURN(this_ptr, "setheader", expires_header, utc_date); RETURN_THIS(); }
/** * Reads the cookie-related info from the SESSION to restore the cookie as it was set * This method is automatically called internally so normally you don't need to call it * * @return Phalcon\Http\Cookie */ PHP_METHOD(Phalcon_Http_Cookie, restore){ zval *restored, *dependency_injector, *service; zval *session, *name, *key, *definition, *expire, *domain; zval *path, *secure, *http_only; PHALCON_MM_GROW(); PHALCON_OBS_VAR(restored); phalcon_read_property_this(&restored, this_ptr, SL("_restored"), PH_NOISY_CC); if (!zend_is_true(restored)) { PHALCON_OBS_VAR(dependency_injector); phalcon_read_property_this(&dependency_injector, this_ptr, SL("_dependencyInjector"), PH_NOISY_CC); if (Z_TYPE_P(dependency_injector) == IS_OBJECT) { PHALCON_INIT_VAR(service); ZVAL_STRING(service, "session", 1); PHALCON_INIT_VAR(session); phalcon_call_method_p1(session, dependency_injector, "getshared", service); PHALCON_OBS_VAR(name); phalcon_read_property_this(&name, this_ptr, SL("_name"), PH_NOISY_CC); PHALCON_INIT_VAR(key); PHALCON_CONCAT_SV(key, "_PHCOOKIE_", name); PHALCON_INIT_VAR(definition); phalcon_call_method_p1(definition, session, "get", key); if (Z_TYPE_P(definition) == IS_ARRAY) { if (phalcon_array_isset_string(definition, SS("expire"))) { PHALCON_OBS_VAR(expire); phalcon_array_fetch_string(&expire, definition, SL("expire"), PH_NOISY); phalcon_update_property_this(this_ptr, SL("_expire"), expire TSRMLS_CC); } if (phalcon_array_isset_string(definition, SS("domain"))) { PHALCON_OBS_VAR(domain); phalcon_array_fetch_string(&domain, definition, SL("domain"), PH_NOISY); phalcon_update_property_this(this_ptr, SL("_domain"), domain TSRMLS_CC); } if (phalcon_array_isset_string(definition, SS("path"))) { PHALCON_OBS_VAR(path); phalcon_array_fetch_string(&path, definition, SL("path"), PH_NOISY); phalcon_update_property_this(this_ptr, SL("_path"), path TSRMLS_CC); } if (phalcon_array_isset_string(definition, SS("secure"))) { PHALCON_OBS_VAR(secure); phalcon_array_fetch_string(&secure, definition, SL("secure"), PH_NOISY); phalcon_update_property_this(this_ptr, SL("_secure"), secure TSRMLS_CC); } if (phalcon_array_isset_string(definition, SS("httpOnly"))) { PHALCON_OBS_VAR(http_only); phalcon_array_fetch_string(&http_only, definition, SL("httpOnly"), PH_NOISY); phalcon_update_property_this(this_ptr, SL("_httpOnly"), http_only TSRMLS_CC); } } } phalcon_update_property_bool(this_ptr, SL("_restored"), 1 TSRMLS_CC); } RETURN_THIS(); }
/** * 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(); }
/** * Sends the cookie to the HTTP client * Stores the cookie definition in session * * @return Phalcon\Http\Cookie */ PHP_METHOD(Phalcon_Http_Cookie, send){ zval *name, *value, *expire, *domain, *path, *secure; zval *http_only, *dependency_injector, *definition; zval *service = NULL, *session = NULL, *key, *encryption, *crypt = NULL; zval *encrypt_value = NULL, *has_session = NULL; PHALCON_MM_GROW(); name = phalcon_read_property(getThis(), SL("_name"), PH_NOISY); value = phalcon_read_property(getThis(), SL("_value"), PH_NOISY); expire = phalcon_read_property(getThis(), SL("_expire"), PH_NOISY); domain = phalcon_read_property(getThis(), SL("_domain"), PH_NOISY); path = phalcon_read_property(getThis(), SL("_path"), PH_NOISY); secure = phalcon_read_property(getThis(), SL("_secure"), PH_NOISY); http_only = phalcon_read_property(getThis(), SL("_httpOnly"), PH_NOISY); dependency_injector = phalcon_read_property(getThis(), SL("_dependencyInjector"), PH_NOISY); if (Z_TYPE_P(dependency_injector) == IS_OBJECT) { PHALCON_INIT_VAR(service); ZVAL_STR(service, IS(session)); PHALCON_CALL_METHOD(&has_session, dependency_injector, "has", service); if (zend_is_true(has_session)) { PHALCON_INIT_VAR(definition); array_init(definition); if (!PHALCON_IS_LONG(expire, 0)) { phalcon_array_update_str(definition, SL("expire"), expire, PH_COPY); } if (PHALCON_IS_NOT_EMPTY(path)) { phalcon_array_update_str(definition, SL("path"), path, PH_COPY); } if (PHALCON_IS_NOT_EMPTY(domain)) { phalcon_array_update_string(definition, IS(domain), domain, PH_COPY); } if (PHALCON_IS_NOT_EMPTY(secure)) { phalcon_array_update_str(definition, SL("secure"), secure, PH_COPY); } if (PHALCON_IS_NOT_EMPTY(http_only)) { phalcon_array_update_str(definition, SL("httpOnly"), http_only, PH_COPY); } /** * The definition is stored in session */ if (phalcon_fast_count_ev(definition)) { PHALCON_CALL_METHOD(&session, dependency_injector, "getshared", service); if (Z_TYPE_P(session) != IS_NULL) { PHALCON_VERIFY_INTERFACE(session, phalcon_session_adapterinterface_ce); PHALCON_INIT_VAR(key); PHALCON_CONCAT_SV(key, "_PHCOOKIE_", name); PHALCON_CALL_METHOD(NULL, session, "set", key, definition); } } } } encryption = phalcon_read_property(getThis(), SL("_useEncryption"), PH_NOISY); if (zend_is_true(encryption) && PHALCON_IS_NOT_EMPTY(value)) { if (Z_TYPE_P(dependency_injector) != IS_OBJECT) { PHALCON_THROW_EXCEPTION_STR(phalcon_http_cookie_exception_ce, "A dependency injection object is required to access the 'filter' service"); return; } PHALCON_INIT_NVAR(service); ZVAL_STRING(service, "crypt"); PHALCON_CALL_METHOD(&crypt, dependency_injector, "getshared", service); PHALCON_VERIFY_INTERFACE(crypt, phalcon_cryptinterface_ce); /** * Encrypt the value also coding it with base64 */ PHALCON_CALL_METHOD(&encrypt_value, crypt, "encryptbase64", value); } else { PHALCON_CPY_WRT(encrypt_value, value); } /** * Sets the cookie using the standard 'setcookie' function */ convert_to_string_ex(name); convert_to_string_ex(encrypt_value); convert_to_long_ex(expire); convert_to_string_ex(path); convert_to_string_ex(domain); convert_to_long_ex(secure); convert_to_long_ex(http_only); php_setcookie(Z_STR_P(name), Z_STR_P(encrypt_value), Z_LVAL_P(expire), Z_STR_P(path), Z_STR_P(domain), Z_LVAL_P(secure), 1, Z_LVAL_P(http_only)); RETURN_THIS(); }
/** * Reads the cookie-related info from the SESSION to restore the cookie as it was set * This method is automatically called internally so normally you don't need to call it * * @return Phalcon\Http\Cookie */ PHP_METHOD(Phalcon_Http_Cookie, restore){ zval *restored, *dependency_injector, *service; zval *session = NULL, *name, *key, *definition = NULL, *expire, *domain; zval *path, *secure, *http_only; PHALCON_MM_GROW(); restored = phalcon_read_property(getThis(), SL("_restored"), PH_NOISY); if (!zend_is_true(restored)) { dependency_injector = phalcon_read_property(getThis(), SL("_dependencyInjector"), PH_NOISY); if (Z_TYPE_P(dependency_injector) == IS_OBJECT) { PHALCON_INIT_VAR(service); ZVAL_STR(service, IS(session)); PHALCON_CALL_METHOD(&session, dependency_injector, "getshared", service); PHALCON_VERIFY_INTERFACE(session, phalcon_session_adapterinterface_ce); name = phalcon_read_property(getThis(), SL("_name"), PH_NOISY); PHALCON_INIT_VAR(key); PHALCON_CONCAT_SV(key, "_PHCOOKIE_", name); PHALCON_CALL_METHOD(&definition, session, "get", key); if (Z_TYPE_P(definition) == IS_ARRAY) { if (phalcon_array_isset_str(definition, SL("expire"))) { PHALCON_OBS_VAR(expire); phalcon_array_fetch_str(&expire, definition, SL("expire"), PH_NOISY); phalcon_update_property_this(getThis(), SL("_expire"), expire); } if (phalcon_array_isset_str(definition, SL("domain"))) { PHALCON_OBS_VAR(domain); phalcon_array_fetch_str(&domain, definition, SL("domain"), PH_NOISY); phalcon_update_property_this(getThis(), SL("_domain"), domain); } if (phalcon_array_isset_str(definition, SL("path"))) { PHALCON_OBS_VAR(path); phalcon_array_fetch_str(&path, definition, SL("path"), PH_NOISY); phalcon_update_property_this(getThis(), SL("_path"), path); } if (phalcon_array_isset_str(definition, SL("secure"))) { PHALCON_OBS_VAR(secure); phalcon_array_fetch_str(&secure, definition, SL("secure"), PH_NOISY); phalcon_update_property_this(getThis(), SL("_secure"), secure); } if (phalcon_array_isset_str(definition, SL("httpOnly"))) { PHALCON_OBS_VAR(http_only); phalcon_array_fetch_str(&http_only, definition, SL("httpOnly"), PH_NOISY); phalcon_update_property_this(getThis(), SL("_httpOnly"), http_only); } } } phalcon_update_property_bool(getThis(), SL("_restored"), 1); } RETURN_THIS(); }
/** public function ION\ResolvablePromise::done(mixed $data) : self */ CLASS_METHOD(ION_ResolvablePromise, done) { RETURN_THIS(); }
/** * Redirect by HTTP to another action or URL * *<code> * //Using a string redirect (internal/external) * $response->redirect("posts/index"); * $response->redirect("http://en.wikipedia.org", true); * $response->redirect("http://www.example.com/new-location", true, 301); * * //Making a redirection based on a named route * $response->redirect(array( * "for" => "index-lang", * "lang" => "jp", * "controller" => "index" * )); *</code> * * @param string $location * @param boolean $externalRedirect * @param int $statusCode * @return Phalcon\Http\ResponseInterface */ PHP_METHOD(Phalcon_Http_Response, redirect){ zval *location = NULL, *external_redirect = NULL, *status_code = NULL; zval *header = NULL, *dependency_injector, *service; zval *url, *status_text, *header_name; static const char* redirect_phrases[] = { /* 300 */ "Multiple Choices", /* 301 */ "Moved Permanently", /* 302 */ "Found", /* 303 */ "See Other", /* 304 */ "Not Modified", /* 305 */ "Use Proxy", /* 306 */ "Switch Proxy", /* 307 */ "Temporary Redirect", /* 308 */ "Permanent Redirect" }; PHALCON_MM_GROW(); phalcon_fetch_params(1, 0, 3, &location, &external_redirect, &status_code); if (!location) { PHALCON_INIT_VAR(location); } if (!external_redirect) { PHALCON_INIT_VAR(external_redirect); ZVAL_BOOL(external_redirect, 0); } if (!status_code) { PHALCON_INIT_VAR(status_code); ZVAL_LONG(status_code, 302); } else if (unlikely(Z_TYPE_P(status_code) != IS_LONG)) { PHALCON_SEPARATE_PARAM(status_code); convert_to_long(status_code); } if (zend_is_true(external_redirect)) { PHALCON_CPY_WRT(header, location); } else { PHALCON_INIT_VAR(dependency_injector); phalcon_call_method(dependency_injector, this_ptr, "getdi"); PHALCON_INIT_VAR(service); ZVAL_STRING(service, "url", 1); PHALCON_INIT_VAR(url); phalcon_call_method_p1(url, dependency_injector, "getshared", service); PHALCON_VERIFY_INTERFACE(url, phalcon_mvc_urlinterface_ce); PHALCON_INIT_NVAR(header); phalcon_call_method_p1(header, url, "get", location); } /** * The HTTP status is 302 by default, a temporary redirection */ PHALCON_INIT_VAR(status_text); if (Z_LVAL_P(status_code) < 300 || Z_LVAL_P(status_code) > 308) { ZVAL_STRING(status_text, "Redirect", 1); } else { ZVAL_STRING(status_text, redirect_phrases[Z_LVAL_P(status_code) - 300], 1); } phalcon_call_method_p2_noret(this_ptr, "setstatuscode", status_code, status_text); /** * Change the current location using 'Location' */ PHALCON_INIT_VAR(header_name); ZVAL_STRING(header_name, "Location", 1); phalcon_call_method_p2_noret(this_ptr, "setheader", header_name, header); RETURN_THIS(); }
/** * Sends the cookie to the HTTP client * Stores the cookie definition in session * * @return Phalcon\Http\Cookie */ PHP_METHOD(Phalcon_Http_Cookie, send){ zval *name, *value, *expire, *domain, *path, *secure; zval *http_only, *dependency_injector, *definition; zval *service = NULL, *session, *key, *encryption, *crypt; zval *encrypt_value = NULL, *has_session; PHALCON_MM_GROW(); PHALCON_OBS_VAR(name); phalcon_read_property_this(&name, this_ptr, SL("_name"), PH_NOISY_CC); PHALCON_OBS_VAR(value); phalcon_read_property_this(&value, this_ptr, SL("_value"), PH_NOISY_CC); PHALCON_OBS_VAR(expire); phalcon_read_property_this(&expire, this_ptr, SL("_expire"), PH_NOISY_CC); PHALCON_OBS_VAR(domain); phalcon_read_property_this(&domain, this_ptr, SL("_domain"), PH_NOISY_CC); PHALCON_OBS_VAR(path); phalcon_read_property_this(&path, this_ptr, SL("_path"), PH_NOISY_CC); PHALCON_OBS_VAR(secure); phalcon_read_property_this(&secure, this_ptr, SL("_secure"), PH_NOISY_CC); PHALCON_OBS_VAR(http_only); phalcon_read_property_this(&http_only, this_ptr, SL("_httpOnly"), PH_NOISY_CC); PHALCON_OBS_VAR(dependency_injector); phalcon_read_property_this(&dependency_injector, this_ptr, SL("_dependencyInjector"), PH_NOISY_CC); if (Z_TYPE_P(dependency_injector) == IS_OBJECT) { PHALCON_INIT_VAR(service); PHALCON_INIT_VAR(has_session); ZVAL_STRING(service, "session", 1); phalcon_call_method_p1(has_session, dependency_injector, "has", service); if (zend_is_true(has_session)) { PHALCON_INIT_VAR(definition); array_init(definition); if (!PHALCON_IS_LONG(expire, 0)) { phalcon_array_update_string(&definition, SL("expire"), &expire, PH_COPY); } if (PHALCON_IS_NOT_EMPTY(path)) { phalcon_array_update_string(&definition, SL("path"), &path, PH_COPY); } if (PHALCON_IS_NOT_EMPTY(domain)) { phalcon_array_update_string(&definition, SL("domain"), &domain, PH_COPY); } if (PHALCON_IS_NOT_EMPTY(secure)) { phalcon_array_update_string(&definition, SL("secure"), &secure, PH_COPY); } if (PHALCON_IS_NOT_EMPTY(http_only)) { phalcon_array_update_string(&definition, SL("httpOnly"), &http_only, PH_COPY); } /** * The definition is stored in session */ if (phalcon_fast_count_ev(definition TSRMLS_CC)) { PHALCON_INIT_VAR(session); phalcon_call_method_p1(session, dependency_injector, "getshared", service); if (Z_TYPE_P(session) != IS_NULL) { PHALCON_INIT_VAR(key); PHALCON_CONCAT_SV(key, "_PHCOOKIE_", name); phalcon_call_method_p2_noret(session, "set", key, definition); } } } } PHALCON_OBS_VAR(encryption); phalcon_read_property_this(&encryption, this_ptr, SL("_useEncryption"), PH_NOISY_CC); if (zend_is_true(encryption) && PHALCON_IS_NOT_EMPTY(value)) { if (Z_TYPE_P(dependency_injector) != IS_OBJECT) { PHALCON_THROW_EXCEPTION_STR(phalcon_http_response_exception_ce, "A dependency injection object is required to access the 'filter' service"); return; } PHALCON_INIT_NVAR(service); ZVAL_STRING(service, "crypt", 1); PHALCON_INIT_VAR(crypt); phalcon_call_method_p1(crypt, dependency_injector, "getshared", service); /** * Encrypt the value also coding it with base64 */ PHALCON_INIT_VAR(encrypt_value); phalcon_call_method_p1(encrypt_value, crypt, "encryptbase64", value); } else { PHALCON_CPY_WRT(encrypt_value, value); } /** * Sets the cookie using the standard 'setcookie' function */ convert_to_string_ex(&name); convert_to_string_ex(&encrypt_value); convert_to_long_ex(&expire); convert_to_string_ex(&path); convert_to_string_ex(&domain); convert_to_long_ex(&secure); convert_to_long_ex(&http_only); php_setcookie( Z_STRVAL_P(name), Z_STRLEN_P(name), Z_STRVAL_P(encrypt_value), Z_STRLEN_P(encrypt_value), Z_LVAL_P(expire), Z_STRVAL_P(path), Z_STRLEN_P(path), Z_STRVAL_P(domain), Z_STRLEN_P(domain), Z_LVAL_P(secure), 1, Z_LVAL_P(http_only) TSRMLS_CC ); RETURN_THIS(); }