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.
khosb/includes/kohana/system/classes/Kohana/Config/File/Reader.php

57 lines
1.3 KiB
PHP
Raw Normal View History

2012-11-09 12:18:50 +00:00
<?php
2010-08-21 04:43:03 +00:00
/**
* File-based configuration reader. Multiple configuration directories can be
2012-11-09 12:18:50 +00:00
* used by attaching multiple instances of this class to [Kohana_Config].
2010-08-21 04:43:03 +00:00
*
* @package Kohana
* @category Configuration
* @author Kohana Team
2012-11-09 12:18:50 +00:00
* @copyright (c) 2009-2012 Kohana Team
2011-05-13 06:00:25 +00:00
* @license http://kohanaframework.org/license
2010-08-21 04:43:03 +00:00
*/
2012-11-09 12:18:50 +00:00
class Kohana_Config_File_Reader implements Kohana_Config_Reader {
2010-08-21 04:43:03 +00:00
2011-05-13 06:00:25 +00:00
/**
2012-11-09 12:18:50 +00:00
* The directory where config files are located
* @var string
2011-05-13 06:00:25 +00:00
*/
2012-11-09 12:18:50 +00:00
protected $_directory = '';
2010-08-21 04:43:03 +00:00
2011-05-13 06:00:25 +00:00
/**
2012-11-09 12:18:50 +00:00
* Creates a new file reader using the given directory as a config source
*
* @param string $directory Configuration directory to search
2011-05-13 06:00:25 +00:00
*/
2010-08-21 04:43:03 +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-09 12:18:50 +00:00
* @param string $group configuration group name
* @return $this current object
2010-08-21 04:43:03 +00:00
* @uses Kohana::load
*/
2012-11-09 12:18:50 +00:00
public function load($group)
2010-08-21 04:43:03 +00:00
{
2012-11-09 12:18:50 +00:00
$config = array();
2010-08-21 04:43:03 +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-09 12:18:50 +00:00
return $config;
2010-08-21 04:43:03 +00:00
}
2012-11-09 12:18:50 +00:00
} // End Kohana_Config