本文整理汇总了C++中PHALCON_THROW_EXCEPTION_STRW函数的典型用法代码示例。如果您正苦于以下问题:C++ PHALCON_THROW_EXCEPTION_STRW函数的具体用法?C++ PHALCON_THROW_EXCEPTION_STRW怎么用?C++ PHALCON_THROW_EXCEPTION_STRW使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了PHALCON_THROW_EXCEPTION_STRW函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: PHP_METHOD
/**
* Adds a resource to the annotations handler
* A resource is a class that contains routing annotations
* The class is located in a module
*
* @param string $module
* @param string $handler
* @param string $prefix
* @return Phalcon\Mvc\Router\Annotations
*/
PHP_METHOD(Phalcon_Mvc_Router_Annotations, addModuleResource){
zval *module, *handler, *prefix = NULL, *scope;
phalcon_fetch_params(0, 2, 1, &module, &handler, &prefix);
if (!prefix) {
prefix = PHALCON_GLOBAL(z_null);
}
if (Z_TYPE_P(module) != IS_STRING) {
PHALCON_THROW_EXCEPTION_STRW(phalcon_mvc_router_exception_ce, "The module is not a valid string");
return;
}
if (Z_TYPE_P(handler) != IS_STRING) {
PHALCON_THROW_EXCEPTION_STRW(phalcon_mvc_router_exception_ce, "The handler must be a class name");
return;
}
MAKE_STD_ZVAL(scope);
array_init_size(scope, 3);
phalcon_array_append(&scope, prefix, 0);
phalcon_array_append(&scope, handler, 0);
phalcon_array_append(&scope, module, 0);
phalcon_update_property_array_append(this_ptr, SL("_handlers"), scope TSRMLS_CC);
zval_ptr_dtor(&scope);
phalcon_update_property_this(this_ptr, SL("_processed"), PHALCON_GLOBAL(z_false) TSRMLS_CC);
RETURN_THISW();
}
示例2: PHP_METHOD
/**
* Changes a parameter in the definition without resolve the service
*
* @param long $position
* @param array $parameter
* @return Phalcon\DI\Service
*/
PHP_METHOD(Phalcon_DI_Service, setParameter){
zval *position, *parameter, definition = {}, arguments = {};
phalcon_fetch_params(0, 2, 0, &position, ¶meter);
PHALCON_ENSURE_IS_LONG(position);
phalcon_return_property(&definition, getThis(), SL("_definition"));
if (unlikely(Z_TYPE(definition) != IS_ARRAY)) {
PHALCON_THROW_EXCEPTION_STRW(phalcon_di_exception_ce, "Definition must be an array to update its parameters");
return;
}
if (unlikely(Z_TYPE_P(parameter) != IS_ARRAY)) {
PHALCON_THROW_EXCEPTION_STRW(phalcon_di_exception_ce, "The parameter must be an array");
return;
}
/* Update the parameter */
if (phalcon_array_isset_fetch_str(&arguments, &definition, SL("arguments"))) {
phalcon_array_update_zval(&arguments, position, parameter, PH_COPY);
} else {
array_init_size(&arguments, 1);
phalcon_array_update_zval(&arguments, position, parameter, PH_COPY);
}
phalcon_array_update_str(&definition, SL("arguments"), &arguments, PH_COPY);
phalcon_update_property_zval(getThis(), SL("_definition"), &definition);
RETURN_THISW();
}
示例3: PHP_METHOD
/**
* Phalcon\Translate\Adapter\Gettext constructor
*
* @param array $options
* @throws \Phalcon\Translate\Exception
*/
PHP_METHOD(Phalcon_Translate_Adapter_Gettext, __construct){
zval *options, *locale, *default_domain, *directory, *setting, *key = NULL, *value = NULL;
HashTable *ah0;
HashPosition hp0;
zval **hd;
PHALCON_MM_GROW();
phalcon_fetch_params(1, 1, 0, &options);
if (Z_TYPE_P(options) != IS_ARRAY) {
PHALCON_THROW_EXCEPTION_STRW(phalcon_translate_exception_ce, "Invalid options");
return;
}
if (!phalcon_array_isset_string_fetch(&locale, options, SS("locale"))) {
PHALCON_THROW_EXCEPTION_STRW(phalcon_translate_exception_ce, "Parameter \"locale\" is required");
return;
}
if (!phalcon_array_isset_string_fetch(&default_domain, options, SS("defaultDomain"))) {
PHALCON_THROW_EXCEPTION_STRW(phalcon_translate_exception_ce, "Parameter \"defaultDomain\" is required");
return;
}
if (!phalcon_array_isset_string_fetch(&directory, options, SS("directory"))) {
PHALCON_THROW_EXCEPTION_STRW(phalcon_translate_exception_ce, "Parameter \"directory\" is required");
return;
}
phalcon_update_property_this(this_ptr, SL("_locale"), locale TSRMLS_CC);
phalcon_update_property_this(this_ptr, SL("_defaultDomain"), default_domain TSRMLS_CC);
phalcon_update_property_this(this_ptr, SL("_directory"), directory TSRMLS_CC);
PHALCON_INIT_VAR(setting);
PHALCON_CONCAT_SV(setting, "LC_ALL=", locale);
PHALCON_CALL_FUNCTION(NULL, "putenv", setting);
setlocale(LC_ALL, Z_STRVAL_P(locale));
if (Z_TYPE_P(directory) == IS_ARRAY) {
phalcon_is_iterable(directory, &ah0, &hp0, 0, 0);
while (zend_hash_get_current_data_ex(ah0, (void**) &hd, &hp0) == SUCCESS) {
PHALCON_GET_HKEY(key, ah0, hp0);
PHALCON_GET_HVALUE(value);
bindtextdomain(Z_STRVAL_P(key), Z_STRVAL_P(value));
zend_hash_move_forward_ex(ah0, &hp0);
}
} else {
bindtextdomain(Z_STRVAL_P(default_domain), Z_STRVAL_P(directory));
}
textdomain(Z_STRVAL_P(default_domain));
PHALCON_MM_RESTORE();
}
示例4: PHP_METHOD
/**
* Phalcon\Paginator\Adapter\Sql
*
* @param array $config
*/
PHP_METHOD(Phalcon_Paginator_Adapter_Sql, __construct){
zval *config, db = {}, sql = {}, total_sql = {}, bind = {}, limit = {}, page = {};
long int i_limit;
phalcon_fetch_params(0, 1, 0, &config);
if (!phalcon_array_isset_fetch_str(&db, config, SL("db"))) {
PHALCON_THROW_EXCEPTION_STRW(phalcon_paginator_exception_ce, "Parameter 'db' is required");
return;
}
if (!phalcon_array_isset_fetch_str(&sql, config, SL("sql"))) {
PHALCON_THROW_EXCEPTION_STRW(phalcon_paginator_exception_ce, "Parameter 'sql' is required");
return;
}
if (!phalcon_array_isset_fetch_str(&total_sql, config, SL("total_sql"))) {
PHALCON_THROW_EXCEPTION_STRW(phalcon_paginator_exception_ce, "Parameter 'sql' is required");
return;
}
if (phalcon_array_isset_fetch_str(&bind, config, SL("bind"))) {
if (Z_TYPE_P(&bind) != IS_ARRAY) {
phalcon_update_property_empty_array(getThis(), SL("_bind"));
} else {
phalcon_update_property_this(getThis(), SL("_bind"), &bind);
}
} else {
phalcon_update_property_empty_array(getThis(), SL("_bind"));
}
PHALCON_VERIFY_INTERFACE_EX(&db, phalcon_db_adapterinterface_ce, phalcon_paginator_exception_ce, 0);
phalcon_update_property_this(getThis(), SL("_db"), &db);
phalcon_update_property_this(getThis(), SL("_sql"), &sql);
phalcon_update_property_this(getThis(), SL("_total_sql"), &total_sql);
if (!phalcon_array_isset_fetch_str(&limit, config, SL("limit"))) {
PHALCON_THROW_EXCEPTION_STRW(phalcon_paginator_exception_ce, "Parameter 'limit' is required");
return;
}
i_limit = phalcon_get_intval(&limit);
if (i_limit < 1) {
PHALCON_THROW_EXCEPTION_STRW(phalcon_paginator_exception_ce, "'limit' should be positive");
return;
}
phalcon_update_property_this(getThis(), SL("_limitRows"), &limit);
if (phalcon_array_isset_fetch_str(&page, config, SL("page"))) {
phalcon_update_property_this(getThis(), SL("_page"), &page);
}
}
示例5: PHP_METHOD
/**
* Phalcon\Logger\Adapter\Stream constructor
*
* @param string $name
* @param array $options
*/
PHP_METHOD(Phalcon_Logger_Adapter_Stream, __construct){
zval *name, *options = NULL, mode = {}, stream = {};
phalcon_fetch_params(0, 1, 1, &name, &options);
PHALCON_ENSURE_IS_STRING(name);
if (!options) {
options = &PHALCON_GLOBAL(z_null);
}
if (phalcon_array_isset_fetch_str(&mode, options, SL("mode"))) {
if (phalcon_memnstr_str(&mode, SL("r"))) {
PHALCON_THROW_EXCEPTION_STRW(phalcon_logger_exception_ce, "Stream must be opened in append or write mode");
return;
}
} else {
ZVAL_STRING(&mode, "ab");
}
/**
* We use 'fopen' to respect to open-basedir directive
*/
PHALCON_CALL_FUNCTIONW(&stream, "fopen", name, &mode);
if (Z_TYPE(stream) != IS_RESOURCE) {
zend_throw_exception_ex(phalcon_logger_exception_ce, 0, "Cannot open stream '%s'", Z_STRVAL_P(name));
} else {
phalcon_update_property_this(getThis(), SL("_stream"), &stream);
}
}
示例6: PHP_METHOD
/**
* Writes parsed annotations to files
*
* @param string $key
* @param Phalcon\Annotations\Reflection $data
*/
PHP_METHOD(Phalcon_Annotations_Adapter_Files, write){
zval *key, *data, annotations_dir = {}, virtual_key = {}, path = {}, php_export = {}, status = {};
smart_str exp = { 0 };
phalcon_fetch_params(0, 2, 0, &key, &data);
PHALCON_ENSURE_IS_STRING(key);
phalcon_return_property(&annotations_dir, getThis(), SL("_annotationsDir"));
/**
* Paths must be normalized before be used as keys
*/
phalcon_prepare_virtual_path_ex(&virtual_key, Z_STRVAL_P(key), Z_STRLEN_P(key), '_');
PHALCON_CONCAT_VVS(&path, &annotations_dir, &virtual_key, ".php");
smart_str_appends(&exp, "<?php return ");
php_var_export_ex(data, 0, &exp);
smart_str_appendc(&exp, ';');
smart_str_0(&exp);
ZVAL_STR(&php_export, exp.s);
phalcon_file_put_contents(&status, &path, &php_export);
if (PHALCON_IS_FALSE(&status)) {
PHALCON_THROW_EXCEPTION_STRW(phalcon_annotations_exception_ce, "Annotations directory cannot be written");
return;
}
}
示例7: PHP_METHOD
/**
* Gets a param by its name or numeric index
*
* @param mixed $param
* @param string|array $filters
* @param mixed $defaultValue
* @return mixed
*/
PHP_METHOD(Phalcon_Http_Request, getParam){
zval *param, *filters = NULL, *default_value = NULL, dependency_injector = {}, service = {}, dispatcher = {};
phalcon_fetch_params(0, 1, 2, ¶m, &filters, &default_value);
if (!filters) {
filters = &PHALCON_GLOBAL(z_null);
}
if (!default_value) {
default_value = &PHALCON_GLOBAL(z_null);
}
PHALCON_CALL_METHODW(&dependency_injector, getThis(), "getdi");
if (Z_TYPE(dependency_injector) != IS_OBJECT) {
PHALCON_THROW_EXCEPTION_STRW(phalcon_http_request_exception_ce, "A dependency injection object is required to access the 'filter' service");
return;
}
PHALCON_STR(&service, ISV(dispatcher));
PHALCON_CALL_METHODW(&dispatcher, &dependency_injector, "getshared", &service);
PHALCON_CALL_METHODW(NULL, &dispatcher, "getparam", param, filters, default_value);
}
示例8: PHP_METHOD
/**
* Phalcon\Mvc\Model\Transaction constructor
*
* @param Phalcon\DIInterface $dependencyInjector
* @param boolean $autoBegin
* @param string $service
*/
PHP_METHOD(Phalcon_Mvc_Model_Transaction, __construct){
zval *dependency_injector, *auto_begin = NULL, *s = NULL, service = {}, connection = {};
phalcon_fetch_params(0, 1, 2, &dependency_injector, &auto_begin, &service);
if (!auto_begin) {
auto_begin = &PHALCON_GLOBAL(z_false);
}
if (!s || Z_TYPE_P(s) != IS_STRING) {
ZVAL_STRING(&service, "db");
} else {
PHALCON_CPY_WRT(&service, s);
}
if (Z_TYPE_P(dependency_injector) != IS_OBJECT) {
PHALCON_THROW_EXCEPTION_STRW(phalcon_mvc_model_transaction_exception_ce, "A dependency injector container is required to obtain the services related to the ORM");
return;
}
PHALCON_CALL_METHODW(&connection, dependency_injector, "get", &service);
phalcon_update_property_zval(getThis(), SL("_connection"), &connection);
if (zend_is_true(auto_begin)) {
PHALCON_CALL_METHODW(NULL, &connection, "begin");
}
}
示例9: PHP_METHOD
/**
* Sets values
*
* @param array $arrayConfig
*/
PHP_METHOD(Phalcon_Config, val){
zval *array_config, *value;
zend_string *str_key;
ulong idx;
phalcon_fetch_params(0, 1, 0, &array_config);
/**
* Throw exceptions if bad parameters are passed
*/
if (Z_TYPE_P(array_config) != IS_ARRAY) {
PHALCON_THROW_EXCEPTION_STRW(phalcon_config_exception_ce, "The configuration must be an Array");
return;
}
ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(array_config), idx, str_key, value) {
zval key;
if (str_key) {
ZVAL_STR(&key, str_key);
} else {
ZVAL_LONG(&key, idx);
}
PHALCON_CALL_SELFW(NULL, "offsetset", &key, value);
} ZEND_HASH_FOREACH_END();
示例10: PHP_METHOD
/**
* Creates a form registering it in the forms manager
*
* @param string $name
* @param object $entity
* @return Phalcon\Forms\Form
*/
PHP_METHOD(Phalcon_Forms_Manager, create){
zval *name = NULL, *entity = NULL, form = {};
phalcon_fetch_params(0, 0, 2, &name, &entity);
if (!name) {
name = &PHALCON_GLOBAL(z_null);
}
if (!entity) {
entity = &PHALCON_GLOBAL(z_null);
}
if (Z_TYPE_P(name) != IS_STRING) {
PHALCON_THROW_EXCEPTION_STRW(phalcon_forms_exception_ce, "The form name must be string");
return;
}
object_init_ex(&form, phalcon_forms_form_ce);
PHALCON_CALL_METHODW(NULL, &form, "__construct", entity);
phalcon_update_property_array(getThis(), SL("_forms"), name, &form);
RETURN_CTORW(&form);
}
示例11: PHP_METHOD
/**
* Draws a polygon
*
*<code>
* $coordinates = array( array( 'x' => 4, 'y' => 6 ), array( 'x' => 8, 'y' => 10 ) );
* $image->polygon($coordinates);
*</code>
*
* @param array $coordinates array of x and y
* @param string $color
* @return Phalcon\Image\Adapter\GD
*/
PHP_METHOD(Phalcon_Image_Adapter_GD, polygon){
zval *coordinates, *color = NULL, image = {}, rgb = {}, r = {}, g = {}, b = {}, imagecolor = {}, *point, points = {}, num_points = {};
phalcon_fetch_params(0, 1, 1, &coordinates, &color);
if (!color) {
color = &PHALCON_GLOBAL(z_null);
}
if (!phalcon_fast_count_ev(coordinates)) {
PHALCON_THROW_EXCEPTION_STRW(phalcon_image_exception_ce, "Coordinates must be not empty");
return;
}
phalcon_return_property(&image, getThis(), SL("_image"));
if (Z_TYPE(image) == IS_RESOURCE) {
PHALCON_CALL_METHODW(&rgb, getThis(), "getcolorrbg", color);
phalcon_array_fetch_long(&r, &rgb, 0, PH_NOISY);
phalcon_array_fetch_long(&g, &rgb, 1, PH_NOISY);
phalcon_array_fetch_long(&b, &rgb, 2, PH_NOISY);
PHALCON_CALL_FUNCTIONW(&imagecolor, "imagecolorallocate", &image, &r, &g, &b);
array_init(&points);
ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(coordinates), point) {
zval x = {}, y = {};
if (Z_TYPE_P(point) == IS_ARRAY) {
if (phalcon_fast_count_int(point) != 2) {
PHALCON_THROW_EXCEPTION_STRW(phalcon_image_exception_ce, "Coordinates point error");
return;
}
if (!phalcon_array_isset_fetch_long(&x, point, 0)) {
phalcon_array_fetch_str(&x, point, SL("x"), PH_NOISY);
}
if (!phalcon_array_isset_fetch_long(&y, point, 0)) {
phalcon_array_fetch_str(&y, point, SL("y"), PH_NOISY);
}
phalcon_array_append(&points, &x, PH_COPY);
phalcon_array_append(&points, &y, PH_COPY);
} else {
phalcon_array_append(&points, &_p->val, PH_COPY);
_p++;
phalcon_array_append(&points, &_p->val, PH_COPY);
}
phalcon_increment(&num_points);
} ZEND_HASH_FOREACH_END();
示例12: PHP_METHOD
/**
* Rows cannot be changed. It has only been implemented to meet the definition of the ArrayAccess interface
*
* @param int $offset
*/
PHP_METHOD(Phalcon_Mvc_Model_Row, offsetUnset) {
zval *offset;
phalcon_fetch_params(0, 1, 0, &offset);
PHALCON_THROW_EXCEPTION_STRW(phalcon_mvc_model_exception_ce, "The index does not exist in the row");
}
示例13: PHP_METHOD
/**
* Generates SQL to create a table in PostgreSQL
*
* @param string $tableName
* @param string $schemaName
* @param array $definition
* @return string
*/
PHP_METHOD(Phalcon_Db_Dialect_Oracle, createTable){
zval *table_name, *schema_name, *definition;
phalcon_fetch_params(0, 3, 0, &table_name, &schema_name, &definition);
PHALCON_THROW_EXCEPTION_STRW(phalcon_db_exception_ce, "Not implemented yet");
return;
}
示例14: PHP_METHOD
/**
* Resulsets cannot be changed. It has only been implemented to meet the definition of the ArrayAccess interface
*
* @param int $offset
*/
PHP_METHOD(Phalcon_Mvc_Model_Resultset, offsetUnset){
zval *offset;
phalcon_fetch_params(0, 1, 0, &offset);
PHALCON_THROW_EXCEPTION_STRW(phalcon_mvc_model_exception_ce, "Cursor is an immutable ArrayAccess object");
return;
}
示例15: PHP_METHOD
/**
* Rows cannot be changed. It has only been implemented to meet the definition of the ArrayAccess interface
*
* @param string $offset
*/
PHP_METHOD(Phalcon_Mvc_Collection_Document, offsetUnset){
zval *offset;
phalcon_fetch_params(0, 1, 0, &offset);
PHALCON_THROW_EXCEPTION_STRW(phalcon_mvc_collection_exception_ce, "The index does not exist in the row");
return;
}