/** * 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(); }
/** * 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(); }
/** * 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(); }
/** * 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); } }
/** * 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); } }
/** * 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; } }
/** * 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); }
/** * 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"); } }
/** * 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();
/** * 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); }
/** * 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();
/** * 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"); }
/** * 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; }
/** * 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; }
/** * Generates SQL to modify a column in a table * * @param string $tableName * @param string $schemaName * @param Phalcon\Db\ColumnInterface $column * @return string */ PHP_METHOD(Phalcon_Db_Dialect_Oracle, modifyColumn){ zval *table_name, *schema_name, *column; phalcon_fetch_params(0, 3, 0, &table_name, &schema_name, &column); PHALCON_THROW_EXCEPTION_STRW(phalcon_db_exception_ce, "Not implemented yet"); return; }
/** * Generates SQL to add the primary key to a table * * @param string $tableName * @param string $schemaName * @param Phalcon\Db\Index $index * @return string */ PHP_METHOD(Phalcon_Db_Dialect_Oracle, addPrimaryKey){ zval *table_name, *schema_name, *index; phalcon_fetch_params(0, 3, 0, &table_name, &schema_name, &index); PHALCON_THROW_EXCEPTION_STRW(phalcon_db_exception_ce, "Not implemented yet"); return; }
/** * Generates SQL to delete a foreign key from a table * * @param string $tableName * @param string $schemaName * @param string $referenceName * @return string */ PHP_METHOD(Phalcon_Db_Dialect_Oracle, dropForeignKey){ zval *table_name, *schema_name, *reference_name; phalcon_fetch_params(0, 3, 0, &table_name, &schema_name, &reference_name); PHALCON_THROW_EXCEPTION_STRW(phalcon_db_exception_ce, "Not implemented yet"); return; }
/** * 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; }
/** * Registers a form in the Forms Manager * * @param string $name * @param Phalcon\Forms\Form $form * @return Phalcon\Forms\Form */ PHP_METHOD(Phalcon_Forms_Manager, set){ zval *name, *form; phalcon_fetch_params(0, 2, 0, &name, &form); if (Z_TYPE_P(name) != IS_STRING) { PHALCON_THROW_EXCEPTION_STRW(phalcon_forms_exception_ce, "The form name must be string"); return; } if (Z_TYPE_P(form) != IS_OBJECT) { PHALCON_THROW_EXCEPTION_STRW(phalcon_forms_exception_ce, "The form is not valid"); return; } phalcon_update_property_array(this_ptr, SL("_forms"), name, form TSRMLS_CC); RETURN_THISW(); }
/** * Returns a collection by its id * *<code> * $scripts = $assets->get('js'); *</code> * * @param string $id * @return Phalcon\Assets\Collection */ PHP_METHOD(Phalcon_Assets_Manager, get){ zval *id, *collections, *collection; phalcon_fetch_params(0, 1, 0, &id); if (unlikely(Z_TYPE_P(id) != IS_STRING)) { PHALCON_THROW_EXCEPTION_STRW(phalcon_assets_exception_ce, "Collection-Id must be a string"); return; } collections = phalcon_fetch_nproperty_this(this_ptr, SL("_collections"), PH_NOISY TSRMLS_CC); if (!phalcon_array_isset_fetch(&collection, collections, id)) { PHALCON_THROW_EXCEPTION_STRW(phalcon_assets_exception_ce, "The collection does not exist in the manager"); return; } RETURN_ZVAL(collection, 1, 0); }
/** * Sets a service using a raw Phalcon\DI\Service definition * * @param string $name * @param Phalcon\DI\ServiceInterface $rawDefinition * @return Phalcon\DI\ServiceInterface */ PHP_METHOD(Phalcon_DI, setRaw){ zval *name, *raw_definition; phalcon_fetch_params(0, 2, 0, &name, &raw_definition); if (Z_TYPE_P(name) != IS_STRING) { PHALCON_THROW_EXCEPTION_STRW(phalcon_di_exception_ce, "The service name must be a string"); return; } if (Z_TYPE_P(raw_definition) != IS_OBJECT) { PHALCON_THROW_EXCEPTION_STRW(phalcon_di_exception_ce, "The service definition must be an object"); return; } phalcon_update_property_array(this_ptr, SL("_services"), name, raw_definition TSRMLS_CC); RETURN_CCTORW(raw_definition); }
/** * Sets a collection in the Assets Manager * *<code> * $assets->get('js', $collection); *</code> * * @param string $id * @param Phalcon\Assets\Collection $collection * @return Phalcon\Assets\Manager */ PHP_METHOD(Phalcon_Assets_Manager, set){ zval *id, *collection; phalcon_fetch_params(0, 2, 0, &id, &collection); if (unlikely(Z_TYPE_P(id) != IS_STRING)) { PHALCON_THROW_EXCEPTION_STRW(phalcon_assets_exception_ce, "Collection-Id must be a string"); return; } if (unlikely(Z_TYPE_P(collection) != IS_OBJECT)) { PHALCON_THROW_EXCEPTION_STRW(phalcon_assets_exception_ce, "Collection must be an object"); return; } phalcon_update_property_array(this_ptr, SL("_collections"), id, collection TSRMLS_CC); RETURN_THISW(); }
/** * Gets a record in a specific position of the row * * @param int $index * @return string|\Phalcon\Mvc\ModelInterface */ PHP_METHOD(Phalcon_Mvc_Model_Row, offsetGet) { zval *index, value; phalcon_fetch_params(0, 1, 0, &index); if (phalcon_property_isset_fetch_zval(&value, getThis(), index)) { RETURN_CTORW(&value); } PHALCON_THROW_EXCEPTION_STRW(phalcon_mvc_model_exception_ce, "The index does not exist in the row"); }
/** * Stops the event preventing propagation */ PHP_METHOD(Phalcon_Events_Event, stop){ zval *cancelable; cancelable = phalcon_fetch_nproperty_this(this_ptr, SL("_cancelable"), PH_NOISY TSRMLS_CC); if (zend_is_true(cancelable)) { phalcon_update_property_bool(this_ptr, SL("_stopped"), 1 TSRMLS_CC); } else { PHALCON_THROW_EXCEPTION_STRW(phalcon_events_exception_ce, "Trying to cancel a non-cancelable event"); return; } }
/** * Phalcon\Binary\Writer constructor * * @param string|resource $data * @param int $endian * @throws \InvalidArgumentException */ PHP_METHOD(Phalcon_Binary_Writer, __construct){ zval *data = NULL, *endian = NULL, filename = {}, mode = {}, handler = {}, fstat = {}, size = {}; phalcon_fetch_params(0, 0, 2, &data, &endian); if (!data) { data = &PHALCON_GLOBAL(z_null); } if (Z_TYPE_P(data) == IS_STRING || Z_TYPE_P(data) == IS_NULL) { ZVAL_STRING(&filename, "php://memory"); ZVAL_STRING(&mode, "br+"); PHALCON_CALL_FUNCTIONW(&handler, "fopen", &filename, &mode); PHALCON_CALL_FUNCTIONW(NULL, "fwrite", &handler, data); PHALCON_CALL_FUNCTIONW(&fstat, "fstat", &handler); if (phalcon_array_isset_fetch_str(&size, &fstat, SL("size"))) { phalcon_update_property_zval(getThis(), SL("_position"), &size); } phalcon_update_property_zval(getThis(), SL("_output"), &handler); } else if (Z_TYPE_P(data) == IS_RESOURCE) { phalcon_update_property_zval(getThis(), SL("_output"), data); PHALCON_CALL_FUNCTIONW(&fstat, "fstat", data); if (phalcon_array_isset_fetch_str(&size, &fstat, SL("size"))) { phalcon_update_property_zval(getThis(), SL("_position"), &size); } } else { PHALCON_THROW_EXCEPTION_STRW(phalcon_binary_exception_ce, "Data must be set as string or resource"); return; } if (endian && Z_TYPE_P(endian) != IS_NULL) { if (Z_TYPE_P(endian) != IS_LONG || Z_LVAL_P(endian) < 0 || Z_LVAL_P(endian) > 2) { PHALCON_THROW_EXCEPTION_STRW(phalcon_binary_exception_ce, "Endian must be set as big or little"); } phalcon_update_property_zval(getThis(), SL("_endian"), endian); } }
/** * Removes a service in the services container * * @param string $name */ PHP_METHOD(Phalcon_DI, remove){ zval *name; phalcon_fetch_params(0, 1, 0, &name); if (Z_TYPE_P(name) != IS_STRING) { PHALCON_THROW_EXCEPTION_STRW(phalcon_di_exception_ce, "The service name must be a string"); return; } phalcon_unset_property_array(this_ptr, SL("_services"), name TSRMLS_CC); }
/** * Sets the DependencyInjector container * * @param Phalcon\DiInterface $dependencyInjector */ PHP_METHOD(Phalcon_Mvc_Model_Criteria, setDI){ zval *dependency_injector; phalcon_fetch_params(0, 1, 0, &dependency_injector); if (Z_TYPE_P(dependency_injector) != IS_OBJECT) { PHALCON_THROW_EXCEPTION_STRW(phalcon_mvc_model_exception_ce, "Dependency Injector is invalid"); return; } phalcon_update_property_array_string(this_ptr, SL("_params"), SS("di"), dependency_injector TSRMLS_CC); }
/** * Assigns the data to an entity * The entity is used to obtain the validation values * * @param string $entity * @param string $data * @return Phalcon\Validation */ PHP_METHOD(Phalcon_Validation, bind){ zval *entity, *data; phalcon_fetch_params(0, 2, 0, &entity, &data); if (Z_TYPE_P(entity) != IS_OBJECT) { PHALCON_THROW_EXCEPTION_STRW(phalcon_validation_exception_ce, "The entity must be an object"); return; } if (Z_TYPE_P(data) != IS_ARRAY) { if (Z_TYPE_P(data) != IS_OBJECT) { PHALCON_THROW_EXCEPTION_STRW(phalcon_validation_exception_ce, "The data to validate must be an array or object"); return; } } phalcon_update_property_this(this_ptr, SL("_entity"), entity TSRMLS_CC); phalcon_update_property_this(this_ptr, SL("_data"), data TSRMLS_CC); RETURN_THISW(); }
/** * Phalcon\Session\Bag constructor * * @param string $name */ PHP_METHOD(Phalcon_Session_Bag, __construct){ zval *name; phalcon_fetch_params(0, 1, 0, &name); if (Z_TYPE_P(name) != IS_STRING) { PHALCON_THROW_EXCEPTION_STRW(phalcon_session_exception_ce, "The name parameter must be a string"); return; } phalcon_update_property_this(this_ptr, SL("_name"), name TSRMLS_CC); }
/** * Sets the DependencyInjector container * * @param Phalcon\DiInterface $dependencyInjector */ PHP_METHOD(Phalcon_Session_Bag, setDI){ zval *dependency_injector; phalcon_fetch_params(0, 1, 0, &dependency_injector); if (Z_TYPE_P(dependency_injector) != IS_OBJECT) { PHALCON_THROW_EXCEPTION_STRW(phalcon_session_exception_ce, "The dependency injector must be an Object"); return; } phalcon_update_property_this(this_ptr, SL("_dependencyInjector"), dependency_injector TSRMLS_CC); }