finish plugin: sticky promotion

This commit is contained in:
xiaomlove
2022-06-08 14:15:59 +08:00
parent 44c750234a
commit 09f6e5b274
62 changed files with 954 additions and 178 deletions
+2 -1
View File
@@ -1,10 +1,11 @@
<?php
namespace Nexus\Plugin;
use App\Repositories\BaseRepository;
use Illuminate\Support\Arr;
use Illuminate\Support\Facades\Artisan;
abstract class BasePlugin
abstract class BasePlugin extends BaseRepository
{
abstract function install();
+2 -2
View File
@@ -37,11 +37,11 @@ class Hook
{
if (!isset(self::$callbacks[$name])) {
do_log("No this hook: $name");
return null;
return $value;
}
$args = func_get_args();
reset(self::$callbacks[$name]);
do_log("name: $name, args: " . json_encode($args));
do_log("name: $name, argc: " . (func_num_args() - 1));
do {
foreach ((array)current(self::$callbacks[$name]) as $callback) {
$args[1] = $value;
+3 -5
View File
@@ -8,9 +8,7 @@ class Plugin
public function __construct()
{
$this->loadProviders();
if (!isRunningInConsole()) {
$this->bootPlugins();
}
$this->bootPlugins();
}
public function enabled($name): bool
@@ -22,7 +20,7 @@ class Plugin
{
if (isset(self::$providers[$name]['providers'][0])) {
$className = self::$providers[$name]['providers'][0];
$className = str_replace('ServiceProvider', '', $className);
$className = str_replace('ServiceProvider', 'Repository', $className);
if (class_exists($className)) {
return new $className;
}
@@ -35,7 +33,7 @@ class Plugin
$provider = $providers['providers'][0];
$parts = explode('\\', $provider);
if ($parts[0] == 'NexusPlugin') {
$className = str_replace('ServiceProvider', '', $provider);
$className = str_replace('ServiceProvider', 'Repository', $provider);
call_user_func([new $className, 'boot']);
}
}