1 | <?php |
||
2 | namespace Extend\Core\Arch; |
||
3 | |||
4 | use Ffcms\Core\App; |
||
5 | use Ffcms\Core\Arch\Widget as NativeWidget; |
||
6 | use Apps\ActiveRecord\App as AppRecord; |
||
7 | use Ffcms\Core\Helper\Type\Str; |
||
8 | |||
9 | /** |
||
10 | * Class FrontWidget. Special controller type for front widgets. |
||
11 | * @package Extend\Core\Arch |
||
12 | */ |
||
13 | class FrontWidget extends NativeWidget |
||
14 | { |
||
15 | public static $name; |
||
16 | |||
17 | /** |
||
18 | * Display widget compiled data. |
||
19 | * @param array|null $params |
||
20 | * @return null|string |
||
21 | */ |
||
22 | public static function widget(?array $params = null): ?string |
||
23 | { |
||
24 | if (!self::enabled()) { |
||
25 | return null; |
||
26 | } |
||
27 | |||
28 | // call parent method |
||
29 | return parent::widget($params); |
||
30 | } |
||
31 | |||
32 | /** |
||
33 | * Check if widget is enabled |
||
34 | * @param string|null $class |
||
35 | * @return bool |
||
36 | */ |
||
37 | public static function enabled(?string $class = null): bool |
||
38 | { |
||
39 | self::$class = ($class !== null ? $class : get_called_class()); // get widget classname from passed data or from stacttrace |
||
40 | if (!class_exists(self::$class) && App::$Debug !== null) { |
||
41 | App::$Debug->addMessage(__('Widget autoload is disabled for class: %class%', ['class' => self::$class])); |
||
42 | return false; |
||
43 | } |
||
44 | // get widget name |
||
45 | self::$name = Str::lastIn(self::$class, '\\', true); |
||
46 | |||
47 | $wData = AppRecord::getItem('widget', self::$name); |
||
0 ignored issues
–
show
|
|||
48 | // widget is not founded, deny run |
||
49 | if ($wData === null) { |
||
0 ignored issues
–
show
|
|||
50 | if (App::$Debug !== null) { |
||
51 | App::$Debug->addMessage(__('Widget with name %name%[%class%] is not found', ['name' => self::$name, 'class' => self::$class])); |
||
52 | } |
||
53 | return false; |
||
54 | } |
||
55 | |||
56 | // if widget is disabled - lets return nothing |
||
57 | return !(bool)$wData->disabled; |
||
58 | } |
||
59 | } |
||
60 |
This check looks for function or method calls that always return null and whose return value is assigned to a variable.
The method
getObject()
can return nothing but null, so it makes no sense to assign that value to a variable.The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.