-
Notifications
You must be signed in to change notification settings - Fork 908
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
71 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
namespace Backpack\CRUD\app\Library\CrudPanel\Hooks\Contracts; | ||
|
||
use Illuminate\Support\Facades\Facade; | ||
|
||
/** | ||
* @method static void register(string $hook, callable $callback) | ||
* @method static void run(string $hook, array $parameters) | ||
* @method static bool has(string $hook) | ||
* | ||
* @see \Backpack\CRUD\app\Library\CrudPanel\Hooks\PanelHooks | ||
*/ | ||
class PanelHook extends Facade | ||
{ | ||
protected static function getFacadeAccessor() | ||
{ | ||
return 'panel-hook'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
|
||
namespace Backpack\CRUD\app\Library\CrudPanel\Hooks; | ||
|
||
final class PanelHooks | ||
{ | ||
const BEFORE_SETUP_ROUTES = 'beforeSetupRoutes'; | ||
const AFTER_SETUP_ROUTES = 'afterSetupRoutes'; | ||
const BEFORE_SETUP_DEFAULTS = 'beforeSetupDefaults'; | ||
const AFTER_SETUP_DEFAULTS = 'afterSetupDefaults'; | ||
const BEFORE_CONTROLLER_SETUP = 'beforeControllerSetup'; | ||
const AFTER_CONTROLLER_SETUP = 'afterControllerSetup'; | ||
|
||
public array $hooks = []; | ||
|
||
public function register(string $hook, callable $callback): void | ||
{ | ||
$this->hooks[$hook][] = $callback; | ||
} | ||
|
||
public function run(string $hook, array $parameters): void | ||
{ | ||
if (isset($this->hooks[$hook])) { | ||
foreach ($this->hooks[$hook] as $callback) { | ||
$callback(...$parameters); | ||
} | ||
} | ||
} | ||
|
||
public function has(string $hook): bool | ||
{ | ||
return isset($this->hooks[$hook]); | ||
} | ||
} |