mirror of
https://github.com/lucaspalomodevelop/core.git
synced 2026-03-13 08:09:41 +00:00
system: restructure previous a little
This commit is contained in:
parent
2332d8e4a9
commit
3778fee6d1
@ -216,9 +216,15 @@ if (isset($opts['h'])) {
|
||||
} elseif (isset($opts['S'])) {
|
||||
$services = get_all_services(isset($args[0]) ? $args[0] : '', isset($args[1]) ? $args[1] : '');
|
||||
echo json_encode($services, JSON_UNESCAPED_SLASHES|JSON_PRETTY_PRINT) . PHP_EOL;
|
||||
} elseif (!empty($args[0]) && isset($opts['s'])) {
|
||||
} elseif (isset($opts['s'])) {
|
||||
$results = [];
|
||||
$services = get_all_services(isset($args[0]) ? $args[0] : '', isset($args[2]) ? $args[2] : '');
|
||||
foreach ($services as $service) {
|
||||
if (empty($args[0])) {
|
||||
$results[$service['name']] = 1;
|
||||
continue;
|
||||
}
|
||||
|
||||
$filter = isset($service['id']) ? ['id' => $service['id']] : [];
|
||||
$act = isset($args[1]) ? $args[1] : '';
|
||||
$name = $service['name'];
|
||||
@ -244,28 +250,30 @@ if (isset($opts['h'])) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($args[0])) {
|
||||
ksort($results);
|
||||
|
||||
foreach ($results as $key => $value) {
|
||||
echo "$key\n";
|
||||
}
|
||||
}
|
||||
} elseif (empty($args[0])) {
|
||||
// no arguments, list plugins of selected type
|
||||
$results = [];
|
||||
if (isset($opts['s'])) {
|
||||
foreach (plugins_services() as $service) {
|
||||
$results[$service['name']] = 1;
|
||||
foreach (plugins_scan() as $name => $path) {
|
||||
try {
|
||||
include_once $path;
|
||||
} catch (\Error $e) {
|
||||
error_log($e);
|
||||
}
|
||||
} else {
|
||||
foreach (plugins_scan() as $name => $path) {
|
||||
try {
|
||||
include_once $path;
|
||||
} catch (\Error $e) {
|
||||
error_log($e);
|
||||
}
|
||||
$func = sprintf('%s_configure', $name);
|
||||
if (function_exists($func)) {
|
||||
foreach ($func() as $when => $worker) {
|
||||
if (empty($results[$when])) {
|
||||
$results[$when] = [];
|
||||
}
|
||||
$results[$when][] = $name;
|
||||
$func = sprintf('%s_configure', $name);
|
||||
if (function_exists($func)) {
|
||||
foreach ($func() as $when => $worker) {
|
||||
if (empty($results[$when])) {
|
||||
$results[$when] = [];
|
||||
}
|
||||
$results[$when][] = $name;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -273,11 +281,7 @@ if (isset($opts['h'])) {
|
||||
ksort($results);
|
||||
|
||||
foreach ($results as $key => $value) {
|
||||
if (is_array($value)) {
|
||||
echo "$key => " . implode(',', $value) . "\n";
|
||||
} else {
|
||||
echo "$key\n";
|
||||
}
|
||||
echo "$key => " . implode(', ', $value) . "\n";
|
||||
}
|
||||
} else {
|
||||
/* second argument is hook */
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user