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