-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathHelper.php
94 lines (81 loc) · 2.26 KB
/
Helper.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
<?php
declare(strict_types=1);
namespace XoopsModules\Publisher;
/*
You may not change or alter any portion of this comment or credits
of supporting developers from this source code or any supporting source code
which is considered copyrighted (c) material of the original comment or credit authors.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
/**
* Publisher class
*
* @copyright The XUUPS Project http://sourceforge.net/projects/xuups/
* @license http://www.fsf.org/copyleft/gpl.html GNU public license
* @since 1.0
* @author trabis <lusopoemas@gmail.com>
*/
/**
* Class Helper
*/
/**
* Class Helper
*/
class Helper extends \Xmf\Module\Helper
{
public $debug;
/**
* @param bool $debug
* @internal param $debug
*/
public function __construct($debug = false)
{
$this->debug = $debug;
$moduleDirName = \basename(\dirname(__DIR__));
parent::__construct($moduleDirName);
}
/**
* @param bool $debug
*
* @return \XoopsModules\Publisher\Helper
*/
public static function getInstance(bool $debug = false): Helper
{
static $instance;
if (null === $instance) {
$instance = new static($debug);
}
return $instance;
}
/**
* @return string
*/
public function getDirname()
{
return $this->dirname;
}
/**
* Get an Object Handler
*
* @param string $name name of handler to load
*
* @return bool|\XoopsObjectHandler|\XoopsPersistableObjectHandler
*/
public function getHandler($name)
{
$ret = false;
$class = __NAMESPACE__ . '\\' . $name . 'Handler';
if (!\class_exists($class)) {
throw new \RuntimeException("Class '$class' not found");
}
/** @var \XoopsMySQLDatabase $db */
$db = \XoopsDatabaseFactory::getDatabaseConnection();
$helper = self::getInstance();
$ret = new $class($db, $helper);
$this->addLog("Getting handler '{$name}'");
return $ret;
}
}
//require_once \dirname(__DIR__, 2) . '/mainfile.php';