PHP_METHOD(Phalcon_Registry, __isset){ zval *key; phalcon_fetch_params(0, 1, 0, &key); PHALCON_RETURN_CALL_SELFW("offsetexists", key); }
/** * Returns an index in the registry */ PHP_METHOD(Phalcon_Registry, __get){ zval *property; phalcon_fetch_params(0, 1, 0, &property); PHALCON_RETURN_CALL_SELFW("offsetget", property); }
/** * Gets variable from $_GET superglobal applying filters if needed * If no parameters are given the $_GET superglobal is returned * *<code> * //Returns value from $_GET["id"] without sanitizing * $id = $request->getQuery("id"); * * //Returns value from $_GET["id"] with sanitizing * $id = $request->getQuery("id", "int"); * * //Returns value from $_GET["id"] with a default value * $id = $request->getQuery("id", null, 150); *</code> * * @param string $name * @param string|array $filters * @param mixed $defaultValue * @param boolean $notAllowEmpty * @param boolean $noRecursive * @return mixed */ PHP_METHOD(Phalcon_Http_Request, getQuery){ zval *name = NULL, *filters = NULL, *default_value = NULL, *not_allow_empty = NULL, *norecursive = NULL, *get; phalcon_fetch_params(0, 0, 5, &name, &filters, &default_value, ¬_allow_empty, &norecursive); if (!name) { name = &PHALCON_GLOBAL(z_null); } if (!filters) { filters = &PHALCON_GLOBAL(z_null); } if (!default_value) { default_value = &PHALCON_GLOBAL(z_null); } if (!not_allow_empty) { not_allow_empty = &PHALCON_GLOBAL(z_false); } if (!norecursive) { norecursive = &PHALCON_GLOBAL(z_false); } get = phalcon_get_global_str(SL("_GET")); PHALCON_RETURN_CALL_SELFW("_get", get, name, filters, default_value, not_allow_empty, norecursive); }
/** * Gets a variable from the $_REQUEST superglobal applying filters if needed. * If no parameters are given the $_REQUEST superglobal is returned * *<code> * //Returns value from $_REQUEST["user_email"] without sanitizing * $userEmail = $request->get("user_email"); * * //Returns value from $_REQUEST["user_email"] with sanitizing * $userEmail = $request->get("user_email", "email"); *</code> * * @param string $name * @param string|array $filters * @param mixed $defaultValue * @param boolean $notAllowEmpty * @param boolean $noRecursive * @return mixed */ PHP_METHOD(Phalcon_Http_Request, get) { zval *name = NULL, *filters = NULL, *default_value = NULL, *not_allow_empty = NULL, *norecursive = NULL, *request; zval put = {}, merged = {}; phalcon_fetch_params(0, 0, 5, &name, &filters, &default_value, ¬_allow_empty, &norecursive); if (!name) { name = &PHALCON_GLOBAL(z_null); } if (!filters) { filters = &PHALCON_GLOBAL(z_null); } if (!default_value) { default_value = &PHALCON_GLOBAL(z_null); } if (!not_allow_empty) { not_allow_empty = &PHALCON_GLOBAL(z_false); } if (!norecursive) { norecursive = &PHALCON_GLOBAL(z_false); } request = phalcon_get_global_str(SL("_REQUEST")); PHALCON_CALL_METHODW(&put, getThis(), "getput"); phalcon_fast_array_merge(&merged, request, &put); PHALCON_RETURN_CALL_SELFW("_get", &merged, name, filters, default_value, not_allow_empty, norecursive); }
/** * Gets a variable from put request * *<code> * $userEmail = $request->getPut("user_email"); * * $userEmail = $request->getPut("user_email", "email"); *</code> * * @param string $name * @param string|array $filters * @param mixed $defaultValue * @param boolean $notAllowEmpty * @param boolean $noRecursive * @return mixed */ PHP_METHOD(Phalcon_Http_Request, getPut) { zval *name = NULL, *filters = NULL, *default_value = NULL, *not_allow_empty = NULL, *norecursive = NULL, is_put = {}, put = {}, raw = {}, new_put = {}; char *tmp; phalcon_fetch_params(0, 0, 5, &name, &filters, &default_value, ¬_allow_empty, &norecursive); if (!name) { name = &PHALCON_GLOBAL(z_null); } if (!filters) { filters = &PHALCON_GLOBAL(z_null); } if (!default_value) { default_value = &PHALCON_GLOBAL(z_null); } if (!not_allow_empty) { not_allow_empty = &PHALCON_GLOBAL(z_false); } if (!norecursive) { norecursive = &PHALCON_GLOBAL(z_false); } PHALCON_CALL_METHODW(&is_put, getThis(), "isput"); if (!zend_is_true(&is_put)) { RETURN_EMPTY_ARRAY(); } else { phalcon_read_property(&put, getThis(), SL("_put"), PH_NOISY); if (Z_TYPE(put) != IS_ARRAY) { PHALCON_CALL_METHODW(&raw, getThis(), "getrawbody"); array_init(&new_put); PHALCON_ENSURE_IS_STRING(&raw); tmp = estrndup(Z_STRVAL(raw), Z_STRLEN(raw)); sapi_module.treat_data(PARSE_STRING, tmp, &new_put); phalcon_update_property_zval(getThis(), SL("_put"), &new_put); } else { PHALCON_CPY_WRT(&new_put, &put); } } PHALCON_RETURN_CALL_SELFW("_get", &new_put, name, filters, default_value, not_allow_empty, norecursive); }
/** * Magic method to get or set services using setters/getters * * @param string $method * @param array $arguments * @return mixed */ PHP_METHOD(Phalcon_DI, __call){ zval *method, *arguments = NULL, possible_service = {}, name = {}, definition = {}; phalcon_fetch_params(0, 1, 1, &method, &arguments); PHALCON_ENSURE_IS_STRING(method); if (!arguments) { arguments = &PHALCON_GLOBAL(z_null); } phalcon_substr(&possible_service, method, 3, 0); phalcon_lcfirst(&name, &possible_service); /** * If the magic method starts with "get" we try to get a service with that name */ if (phalcon_start_with_str(method, SL("get"))) { if (phalcon_isset_property_array(getThis(), SL("_services"), &name)) { PHALCON_RETURN_CALL_SELFW("get", &name, arguments); return; } } /** * If the magic method starts with "set" we try to set a service using that name */ if (phalcon_start_with_str(method, SL("set"))) { if (phalcon_array_isset_fetch_long(&definition, arguments, 0)) { PHALCON_CALL_SELFW(NULL, "set", &name, &definition); return; } } /** * The method doesn't start with set/get throw an exception */ zend_throw_exception_ex(phalcon_di_exception_ce, 0, "Call to undefined method or service '%s'", Z_STRVAL_P(method)); }
/** * Magic __toString method returns uri * * @return string */ PHP_METHOD(Phalcon_Http_Uri, __toString){ PHALCON_RETURN_CALL_SELFW("build"); }