Moved module configuration back into config/kohana.php, modified Kohana::init and Kohana::modules
This commit is contained in:
parent
d1679e9614
commit
9c4f0ef956
|
@ -1,9 +1,28 @@
|
|||
<?php
|
||||
/**
|
||||
* Main application configuration for preparing the environment. Modules are
|
||||
* configured here, as well as l10n and i18n settings.
|
||||
*
|
||||
* @package Core
|
||||
*/
|
||||
return array
|
||||
(
|
||||
/**
|
||||
* Modules are additional resource paths. Any file that can be placed within
|
||||
* the application or system directories can also be placed in a module.
|
||||
* All modules are relative or absolute paths to directories.
|
||||
*
|
||||
* @see http://docs.kohanaphp.com/modules
|
||||
*/
|
||||
'modules' => array
|
||||
(
|
||||
'documentation' => MODPATH,
|
||||
'html' => MODPATH,
|
||||
'database' => MODPATH,
|
||||
// 'orm' => MODPATH,
|
||||
// 'email' => MODPATH,
|
||||
),
|
||||
|
||||
/**
|
||||
* Locale of your application. Note that even if you are not using a POSIX
|
||||
* system, the first locale must be POSIX `xx_XX` locale name for internal i18n
|
||||
|
@ -18,6 +37,7 @@ return array
|
|||
/**
|
||||
* Time zone of your application. Use NULL to use the default system time zone.
|
||||
*
|
||||
* @see http://docs.kohanaphp.com/i18n
|
||||
* @see http://php.net/manual/timezones.php
|
||||
* @see http://php.net/manual/datetime.configuration.php
|
||||
*/
|
||||
|
@ -34,8 +54,8 @@ return array
|
|||
'save_cache' => FALSE,
|
||||
|
||||
/**
|
||||
* Default locale of your application. Change this to the POSXI locale of the
|
||||
* language that is used as the default text in views.
|
||||
* Default locale of your application. Change this to the POSIX locale of the
|
||||
* language that is used as the primary development language.
|
||||
*
|
||||
* @see http://docs.kohanaphp.com/i18n
|
||||
*/
|
||||
|
|
53
index.php
53
index.php
|
@ -2,61 +2,50 @@
|
|||
/**
|
||||
* The directory in which your application specific resources are located.
|
||||
* The application directory must contain the config/kohana.php file.
|
||||
*
|
||||
*
|
||||
* @see http://docs.kohanaphp.com/install#application
|
||||
*/
|
||||
$application = 'application';
|
||||
|
||||
/**
|
||||
* The directory in which your modules are located.
|
||||
*
|
||||
* @see http://docs.kohanaphp.com/install#modules
|
||||
*/
|
||||
$modules = 'modules';
|
||||
|
||||
/**
|
||||
* The directory in which the Kohana resources are located. The system
|
||||
* directory must contain the classes/kohana.php file.
|
||||
*
|
||||
*
|
||||
* @see http://docs.kohanaphp.com/install#system
|
||||
*/
|
||||
$system = 'system';
|
||||
|
||||
/**
|
||||
* Modules are additional resource paths. Any file that can be placed within
|
||||
* the application or system directories can also be placed in a module.
|
||||
* All modules are relative or absolute paths to directories.
|
||||
*
|
||||
* @see http://docs.kohanaphp.com/modules
|
||||
*/
|
||||
$modules = 'modules';
|
||||
|
||||
/**
|
||||
* Modules are additional resource paths. Any file that can be placed within
|
||||
* the application or system directories can also be placed in a module.
|
||||
* All modules are relative or absolute paths to directories.
|
||||
*
|
||||
* @see http://docs.kohanaphp.com/modules
|
||||
*/
|
||||
$modules = array
|
||||
(
|
||||
'modules/database',
|
||||
'modules/forms',
|
||||
'modules/email',
|
||||
);
|
||||
|
||||
/**
|
||||
* The default extension of resource files. If you change this, all resources
|
||||
* must be renamed to use the new extension.
|
||||
*
|
||||
*
|
||||
* @see http://docs.kohanaphp.com/install#ext
|
||||
*/
|
||||
define('EXT', '.php');
|
||||
|
||||
//
|
||||
// END OF CONFIGURATION, DO NOT EDIT BELOW!
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
/**
|
||||
* End of standard configuration! Changing any of the code below should only be
|
||||
* attempted by those with a working knowledge of Kohana internals.
|
||||
*
|
||||
* @see http://docs.kohanaphp.com/bootstrap
|
||||
*
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
// Define the name of the front controller
|
||||
define('FC_FILE', basename(__FILE__));
|
||||
// Define the name of the front controller index
|
||||
define('FCINDEX', basename(__FILE__));
|
||||
|
||||
// Define the absolute paths for configured directories
|
||||
define('DOCROOT', str_replace('\\', '/', realpath(getcwd())).'/');
|
||||
define('APPPATH', str_replace('\\', '/', realpath($application)).'/');
|
||||
define('MODPATH', str_replace('\\', '/', realpath($modules)).'/');
|
||||
define('SYSPATH', str_replace('\\', '/', realpath($system)).'/');
|
||||
|
||||
// Clean up the configuration vars
|
||||
|
|
|
@ -47,6 +47,9 @@ final class Kohana {
|
|||
// Environment has been initialized?
|
||||
private static $init = FALSE;
|
||||
|
||||
// Current modules
|
||||
private static $modules = array();
|
||||
|
||||
// Include paths that are used to find files
|
||||
private static $include_paths = array(APPPATH, SYSPATH);
|
||||
|
||||
|
@ -99,6 +102,9 @@ final class Kohana {
|
|||
// Set the enviroment time
|
||||
self::timezone($config->timezone);
|
||||
|
||||
// Enable modules
|
||||
self::modules($config->modules);
|
||||
|
||||
if ($hooks = self::list_files('hooks', TRUE))
|
||||
{
|
||||
foreach ($hooks as $hook)
|
||||
|
@ -330,34 +336,44 @@ final class Kohana {
|
|||
* @param array module paths
|
||||
* @return void
|
||||
*/
|
||||
public static function modules(array $modules)
|
||||
public static function modules(array $modules = NULL)
|
||||
{
|
||||
// Start a new set of include paths, APPPATH first
|
||||
$paths = array(APPPATH);
|
||||
if ($modules === NULL)
|
||||
return $modules;
|
||||
|
||||
foreach ($modules as $module)
|
||||
// Start a new set of include paths, APPPATH first
|
||||
$include_paths = array(APPPATH);
|
||||
|
||||
foreach ($modules as $name => $path)
|
||||
{
|
||||
if (is_dir($module))
|
||||
if (is_dir($path))
|
||||
{
|
||||
// Get the absolute path to the module
|
||||
$module = realpath($module);
|
||||
$path = realpath($path);
|
||||
|
||||
if (Kohana::$is_windows === TRUE)
|
||||
{
|
||||
// Remove backslashes
|
||||
$module = str_replace('\\', '/', $module);
|
||||
$path = str_replace('\\', '/', $path);
|
||||
}
|
||||
|
||||
// Add the module to include paths
|
||||
$paths[] = $module.'/';
|
||||
$include_paths[] = $path.'/';
|
||||
}
|
||||
else
|
||||
{
|
||||
unset($modules[$name]);
|
||||
}
|
||||
}
|
||||
|
||||
// Set the current module list
|
||||
self::$modules = $modules;
|
||||
|
||||
// Finish the include paths by adding SYSPATH
|
||||
$paths[] = SYSPATH;
|
||||
$include_paths[] = SYSPATH;
|
||||
|
||||
// Set the new include paths
|
||||
self::$include_paths = $paths;
|
||||
self::$include_paths = $include_paths;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue