Skip to content

Commit

Permalink
Merge pull request #1796 from sjinks/ini
Browse files Browse the repository at this point in the history
Use INI entries to control ORM options
  • Loading branch information
Phalcon committed Jan 13, 2014
2 parents b03a17c + cd3a2f4 commit 2924a4d
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
- Fixed PHP notices, warnings and other incompatibilities (#894, #1222, #1315, #1413, #1427, #1428, #1529)
- Fixed inheritance chain for Phalcon\Forms\Exception, Phalcon\Loader\Exception, Phalcon\Http\Request\Exception (#1770)
- Major source coede optimizations (#1785)
- Control Phalcon behavior via INI settings (#1796)
- Security fixes:
- Hardening fixes (#1044)
- Interface validation (#1043, #1048)
Expand Down
25 changes: 24 additions & 1 deletion ext/phalcon.c
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,27 @@ static void phalcon_verify_permanent_zvals(int strict TSRMLS_DC)

#endif

PHP_INI_BEGIN()
/* Enables/Disables globally the internal events */
STD_PHP_INI_BOOLEAN("phalcon.orm.events", "1", PHP_INI_ALL, OnUpdateBool, orm.events, zend_phalcon_globals, phalcon_globals)
/* Enables/Disables virtual foreign keys */
STD_PHP_INI_BOOLEAN("phalcon.orm.virtual_foreign_keys", "1", PHP_INI_ALL, OnUpdateBool, orm.virtual_foreign_keys, zend_phalcon_globals, phalcon_globals)
/* Enables/Disables column renaming */
STD_PHP_INI_BOOLEAN("phalcon.orm.column_renaming", "1", PHP_INI_ALL, OnUpdateBool, orm.column_renaming, zend_phalcon_globals, phalcon_globals)
/* Enables/Disables automatic NOT NULL validation */
STD_PHP_INI_BOOLEAN("phalcon.orm.not_null_validations", "1", PHP_INI_ALL, OnUpdateBool, orm.not_null_validations, zend_phalcon_globals, phalcon_globals)
/* Enables/Disables throwing an exception if save fails */
STD_PHP_INI_BOOLEAN("phalcon.orm.exception_on_failed_save", "0", PHP_INI_ALL, OnUpdateBool, orm.exception_on_failed_save, zend_phalcon_globals, phalcon_globals)
/* Enables/Disables literals in PHQL */
STD_PHP_INI_BOOLEAN("phalcon.orm.enable_literals", "1", PHP_INI_ALL, OnUpdateBool, orm.enable_literals, zend_phalcon_globals, phalcon_globals)
/* Not used? */
STD_PHP_INI_BOOLEAN("phalcon.db.escape_identifiers", "1", PHP_INI_ALL, OnUpdateBool, db.escape_identifiers, zend_phalcon_globals, phalcon_globals)
PHP_INI_END()

static PHP_MINIT_FUNCTION(phalcon){

REGISTER_INI_ENTRIES();

nusphere_dbg_present = (zend_get_extension("DBG") != NULL);

PHALCON_INIT(Phalcon_DI_InjectionAwareInterface);
Expand Down Expand Up @@ -509,6 +528,8 @@ static PHP_MSHUTDOWN_FUNCTION(phalcon){
assert(PHALCON_GLOBAL(orm).parser_cache == NULL);
assert(PHALCON_GLOBAL(orm).ast_cache == NULL);

UNREGISTER_INI_ENTRIES();

zend_execute_internal = orig_execute_internal;
return SUCCESS;
}
Expand Down Expand Up @@ -548,6 +569,8 @@ static PHP_MINFO_FUNCTION(phalcon)
php_info_print_table_row(2, "Phalcon Framework", "enabled");
php_info_print_table_row(2, "Phalcon Version", PHP_PHALCON_VERSION);
php_info_print_table_end();

DISPLAY_INI_ENTRIES();
}

static PHP_GINIT_FUNCTION(phalcon)
Expand Down Expand Up @@ -703,7 +726,7 @@ zend_module_dep phalcon_deps[] = {

zend_module_entry phalcon_module_entry = {
STANDARD_MODULE_HEADER_EX,
NULL,
ini_entries,
phalcon_deps,
PHP_PHALCON_EXTNAME,
NULL,
Expand Down

0 comments on commit 2924a4d

Please sign in to comment.