Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[NFR]Add functon getKey for request/file #883

Closed
wants to merge 16 commits into from
Prev Previous commit
Next Next commit
getError(), __set_state()
  • Loading branch information
sjinks committed Jul 19, 2013
commit a77ac4a06b744515f72a5642d136bb19ed55ec57
35 changes: 33 additions & 2 deletions ext/http/request/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ PHALCON_INIT_CLASS(Phalcon_Http_Request_File){
zend_declare_property_null(phalcon_http_request_file_ce, SL("_tmp"), ZEND_ACC_PROTECTED TSRMLS_CC);
zend_declare_property_null(phalcon_http_request_file_ce, SL("_size"), ZEND_ACC_PROTECTED TSRMLS_CC);
zend_declare_property_null(phalcon_http_request_file_ce, SL("_type"), ZEND_ACC_PROTECTED TSRMLS_CC);
zend_declare_property_null(phalcon_http_request_file_ce, SL("_error"), ZEND_ACC_PROTECTED TSRMLS_CC);

zend_class_implements(phalcon_http_request_file_ce TSRMLS_CC, 1, phalcon_http_request_fileinterface_ce);

Expand All @@ -86,7 +87,7 @@ PHALCON_INIT_CLASS(Phalcon_Http_Request_File){
*/
PHP_METHOD(Phalcon_Http_Request_File, __construct){

zval *file, *name, *temp_name, *size, *type;
zval *file, *name, *temp_name, *size, *type, *error;

PHALCON_MM_GROW();

Expand Down Expand Up @@ -119,7 +120,13 @@ PHP_METHOD(Phalcon_Http_Request_File, __construct){
phalcon_array_fetch_string(&type, file, SL("type"), PH_NOISY);
phalcon_update_property_this(this_ptr, SL("_type"), type TSRMLS_CC);
}


if (phalcon_array_isset_string(file, SS("error"))) {
PHALCON_OBS_VAR(error);
phalcon_array_fetch_string(&error, file, SL("error"), PH_NOISY);
phalcon_update_property_this(this_ptr, SL("_error"), error TSRMLS_CC);
}

PHALCON_MM_RESTORE();
}

Expand Down Expand Up @@ -171,12 +178,24 @@ PHP_METHOD(Phalcon_Http_Request_File, getType){
/**
* Gets the real mime type of the upload file using finfo
*
* @todo Not implemented
* @return string
*/
PHP_METHOD(Phalcon_Http_Request_File, getRealType){



}

/**
* Returns the error code
*
* @return string
*/
PHP_METHOD(Phalcon_Http_Request_File, getError){


RETURN_MEMBER(this_ptr, "_error");
}

/**
Expand All @@ -199,3 +218,15 @@ PHP_METHOD(Phalcon_Http_Request_File, moveTo){
RETURN_MM();
}

PHP_METHOD(Phalcon_Http_Request_File, __set_state) {

zval *data;

phalcon_fetch_params(0, 1, 0, &data);

object_init_ex(return_value, phalcon_http_request_file_ce);

PHALCON_MM_GROW();
phalcon_call_method_p1_noret(return_value, "__construct", data);
PHALCON_MM_RESTORE();
}
8 changes: 6 additions & 2 deletions ext/http/request/file.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ PHP_METHOD(Phalcon_Http_Request_File, getName);
PHP_METHOD(Phalcon_Http_Request_File, getTempName);
PHP_METHOD(Phalcon_Http_Request_File, getType);
PHP_METHOD(Phalcon_Http_Request_File, getRealType);
PHP_METHOD(Phalcon_Http_Request_File, getError);
PHP_METHOD(Phalcon_Http_Request_File, moveTo);
PHP_METHOD(Phalcon_Http_Request_File, __set_state);

ZEND_BEGIN_ARG_INFO_EX(arginfo_phalcon_http_request_file___construct, 0, 0, 1)
ZEND_ARG_INFO(0, file)
Expand All @@ -43,8 +45,10 @@ PHALCON_INIT_FUNCS(phalcon_http_request_file_method_entry){
PHP_ME(Phalcon_Http_Request_File, getName, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Phalcon_Http_Request_File, getTempName, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Phalcon_Http_Request_File, getType, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Phalcon_Http_Request_File, getRealType, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Phalcon_Http_Request_File, moveTo, arginfo_phalcon_http_request_file_moveto, ZEND_ACC_PUBLIC)
PHP_ME(Phalcon_Http_Request_File, getRealType, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Phalcon_Http_Request_File, getError, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Phalcon_Http_Request_File, moveTo, arginfo_phalcon_http_request_file_moveto, ZEND_ACC_PUBLIC)
PHP_ME(Phalcon_Config, __set_state, arginfo_phalcon_http_request_file___construct, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
PHP_FE_END
};