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
|
<?php
|
||||||
/**
|
/**
|
||||||
|
* Main application configuration for preparing the environment. Modules are
|
||||||
|
* configured here, as well as l10n and i18n settings.
|
||||||
*
|
*
|
||||||
|
* @package Core
|
||||||
*/
|
*/
|
||||||
return array
|
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
|
* 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
|
* 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.
|
* 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/timezones.php
|
||||||
* @see http://php.net/manual/datetime.configuration.php
|
* @see http://php.net/manual/datetime.configuration.php
|
||||||
*/
|
*/
|
||||||
|
@ -34,8 +54,8 @@ return array
|
||||||
'save_cache' => FALSE,
|
'save_cache' => FALSE,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default locale of your application. Change this to the POSXI locale of the
|
* Default locale of your application. Change this to the POSIX locale of the
|
||||||
* language that is used as the default text in views.
|
* language that is used as the primary development language.
|
||||||
*
|
*
|
||||||
* @see http://docs.kohanaphp.com/i18n
|
* @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 directory in which your application specific resources are located.
|
||||||
* The application directory must contain the config/kohana.php file.
|
* The application directory must contain the config/kohana.php file.
|
||||||
*
|
*
|
||||||
* @see http://docs.kohanaphp.com/install#application
|
* @see http://docs.kohanaphp.com/install#application
|
||||||
*/
|
*/
|
||||||
$application = '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
|
* The directory in which the Kohana resources are located. The system
|
||||||
* directory must contain the classes/kohana.php file.
|
* directory must contain the classes/kohana.php file.
|
||||||
*
|
*
|
||||||
* @see http://docs.kohanaphp.com/install#system
|
* @see http://docs.kohanaphp.com/install#system
|
||||||
*/
|
*/
|
||||||
$system = '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
|
* The default extension of resource files. If you change this, all resources
|
||||||
* must be renamed to use the new extension.
|
* must be renamed to use the new extension.
|
||||||
*
|
*
|
||||||
* @see http://docs.kohanaphp.com/install#ext
|
* @see http://docs.kohanaphp.com/install#ext
|
||||||
*/
|
*/
|
||||||
define('EXT', '.php');
|
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 the name of the front controller index
|
||||||
define('FC_FILE', basename(__FILE__));
|
define('FCINDEX', basename(__FILE__));
|
||||||
|
|
||||||
// Define the absolute paths for configured directories
|
// Define the absolute paths for configured directories
|
||||||
define('DOCROOT', str_replace('\\', '/', realpath(getcwd())).'/');
|
define('DOCROOT', str_replace('\\', '/', realpath(getcwd())).'/');
|
||||||
define('APPPATH', str_replace('\\', '/', realpath($application)).'/');
|
define('APPPATH', str_replace('\\', '/', realpath($application)).'/');
|
||||||
|
define('MODPATH', str_replace('\\', '/', realpath($modules)).'/');
|
||||||
define('SYSPATH', str_replace('\\', '/', realpath($system)).'/');
|
define('SYSPATH', str_replace('\\', '/', realpath($system)).'/');
|
||||||
|
|
||||||
// Clean up the configuration vars
|
// Clean up the configuration vars
|
||||||
|
|
|
@ -47,6 +47,9 @@ final class Kohana {
|
||||||
// Environment has been initialized?
|
// Environment has been initialized?
|
||||||
private static $init = FALSE;
|
private static $init = FALSE;
|
||||||
|
|
||||||
|
// Current modules
|
||||||
|
private static $modules = array();
|
||||||
|
|
||||||
// Include paths that are used to find files
|
// Include paths that are used to find files
|
||||||
private static $include_paths = array(APPPATH, SYSPATH);
|
private static $include_paths = array(APPPATH, SYSPATH);
|
||||||
|
|
||||||
|
@ -99,6 +102,9 @@ final class Kohana {
|
||||||
// Set the enviroment time
|
// Set the enviroment time
|
||||||
self::timezone($config->timezone);
|
self::timezone($config->timezone);
|
||||||
|
|
||||||
|
// Enable modules
|
||||||
|
self::modules($config->modules);
|
||||||
|
|
||||||
if ($hooks = self::list_files('hooks', TRUE))
|
if ($hooks = self::list_files('hooks', TRUE))
|
||||||
{
|
{
|
||||||
foreach ($hooks as $hook)
|
foreach ($hooks as $hook)
|
||||||
|
@ -330,34 +336,44 @@ final class Kohana {
|
||||||
* @param array module paths
|
* @param array module paths
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public static function modules(array $modules)
|
public static function modules(array $modules = NULL)
|
||||||
{
|
{
|
||||||
// Start a new set of include paths, APPPATH first
|
if ($modules === NULL)
|
||||||
$paths = array(APPPATH);
|
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
|
// Get the absolute path to the module
|
||||||
$module = realpath($module);
|
$path = realpath($path);
|
||||||
|
|
||||||
if (Kohana::$is_windows === TRUE)
|
if (Kohana::$is_windows === TRUE)
|
||||||
{
|
{
|
||||||
// Remove backslashes
|
// Remove backslashes
|
||||||
$module = str_replace('\\', '/', $module);
|
$path = str_replace('\\', '/', $path);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add the module to include paths
|
// 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
|
// Finish the include paths by adding SYSPATH
|
||||||
$paths[] = SYSPATH;
|
$include_paths[] = SYSPATH;
|
||||||
|
|
||||||
// Set the new include paths
|
// Set the new include paths
|
||||||
self::$include_paths = $paths;
|
self::$include_paths = $include_paths;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue