Server : LiteSpeed System : Linux server 3.10.0-1160.90.1.el7.x86_64 #1 SMP Thu May 4 15:21:22 UTC 2023 x86_64 User : alsaif ( 1057) PHP Version : 7.4.33 Disable Function : show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname Directory : /home/alsaif/public_html/libraries/fof40/Cli/Traits/ |
<?php
/**
* @package FOF
* @copyright Copyright (c)2010-2022 Nicholas K. Dionysopoulos / Akeeba Ltd
* @license GNU General Public License version 3, or later
*/
namespace FOF40\Cli\Traits;
defined('_JEXEC') || die;
/**
* Allows the CLI application to use the Joomla Global Configuration parameters as its own configuration.
*
* @package FOF40\Cli\Traits
*/
trait JoomlaConfigAware
{
/**
* Method to load the application configuration, returning it as an object or array
*
* This can be overridden in subclasses if you don't want to fetch config from a PHP class file.
*
* @param string|null $file The filepath to the file containing the configuration class. Default: Joomla's
* configuration.php
* @param string $className The name of the PHP class holding the configuration. Default: JConfig
*
* @return mixed Either an array or object to be loaded into the configuration object.
*/
protected function fetchConfigurationData($file = null, $className = 'JConfig')
{
// Set the configuration file name.
if (empty($file))
{
$file = JPATH_BASE . '/configuration.php';
}
// Import the configuration file.
if (!is_file($file))
{
return [];
}
include_once $file;
// Instantiate the configuration object.
if (!class_exists('JConfig'))
{
return [];
}
return new $className();
}
}