mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-24 20:17:24 +08:00
finish plugin: sticky promotion
This commit is contained in:
@@ -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();
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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']);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user