1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace XoopsModules\Rssfit; |
6
|
|
|
|
7
|
|
|
/* |
8
|
|
|
* You may not change or alter any portion of this comment or credits |
9
|
|
|
* of supporting developers from this source code or any supporting source code |
10
|
|
|
* which is considered copyrighted (c) material of the original comment or credit authors. |
11
|
|
|
* |
12
|
|
|
* This program is distributed in the hope that it will be useful, |
13
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
14
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
15
|
|
|
*/ |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* @copyright XOOPS Project (https://xoops.org) |
19
|
|
|
* @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html) |
20
|
|
|
* @author XOOPS Development Team |
21
|
|
|
*/ |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* Class Helper |
25
|
|
|
*/ |
26
|
|
|
class Helper extends \Xmf\Module\Helper |
27
|
|
|
{ |
28
|
|
|
public $debug; |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* @param bool $debug |
32
|
|
|
*/ |
33
|
|
|
public function __construct($debug = false) |
34
|
|
|
{ |
35
|
|
|
$this->debug = $debug; |
36
|
|
|
if (null === $this->dirname) { |
37
|
|
|
$dirname = \basename(\dirname(__DIR__)); |
38
|
|
|
$this->dirname = $dirname; |
39
|
|
|
} |
40
|
|
|
parent::__construct($this->dirname); |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
public static function getInstance(bool $debug = false): Helper |
44
|
|
|
{ |
45
|
|
|
static $instance; |
46
|
|
|
if (null === $instance) { |
47
|
|
|
$instance = new static($debug); |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
return $instance; |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
public function getDirname(): string |
54
|
|
|
{ |
55
|
|
|
return $this->dirname; |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* Get an Object Handler |
60
|
|
|
* |
61
|
|
|
* @param string $name name of handler to load |
62
|
|
|
* |
63
|
|
|
* @return \XoopsPersistableObjectHandler |
64
|
|
|
*/ |
65
|
|
|
public function getHandler($name): ?\XoopsPersistableObjectHandler |
66
|
|
|
{ |
67
|
|
|
$ret = null; |
|
|
|
|
68
|
|
|
|
69
|
|
|
$class = __NAMESPACE__ . '\\' . \ucfirst($name) . 'Handler'; |
70
|
|
|
if (!\class_exists($class)) { |
71
|
|
|
throw new \RuntimeException("Class '$class' not found"); |
72
|
|
|
} |
73
|
|
|
/** @var \XoopsMySQLDatabase $db */ |
74
|
|
|
$db = \XoopsDatabaseFactory::getDatabaseConnection(); |
75
|
|
|
$helper = self::getInstance(); |
76
|
|
|
$ret = new $class($db, $helper); |
77
|
|
|
$this->addLog("Getting handler '$name'"); |
78
|
|
|
return $ret; |
79
|
|
|
} |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
|