Configurator
Configurator class pulls various configuration of the module into one central location.
/**
* Class Configurator
*/
class Configurator
{
public $name;
public $paths = [];
public $uploadFolders = [];
public $copyBlankFiles = [];
public $copyTestFolders = [];
public $templateFolders = [];
public $oldFiles = [];
public $oldFolders = [];
public $renameTables = [];
public $moduleStats = [];
public $modCopyright;
public $icons;
/**
* Configurator constructor.
*/
public function __construct()
{
$config = include dirname(dirname(__DIR__)) . '/config/config.php';
$this->name = $config->name;
$this->paths = $config->paths;
$this->uploadFolders = $config->uploadFolders;
$this->copyBlankFiles = $config->copyBlankFiles;
$this->copyTestFolders = $config->copyTestFolders;
$this->templateFolders = $config->templateFolders;
$this->oldFiles = $config->oldFiles;
$this->oldFolders = $config->oldFolders;
$this->renameTables = $config->renameTables;
$this->moduleStats = $config->moduleStats;
$this->modCopyright = $config->modCopyright;
$this->icons = include dirname(dirname(__DIR__)) . '/config/icons.php';
$this->paths = include dirname(dirname(__DIR__)) . '/config/paths.php';
}
}
A typical config.php file:
use Xmf\Module\Admin;
$moduleDirName = basename(dirname(__DIR__));
return (object)[
'name' => mb_strtoupper($moduleDirName) . ' ModuleConfigurator',
'paths' => [
'dirname' => $moduleDirName,
'admin' => XOOPS_ROOT_PATH . '/modules/' . $moduleDirName . '/admin',
'modPath' => XOOPS_ROOT_PATH . '/modules/' . $moduleDirName,
'modUrl' => XOOPS_URL . '/modules/' . $moduleDirName,
'uploadPath' => XOOPS_UPLOAD_PATH . '/' . $moduleDirName,
'uploadUrl' => XOOPS_UPLOAD_URL . '/' . $moduleDirName,
],
'uploadFolders' => [
XOOPS_UPLOAD_PATH . '/' . $moduleDirName,
XOOPS_UPLOAD_PATH . '/' . $moduleDirName . '/category',
XOOPS_UPLOAD_PATH . '/' . $moduleDirName . '/screenshots',
//XOOPS_UPLOAD_PATH . '/flags'
],
'copyBlankFiles' => [
XOOPS_UPLOAD_PATH . '/' . $moduleDirName,
XOOPS_UPLOAD_PATH . '/' . $moduleDirName . '/category',
XOOPS_UPLOAD_PATH . '/' . $moduleDirName . '/screenshots',
//XOOPS_UPLOAD_PATH . '/flags'
],
'copyTestFolders' => [
[
XOOPS_ROOT_PATH . '/modules/' . $moduleDirName . '/testdata/uploads',
XOOPS_UPLOAD_PATH . '/' . $moduleDirName,
],
],
'templateFolders' => [
'/templates/',
// '/templates/blocks/',
// '/templates/admin/'
],
//old files to be deleted during module update
'oldFiles' => [
'/class/request.php',
'/class/registry.php',
'/class/utilities.php',
'/class/util.php',
// '/include/constants.php',
// '/include/functions.php',
'/ajaxrating.txt',
],
//old folders to be deleted during module update
'oldFolders' => [
'/images',
'/css',
'/js',
'/tcpdf',
],
// list all tables that should be renamed during module update
'renameTables' => [
// 'XX_archive' => 'ZZZZ_archive',
],
// module stats to be calculated
'moduleStats' => [
// 'totalcategories' => $helper->getHandler('Category')->getCategoriesCount(-1),
// 'totalitems' => $helper->getHandler('Item')->getItemsCount(),
// 'totalsubmitted' => $helper->getHandler('Item')->getItemsCount(-1, [Constants::PUBLISHER_STATUS_SUBMITTED]),
],
'modCopyright' => "<a href='https://xoops.org' title='XOOPS Project' target='_blank'>
<img src='" . Admin::iconUrl('xoopsmicrobutton.gif') . "' alt='XOOPS Project'></a>",
];
Last updated