|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Ffcms\Core\Arch; |
|
4
|
|
|
|
|
5
|
|
|
use Apps\ActiveRecord\App as AppRecord; |
|
|
|
|
|
|
6
|
|
|
use Ffcms\Core\App; |
|
7
|
|
|
use Ffcms\Core\Helper\Type\Any; |
|
8
|
|
|
use Ffcms\Core\Helper\Type\Str; |
|
9
|
|
|
use Ffcms\Core\Interfaces\iWidget; |
|
10
|
|
|
|
|
11
|
|
|
/** |
|
12
|
|
|
* Class Widget. Provide constructor to work with widget-type based extensions for ffcms. |
|
13
|
|
|
* @package Ffcms\Core\Arch |
|
14
|
|
|
*/ |
|
15
|
|
|
class Widget implements iWidget |
|
16
|
|
|
{ |
|
17
|
|
|
/** @var string|null */ |
|
18
|
|
|
public static $class; |
|
19
|
|
|
|
|
20
|
|
|
public static $view; |
|
21
|
|
|
public static $request; |
|
22
|
|
|
public static $response; |
|
23
|
|
|
|
|
24
|
|
|
/** |
|
25
|
|
|
* Build and display widget |
|
26
|
|
|
* @param array|null $params |
|
27
|
|
|
* @return null|string |
|
28
|
|
|
*/ |
|
29
|
|
|
public static function widget(?array $params = null): ?string |
|
|
|
|
|
|
30
|
|
|
{ |
|
31
|
|
|
self::$class = get_called_class(); |
|
32
|
|
|
self::$view = App::$View; |
|
33
|
|
|
self::$request = App::$Request; |
|
34
|
|
|
self::$response = App::$Response; |
|
35
|
|
|
|
|
36
|
|
|
// check if class exist |
|
37
|
|
|
if (!class_exists(self::$class)) { |
|
38
|
|
|
return 'Error: Widget is not founded: ' . self::$class; |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
/** @var iWidget $object */ |
|
42
|
|
|
$object = new self::$class; |
|
43
|
|
|
if (Any::isArray($params) && count($params) > 0) { |
|
44
|
|
|
foreach ($params as $property => $value) { |
|
45
|
|
|
if (property_exists($object, $property)) { |
|
46
|
|
|
$object->{$property} = $value; |
|
47
|
|
|
} |
|
48
|
|
|
} |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
// initialize widget |
|
52
|
|
|
$object->init(); |
|
53
|
|
|
return $object->display(); |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
/** |
|
57
|
|
|
* Get widget configs from admin part as array $cfg=>$value |
|
58
|
|
|
* @return array|null |
|
59
|
|
|
*/ |
|
60
|
|
|
public function getConfigs(): ?array |
|
61
|
|
|
{ |
|
62
|
|
|
$realName = Str::lastIn(self::$class, '\\', true); |
|
63
|
|
|
return AppRecord::getConfigs('widget', $realName); |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
public function display(): ?string |
|
67
|
|
|
{ |
|
68
|
|
|
} |
|
69
|
|
|
|
|
70
|
|
|
public function init(): void |
|
71
|
|
|
{ |
|
72
|
|
|
} |
|
73
|
|
|
|
|
74
|
|
|
/** |
|
75
|
|
|
* Check if widget is enabled. For native widget is always enabled |
|
76
|
|
|
* @param string|null $name |
|
77
|
|
|
* @return bool |
|
78
|
|
|
*/ |
|
79
|
|
|
public static function enabled(?string $name = null): bool |
|
|
|
|
|
|
80
|
|
|
{ |
|
81
|
|
|
return true; |
|
82
|
|
|
} |
|
83
|
|
|
} |
|
84
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths