本文整理汇总了C++中phalcon_call_method函数的典型用法代码示例。如果您正苦于以下问题:C++ phalcon_call_method函数的具体用法?C++ phalcon_call_method怎么用?C++ phalcon_call_method使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了phalcon_call_method函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: PHP_METHOD
/**
* Get last row in the resultset
*
* @return Phalcon\Mvc\ModelInterface
*/
PHP_METHOD(Phalcon_Mvc_Model_Resultset, getLast){
zval *one, *count, *pre_count, *valid, *current;
PHALCON_MM_GROW();
PHALCON_INIT_VAR(one);
ZVAL_LONG(one, 1);
PHALCON_INIT_VAR(count);
phalcon_call_method(count, this_ptr, "count");
PHALCON_INIT_VAR(pre_count);
sub_function(pre_count, count, one TSRMLS_CC);
phalcon_call_method_p1_noret(this_ptr, "seek", pre_count);
PHALCON_INIT_VAR(valid);
phalcon_call_method(valid, this_ptr, "valid");
if (PHALCON_IS_NOT_FALSE(valid)) {
PHALCON_INIT_VAR(current);
phalcon_call_method(current, this_ptr, "current");
RETURN_CCTOR(current);
}
RETURN_MM_FALSE;
}
示例2: PHP_METHOD
/**
* Returns a complete resultset as an array, if the resultset has a big number of rows
* it could consume more memory than currently it does.
*
* @return array
*/
PHP_METHOD(Phalcon_Mvc_Model_Resultset_Complex, toArray){
zval *records, *valid = NULL, *current = NULL;
zval *r0 = NULL;
PHALCON_MM_GROW();
PHALCON_INIT_VAR(records);
array_init(records);
phalcon_call_method_noret(this_ptr, "rewind");
while (1) {
PHALCON_INIT_NVAR(r0);
phalcon_call_method(r0, this_ptr, "valid");
PHALCON_CPY_WRT(valid, r0);
if (PHALCON_IS_NOT_FALSE(valid)) {
} else {
break;
}
PHALCON_INIT_NVAR(current);
phalcon_call_method(current, this_ptr, "current");
phalcon_array_append(&records, current, PH_SEPARATE);
phalcon_call_method_noret(this_ptr, "next");
}
RETURN_CTOR(records);
}
示例3: PHP_METHOD
/**
* Maps a route to a handler that only matches if the HTTP method is HEAD
*
* @param string $routePattern
* @param callable $handler
* @return Phalcon\Mvc\Router\RouteInterface
*/
PHP_METHOD(Phalcon_Mvc_Micro, head){
zval *route_pattern, *handler, *router, *route;
zval *route_id;
PHALCON_MM_GROW();
phalcon_fetch_params(1, 2, 0, &route_pattern, &handler);
/**
* We create a router even if there is no one in the DI
*/
PHALCON_INIT_VAR(router);
phalcon_call_method(router, this_ptr, "getrouter");
/**
* Routes are added to the router restricting to HEAD
*/
PHALCON_INIT_VAR(route);
phalcon_call_method_p1(route, router, "addhead", route_pattern);
/**
* Using the id produced by the router we store the handler
*/
PHALCON_INIT_VAR(route_id);
phalcon_call_method(route_id, route, "getrouteid");
phalcon_update_property_array(this_ptr, SL("_handlers"), route_id, handler TSRMLS_CC);
/**
* The route is returned, the developer can add more things on it
*/
RETURN_CCTOR(route);
}
示例4: PHP_METHOD
/**
* Reads meta-data for certain model using a MODEL_* constant
*
*<code>
* print_r($metaData->writeColumnMapIndex(new Robots(), MetaData::MODELS_REVERSE_COLUMN_MAP, array('leName' => 'name')));
*</code>
*
* @param Phalcon\Mvc\ModelInterface $model
* @param int $index
* @return array
*/
PHP_METHOD(Phalcon_Mvc_Model_MetaData, readMetaDataIndex) {
zval *model, *index, *table, *schema, *class_name;
zval *key, *meta_data = NULL, *meta_data_index, *attributes;
PHALCON_MM_GROW();
phalcon_fetch_params(1, 2, 0, &model, &index);
if (Z_TYPE_P(model) != IS_OBJECT) {
PHALCON_THROW_EXCEPTION_STR(phalcon_mvc_model_exception_ce, "A model instance is required to retrieve the meta-data");
return;
}
if (Z_TYPE_P(index) != IS_LONG) {
PHALCON_THROW_EXCEPTION_STR(phalcon_mvc_model_exception_ce, "Index must be a valid integer constant");
return;
}
PHALCON_INIT_VAR(table);
phalcon_call_method(table, model, "getsource");
PHALCON_INIT_VAR(schema);
phalcon_call_method(schema, model, "getschema");
PHALCON_INIT_VAR(class_name);
phalcon_get_class(class_name, model, 1 TSRMLS_CC);
/**
* Unique key for meta-data is created using class-name-schema-table
*/
PHALCON_INIT_VAR(key);
PHALCON_CONCAT_VSVV(key, class_name, "-", schema, table);
PHALCON_OBS_VAR(meta_data);
phalcon_read_property_this(&meta_data, this_ptr, SL("_metaData"), PH_NOISY_CC);
if (!phalcon_array_isset(meta_data, key)) {
phalcon_call_method_p4_noret(this_ptr, "_initialize", model, key, table, schema);
PHALCON_OBS_NVAR(meta_data);
phalcon_read_property_this(&meta_data, this_ptr, SL("_metaData"), PH_NOISY_CC);
}
PHALCON_OBS_VAR(meta_data_index);
phalcon_array_fetch(&meta_data_index, meta_data, key, PH_NOISY);
PHALCON_OBS_VAR(attributes);
phalcon_array_fetch(&attributes, meta_data_index, index, PH_NOISY);
RETURN_CCTOR(attributes);
}
示例5: PHP_METHOD
/**
* Rollbacks active transactions within the manager
* Collect will remove transaction from the manager
*
* @param boolean $collect
*/
PHP_METHOD(Phalcon_Mvc_Model_Transaction_Manager, rollback){
zval *collect = NULL, *transactions, *transaction = NULL, *connection = NULL;
zval *is_under_transaction = NULL;
HashTable *ah0;
HashPosition hp0;
zval **hd;
PHALCON_MM_GROW();
phalcon_fetch_params(1, 0, 1, &collect);
if (!collect) {
PHALCON_INIT_VAR(collect);
ZVAL_BOOL(collect, 1);
}
PHALCON_OBS_VAR(transactions);
phalcon_read_property_this(&transactions, this_ptr, SL("_transactions"), PH_NOISY_CC);
if (Z_TYPE_P(transactions) == IS_ARRAY) {
phalcon_is_iterable(transactions, &ah0, &hp0, 0, 0);
while (zend_hash_get_current_data_ex(ah0, (void**) &hd, &hp0) == SUCCESS) {
PHALCON_GET_HVALUE(transaction);
PHALCON_INIT_NVAR(connection);
phalcon_call_method(connection, transaction, "getconnection");
PHALCON_INIT_NVAR(is_under_transaction);
phalcon_call_method(is_under_transaction, connection, "isundertransaction");
if (zend_is_true(is_under_transaction)) {
phalcon_call_method_noret(connection, "rollback");
phalcon_call_method_noret(connection, "close");
}
if (zend_is_true(collect)) {
phalcon_call_method_p1_noret(this_ptr, "_collecttransaction", transaction);
}
zend_hash_move_forward_ex(ah0, &hp0);
}
}
PHALCON_MM_RESTORE();
}
示例6: PHP_METHOD
/**
* Writes the log to the stream itself
*
* @param string $message
* @param int $type
* @param int $time
*/
PHP_METHOD(Phalcon_Logger_Adapter_Syslog, logInternal){
zval *message, *type, *time, *formatter, *applied_format;
zval *syslog_type, *syslog_message;
PHALCON_MM_GROW();
phalcon_fetch_params(1, 3, 0, &message, &type, &time);
PHALCON_INIT_VAR(formatter);
phalcon_call_method(formatter, this_ptr, "getformatter");
PHALCON_INIT_VAR(applied_format);
phalcon_call_method_p3(applied_format, formatter, "format", message, type, time);
if (Z_TYPE_P(applied_format) != IS_ARRAY) {
PHALCON_THROW_EXCEPTION_STR(phalcon_logger_exception_ce, "The formatted message is not valid");
return;
}
PHALCON_OBS_VAR(syslog_type);
phalcon_array_fetch_long(&syslog_type, applied_format, 0, PH_NOISY);
PHALCON_OBS_VAR(syslog_message);
phalcon_array_fetch_long(&syslog_message, applied_format, 1, PH_NOISY);
phalcon_call_func_p2_noret("syslog", syslog_type, syslog_message);
PHALCON_MM_RESTORE();
}
示例7: PHP_METHOD
/**
* Creates a password hash using bcrypt with a pseudo random salt
*
* @param string $password
* @param int $workFactor
* @return string
*/
PHP_METHOD(Phalcon_Security, hash){
zval *password, *work_factor = NULL, *format, *factor;
zval *salt_bytes, *salt;
PHALCON_MM_GROW();
phalcon_fetch_params(1, 1, 1, &password, &work_factor);
if (!work_factor) {
PHALCON_INIT_VAR(work_factor);
} else {
PHALCON_SEPARATE_PARAM(work_factor);
}
if (Z_TYPE_P(work_factor) == IS_NULL) {
PHALCON_OBS_NVAR(work_factor);
phalcon_read_property_this(&work_factor, this_ptr, SL("_workFactor"), PH_NOISY_CC);
}
PHALCON_INIT_VAR(format);
ZVAL_STRING(format, "%02s", 1);
PHALCON_INIT_VAR(factor);
phalcon_call_func_p2(factor, "sprintf", format, work_factor);
PHALCON_INIT_VAR(salt_bytes);
phalcon_call_method(salt_bytes, this_ptr, "getsaltbytes");
PHALCON_INIT_VAR(salt);
PHALCON_CONCAT_SVSV(salt, "$2a$", factor, "$", salt_bytes);
phalcon_call_func_p2(return_value, "crypt", password, salt);
RETURN_MM();
}
示例8: PHP_METHOD
/**
* Phalcon\Mvc\Model\ValidationFailed constructor
*
* @param Phalcon\Mvc\Model $model
* @param Phalcon\Mvc\Model\Message[] $validationMessages
*/
PHP_METHOD(Phalcon_Mvc_Model_ValidationFailed, __construct){
zval *model, *validation_messages, *message;
zval *message_str = NULL;
PHALCON_MM_GROW();
phalcon_fetch_params(1, 2, 0, &model, &validation_messages);
if (phalcon_fast_count_ev(validation_messages TSRMLS_CC)) {
/**
* Get the first message in the array
*/
PHALCON_OBS_VAR(message);
phalcon_array_fetch_long(&message, validation_messages, 0, PH_NOISY);
/**
* Get the message to use it in the exception
*/
PHALCON_INIT_VAR(message_str);
phalcon_call_method(message_str, message, "getmessage");
} else {
PHALCON_INIT_NVAR(message_str);
ZVAL_STRING(message_str, "Validation failed", 1);
}
phalcon_update_property_this(this_ptr, SL("_model"), model TSRMLS_CC);
phalcon_update_property_this(this_ptr, SL("_messages"), validation_messages TSRMLS_CC);
PHALCON_CALL_PARENT_PARAMS_1_NORETURN(this_ptr, "Phalcon\\Mvc\\Model\\ValidationFailed", "__construct", message_str);
PHALCON_MM_RESTORE();
}
示例9: PHP_METHOD
/**
* Sets the response content-type mime, optionally the charset
*
*<code>
* $response->setContentType('application/pdf');
* $response->setContentType('text/plain', 'UTF-8');
*</code>
*
* @param string $contentType
* @param string $charset
* @return Phalcon\Http\ResponseInterface
*/
PHP_METHOD(Phalcon_Http_Response, setContentType){
zval *content_type, *charset = NULL, *headers, *name, *header_value;
PHALCON_MM_GROW();
phalcon_fetch_params(1, 1, 1, &content_type, &charset);
if (!charset) {
PHALCON_INIT_VAR(charset);
}
PHALCON_INIT_VAR(headers);
phalcon_call_method(headers, this_ptr, "getheaders");
PHALCON_INIT_VAR(name);
ZVAL_STRING(name, "Content-Type", 1);
if (Z_TYPE_P(charset) == IS_NULL) {
phalcon_call_method_p2_noret(headers, "set", name, content_type);
} else {
PHALCON_INIT_VAR(header_value);
PHALCON_CONCAT_VSV(header_value, content_type, "; charset=", charset);
phalcon_call_method_p2_noret(headers, "set", name, header_value);
}
RETURN_THIS();
}
示例10: PHP_METHOD
/**
* Returns a service definition without resolving
*
* @param string $name
* @return mixed
*/
PHP_METHOD(Phalcon_DI, getRaw){
zval *name, *services, *service, *exception_message;
PHALCON_MM_GROW();
phalcon_fetch_params(1, 1, 0, &name);
if (Z_TYPE_P(name) != IS_STRING) {
PHALCON_THROW_EXCEPTION_STR(phalcon_di_exception_ce, "The service name must be a string");
return;
}
PHALCON_OBS_VAR(services);
phalcon_read_property_this(&services, this_ptr, SL("_services"), PH_NOISY_CC);
if (phalcon_array_isset(services, name)) {
PHALCON_OBS_VAR(service);
phalcon_array_fetch(&service, services, name, PH_NOISY);
phalcon_call_method(return_value, service, "getdefinition");
RETURN_MM();
}
PHALCON_INIT_VAR(exception_message);
PHALCON_CONCAT_SVS(exception_message, "Service '", name, "' wasn't found in the dependency injection container");
PHALCON_THROW_EXCEPTION_ZVAL(phalcon_di_exception_ce, exception_message);
return;
}
示例11: PHP_METHOD
/**
* Writes the log to the file itself
*
* @param string $message
* @param int $type
* @param int $time
*/
PHP_METHOD(Phalcon_Logger_Adapter_File, logInternal){
zval *message, *type, *time, *file_handler, *formatter;
zval *applied_format;
PHALCON_MM_GROW();
phalcon_fetch_params(1, 3, 0, &message, &type, &time);
PHALCON_OBS_VAR(file_handler);
phalcon_read_property_this(&file_handler, this_ptr, SL("_fileHandler"), PH_NOISY_CC);
if (!zend_is_true(file_handler)) {
PHALCON_THROW_EXCEPTION_STR(phalcon_logger_exception_ce, "Cannot send message to the log because it is invalid");
return;
}
PHALCON_INIT_VAR(formatter);
phalcon_call_method(formatter, this_ptr, "getformatter");
PHALCON_INIT_VAR(applied_format);
phalcon_call_method_p3(applied_format, formatter, "format", message, type, time);
phalcon_call_func_p2_noret("fwrite", file_handler, applied_format);
PHALCON_MM_RESTORE();
}
示例12: PHP_METHOD
/**
* Checks for annotations in the controller docblock
*
* @param string $handler
* @param Phalcon\Annotations\AdapterInterface
*/
PHP_METHOD(Phalcon_Mvc_Router_Annotations, processControllerAnnotation){
zval *handler, *annotation, *name, *position, *value;
PHALCON_MM_GROW();
phalcon_fetch_params(1, 2, 0, &handler, &annotation);
PHALCON_INIT_VAR(name);
phalcon_call_method(name, annotation, "getname");
/**
* @RoutePrefix add a prefix for all the routes defined in the model
*/
if (PHALCON_IS_STRING(name, "RoutePrefix")) {
PHALCON_INIT_VAR(position);
ZVAL_LONG(position, 0);
PHALCON_INIT_VAR(value);
phalcon_call_method_p1(value, annotation, "getargument", position);
phalcon_update_property_this(this_ptr, SL("_routePrefix"), value TSRMLS_CC);
}
PHALCON_MM_RESTORE();
}
示例13: PHP_METHOD
/**
* Possible controller class name that will be located to dispatch the request
*
* @return string
*/
PHP_METHOD(Phalcon_Mvc_Dispatcher, getControllerClass){
PHALCON_MM_GROW();
phalcon_call_method(return_value, this_ptr, "gethandlername");
RETURN_MM();
}
示例14: PHP_METHOD
/**
* Checks whether the platform supports releasing savepoints.
*
* @return boolean
*/
PHP_METHOD(Phalcon_Db_Dialect, supportsReleaseSavepoints){
PHALCON_MM_GROW();
phalcon_call_method(return_value, this_ptr, "supportssavepoints");
RETURN_MM();
}
示例15: PHP_METHOD
/**
* 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;
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);
}
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_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);
ZVAL_STRING(status_text, "Redirect", 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();
}