- md5
- fda279c78b0eb4ca38f1066d5e817688
- sha1
- a61e73630c927b62535d131d578981fb1366fb5f
- sha256
- 39d33ebaa132ec6b2ce9fcf0347abcf86f954eac5c0428880fb5c007ef2aa949
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
<?php
/**
* Joomla! Content Management System
*
* @copyright Copyright (C) 2005 - 2016 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
namespace Joomla\CMS\Application;
defined('JPATH_PLATFORM') or die;
use Joomla\Registry\Registry;
/**
* Trait for application classes which can automatically retrieve the global configuration
*
* @since 4.0
*/
trait Autoconfigurable
{
/**
* Method to load a PHP configuration class file based on convention and return the instantiated data object.
*
* @param string $file The path and filename of the configuration file. If not provided, configuration.php
* in JPATH_CONFIGURATION will be used.
* @param string $class The class name to instantiate.
*
* @return mixed Either an array or object to be loaded into the configuration object.
*
* @since 4.0
* @throws \RuntimeException
*/
protected function fetchConfigurationData($file = '', $class = 'JConfig')
{
// Instantiate variables.
$config = [];
if (empty($file))
{
$file = JPATH_CONFIGURATION . '/configuration.php';
// Applications can choose not to have any configuration data by not implementing this method and not having a config file.
if (!file_exists($file))
{
$file = '';
}
}
if (!empty($file))
{
\JLoader::register($class, $file);
if (!class_exists($class))
{
throw new \RuntimeException('Configuration class does not exist.');
}
$config = new $class;
}
return $config;
}
/**
* Retrieve the application configuration object.
*
* @return Registry
*
* @since 4.0
*/
public function getConfig()
{
return $this->config;
}
/**
* Load an object or array into the application configuration object.
*
* @param mixed $data Either an array or object to be loaded into the configuration object.
*
* @return $this
*
* @since 4.0
*/
public function loadConfiguration($data)
{
// Load the data into the configuration object.
if (is_array($data))
{
$this->getConfig()->loadArray($data);
}
elseif (is_object($data))
{
$this->getConfig()->loadObject($data);
}
return $this;
}
}
No other release has this exact content. See every version of this file.