This repository has been archived on 2024-04-08. You can view files and clone it, but cannot push or open issues or pull requests.
phptsmadmin/includes/kohana/system/classes/Kohana/Config/File/Reader.php

57 lines
1.3 KiB
PHP
Raw Normal View History

2012-11-22 03:25:06 +00:00
<?php
2011-01-13 14:49:56 +00:00
/**
* File-based configuration reader. Multiple configuration directories can be
2012-11-22 03:25:06 +00:00
* used by attaching multiple instances of this class to [Kohana_Config].
2011-01-13 14:49:56 +00:00
*
* @package Kohana
* @category Configuration
* @author Kohana Team
2012-11-22 03:25:06 +00:00
* @copyright (c) 2009-2012 Kohana Team
2011-01-13 14:49:56 +00:00
* @license http://kohanaframework.org/license
*/
2012-11-22 03:25:06 +00:00
class Kohana_Config_File_Reader implements Kohana_Config_Reader {
2011-01-13 14:49:56 +00:00
/**
2012-11-22 03:25:06 +00:00
* The directory where config files are located
* @var string
2011-01-13 14:49:56 +00:00
*/
2012-11-22 03:25:06 +00:00
protected $_directory = '';
2011-01-13 14:49:56 +00:00
/**
2012-11-22 03:25:06 +00:00
* Creates a new file reader using the given directory as a config source
*
* @param string $directory Configuration directory to search
2011-01-13 14:49:56 +00:00
*/
public function __construct($directory = 'config')
{
// Set the configuration directory name
$this->_directory = trim($directory, '/');
}
/**
* Load and merge all of the configuration files in this group.
*
* $config->load($name);
*
2012-11-22 03:25:06 +00:00
* @param string $group configuration group name
* @return $this current object
2011-01-13 14:49:56 +00:00
* @uses Kohana::load
*/
2012-11-22 03:25:06 +00:00
public function load($group)
2011-01-13 14:49:56 +00:00
{
2012-11-22 03:25:06 +00:00
$config = array();
2011-01-13 14:49:56 +00:00
if ($files = Kohana::find_file($this->_directory, $group, NULL, TRUE))
{
foreach ($files as $file)
{
// Merge each file to the configuration array
$config = Arr::merge($config, Kohana::load($file));
}
}
2012-11-22 03:25:06 +00:00
return $config;
2011-01-13 14:49:56 +00:00
}
2012-11-22 03:25:06 +00:00
} // End Kohana_Config