|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace Hyde\Foundation\Concerns; |
|
6
|
|
|
|
|
7
|
|
|
use Hyde\Foundation\HydeKernel; |
|
8
|
|
|
use Hyde\Foundation\Kernel\FileCollection; |
|
9
|
|
|
use Hyde\Foundation\Kernel\PageCollection; |
|
10
|
|
|
use Hyde\Foundation\Kernel\RouteCollection; |
|
11
|
|
|
|
|
12
|
|
|
/** |
|
13
|
|
|
* When creating a HydePHP extension, you should create a class that extends this one. |
|
14
|
|
|
* |
|
15
|
|
|
* After registering your implementation with the HydeKernel (usually in a service provider), |
|
16
|
|
|
* Hyde will be able to use the information within to integrate your plugin, and to allow you to |
|
17
|
|
|
* hook into various parts of the internal application lifecycle, and through that, all aspects of Hyde. |
|
18
|
|
|
* |
|
19
|
|
|
* Before creating your extension, it will certainly be helpful if you first become familiar |
|
20
|
|
|
* with the basic internal architecture of HydePHP, as well as how the auto-discovery system functions. |
|
21
|
|
|
* |
|
22
|
|
|
* @link https://hydephp.com/docs/1.x/core-concepts |
|
23
|
|
|
* |
|
24
|
|
|
* It's important that your class is registered before the HydeKernel boots. |
|
25
|
|
|
* An excellent place for this is the 'register' method of your extensions service provider, |
|
26
|
|
|
* where you call the 'registerExtension' method of the HydeKernel singleton instance, |
|
27
|
|
|
* which you can access via the Hyde\Hyde facade, or via the service container. |
|
28
|
|
|
* |
|
29
|
|
|
* @example `$this->app->make(HydeKernel::class)->registerExtension(MyExtension::class);` |
|
30
|
|
|
*/ |
|
31
|
|
|
abstract class HydeExtension |
|
32
|
|
|
{ |
|
33
|
|
|
/** |
|
34
|
|
|
* If your extension adds new discoverable page classes, you should register them here. |
|
35
|
|
|
* |
|
36
|
|
|
* Hyde will then automatically discover source files for the new page class, |
|
37
|
|
|
* generate routes, and compile the pages during the build process. |
|
38
|
|
|
* |
|
39
|
|
|
* If your page classes require more complex logic to discover their source files, |
|
40
|
|
|
* use the discovery handler methods found below for full process control. |
|
41
|
|
|
* |
|
42
|
|
|
* @return array<class-string<\Hyde\Pages\Concerns\HydePage>> |
|
|
|
|
|
|
43
|
|
|
*/ |
|
44
|
|
|
public static function getPageClasses(): array |
|
45
|
|
|
{ |
|
46
|
|
|
return []; |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
/** |
|
50
|
|
|
* If your extension needs to hook into the file discovery process, |
|
51
|
|
|
* you can configure the following handler method. It will be called |
|
52
|
|
|
* at the end of the file discovery process. The collection instance |
|
53
|
|
|
* will be injected, so that you can interact with it directly. |
|
54
|
|
|
*/ |
|
55
|
|
|
public function discoverFiles(FileCollection $collection): void |
|
|
|
|
|
|
56
|
|
|
{ |
|
57
|
|
|
// |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
/** |
|
61
|
|
|
* If your extension needs to hook into the page discovery process, |
|
62
|
|
|
* you can configure the following handler method. It will be called |
|
63
|
|
|
* at the end of the page discovery process. The collection instance |
|
64
|
|
|
* will be injected, so that you can interact with it directly. |
|
65
|
|
|
*/ |
|
66
|
|
|
public function discoverPages(PageCollection $collection): void |
|
|
|
|
|
|
67
|
|
|
{ |
|
68
|
|
|
// |
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
|
|
/** |
|
72
|
|
|
* If your extension needs to hook into the route discovery process, |
|
73
|
|
|
* you can configure the following handler method. It will be called |
|
74
|
|
|
* at the end of the route discovery process. The collection instance |
|
75
|
|
|
* will be injected, so that you can interact with it directly. |
|
76
|
|
|
*/ |
|
77
|
|
|
public function discoverRoutes(RouteCollection $collection): void |
|
|
|
|
|
|
78
|
|
|
{ |
|
79
|
|
|
// |
|
80
|
|
|
} |
|
81
|
|
|
|
|
82
|
|
|
/** |
|
83
|
|
|
* Register a callback to be run before the kernel is booted, |
|
84
|
|
|
* which is before any file/page/route discovery has begun. |
|
85
|
|
|
*/ |
|
86
|
|
|
public function booting(HydeKernel $kernel): void |
|
|
|
|
|
|
87
|
|
|
{ |
|
88
|
|
|
// |
|
89
|
|
|
} |
|
90
|
|
|
|
|
91
|
|
|
/** |
|
92
|
|
|
* Register a callback to be run after the kernel is booted, |
|
93
|
|
|
* which is after file/page/route discovery has completed. |
|
94
|
|
|
*/ |
|
95
|
|
|
public function booted(HydeKernel $kernel): void |
|
|
|
|
|
|
96
|
|
|
{ |
|
97
|
|
|
// |
|
98
|
|
|
} |
|
99
|
|
|
} |
|
100
|
|
|
|