From 08fec7bdf846daa3dfa4114310f065294ac092fc Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Fri, 19 Jul 2013 16:25:51 +0300 Subject: Router improvements - Make dashes-to-underscores URI segment replacement configurable via ['translate_uri_dashes']. - Make _set_routing() protected and move the call to the class constructor. - Remove redudant calls to set_class() and set_method(). - Clean-up/optimize the routes loading procedure. (fixes issue #2503) --- user_guide_src/source/changelog.rst | 4 ++-- user_guide_src/source/general/routing.rst | 14 +++++++++++++- 2 files changed, 15 insertions(+), 3 deletions(-) (limited to 'user_guide_src') diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index 0beffb568..efbe86069 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -414,7 +414,7 @@ Release Date: Not Released - :doc:`URI Routing ` changes include: - Added possibility to route requests using callbacks. - - Added possibility to use dashes in the controller and method URI segments (translated to underscores). + - Added a new reserved route (*translate_uri_dashes*) to allow usage of dashes in the controller and method URI segments. - Deprecated methods ``fetch_directory()``, ``fetch_class()`` and ``fetch_method()`` in favor of their respective public properties. - :doc:`Language Library ` changes include: @@ -483,7 +483,7 @@ Bug fixes for 3.0 - Fixed a bug (#23, #1238) - delete_all() in the `Database Caching Library ` used to delete .htaccess and index.html files, which is a potential security risk. - Fixed a bug in :doc:`Trackback Library ` method validate_url() where it didn't actually do anything, due to input not being passed by reference. - Fixed a bug (#11, #183, #863) - CI_Form_validation::_execute() silently continued to the next rule, if a rule method/function is not found. -- Fixed a bug (#122) Where routed uri string was being reported incorrectly in sub-directories. +- Fixed a bug (#122) - routed URI string was being reported incorrectly in sub-directories. - Fixed a bug (#1242) - read_dir() in the :doc:`Zip Library ` wasn't compatible with Windows. - Fixed a bug (#306) - ODBC driver didn't have an _insert_batch() method, which resulted in fatal error being triggered when insert_batch() is used with it. - Fixed a bug in MSSQL and SQLSrv's _truncate() where the TABLE keyword was missing. diff --git a/user_guide_src/source/general/routing.rst b/user_guide_src/source/general/routing.rst index 123257fc8..5520f59fe 100644 --- a/user_guide_src/source/general/routing.rst +++ b/user_guide_src/source/general/routing.rst @@ -145,7 +145,7 @@ routing rules to process the back-references. Example:: Reserved Routes =============== -There are two reserved routes:: +There are three reserved routes:: $route['default_controller'] = 'welcome'; @@ -165,5 +165,17 @@ error page. It won't affect to the ``show_404()`` function, which will continue loading the default *error_404.php* file at *application/views/errors/error_404.php*. + +:: + + $route['translate_uri_dashes'] = FALSE; + +As evident by the boolean value, this is not exactly a route. This +option enables you to automatically replace dashes ('-') with +underscores in the controller and method URI segments, thus saving you +additional route entries if you need to do that. +This is required, because the dash isn't a valid class or method name +character and would cause a fatal error if you try to use it. + .. important:: The reserved routes must come before any wildcard or regular expression routes. \ No newline at end of file -- cgit v1.2.3-24-g4f1b