1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Godbout\Alfred\Workflow; |
4
|
|
|
|
5
|
|
|
use Godbout\Alfred\Workflow\Contracts\Workflow; |
6
|
|
|
use ReflectionClass; |
7
|
|
|
|
8
|
|
|
abstract class BaseWorkflow implements Workflow |
9
|
|
|
{ |
10
|
|
|
private static $instance = null; |
11
|
|
|
private $scriptFilter = null; |
12
|
|
|
|
13
|
|
|
|
14
|
|
|
final protected function __construct() |
15
|
|
|
{ |
16
|
|
|
$this->scriptFilter = ScriptFilter::create(); |
|
|
|
|
17
|
|
|
} |
18
|
|
|
|
19
|
|
|
final public static function getInstance() |
20
|
|
|
{ |
21
|
|
|
if (is_null(self::$instance)) { |
22
|
|
|
self::$instance = new static; |
23
|
|
|
} |
24
|
|
|
|
25
|
|
|
return self::$instance; |
26
|
|
|
} |
27
|
|
|
|
28
|
|
|
public static function currentMenu() |
29
|
|
|
{ |
30
|
|
|
static::getCurrentMenuClass()::scriptFilter(); |
31
|
|
|
|
32
|
|
|
return static::getInstance()->scriptFilter->output(); |
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
private static function getCurrentMenuClass() |
36
|
|
|
{ |
37
|
|
|
$args = explode('_', getenv('action')); |
|
|
|
|
38
|
|
|
|
39
|
|
|
return (new ReflectionClass(static::class))->getNamespaceName() . "\\Menus\\" . (static::getMenuClassName(getenv('action')) ?: 'Entrance'); |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
private static function getMenuClassName($action) |
43
|
|
|
{ |
44
|
|
|
return str_replace('_', '', ucwords($action === false ? 'entrance' : $action, '_')); |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
final public static function destroy() |
48
|
|
|
{ |
49
|
|
|
ScriptFilter::destroy(); |
50
|
|
|
|
51
|
|
|
self::$instance = null; |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
final private function __clone() |
55
|
|
|
{ |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
public static function do() |
59
|
|
|
{ |
60
|
|
|
$action = getenv('workflow_action'); |
61
|
|
|
|
62
|
|
|
if (method_exists(static::class, $action)) { |
63
|
|
|
return static::$action(); |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
return false; |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
public static function notify($result = false) |
70
|
|
|
{ |
71
|
|
|
$action = getenv('workflow_action'); |
72
|
|
|
|
73
|
|
|
if ($result === false) { |
74
|
|
|
return "Oops... cannot $action."; |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
return "$action is done!"; |
78
|
|
|
} |
79
|
|
|
} |
80
|
|
|
|
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