Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
4 / 4 |
|
100.00% |
4 / 4 |
CRAP | |
100.00% |
1 / 1 |
| HydeExtension | |
100.00% |
4 / 4 |
|
100.00% |
4 / 4 |
4 | |
100.00% |
1 / 1 |
| getPageClasses | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| discoverFiles | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| discoverPages | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| discoverRoutes | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace Hyde\Foundation\Concerns; |
| 6 | |
| 7 | use Hyde\Foundation\Kernel\FileCollection; |
| 8 | use Hyde\Foundation\Kernel\PageCollection; |
| 9 | use Hyde\Foundation\Kernel\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/1.x/core-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 `$this->app->make(HydeKernel::class)->registerExtension(MyExtension::class);` |
| 29 | */ |
| 30 | abstract class HydeExtension |
| 31 | { |
| 32 | /** |
| 33 | * If your extension adds new discoverable page classes, you should register them here. |
| 34 | * |
| 35 | * Hyde will then automatically discover source files for the new page class, |
| 36 | * generate routes, and compile the pages during the build process. |
| 37 | * |
| 38 | * If your page classes require more complex logic to discover their source files, |
| 39 | * use the discovery handler methods found below for full process control. |
| 40 | * |
| 41 | * @return array<class-string<\Hyde\Pages\Concerns\HydePage>> |
| 42 | */ |
| 43 | public static function getPageClasses(): array |
| 44 | { |
| 45 | return []; |
| 46 | } |
| 47 | |
| 48 | /** |
| 49 | * If your extension needs to hook into the file discovery process, |
| 50 | * you can configure the following handler method. It will be called |
| 51 | * at the end of the file discovery process. The collection instance |
| 52 | * will be injected, so that you can interact with it directly. |
| 53 | */ |
| 54 | public function discoverFiles(FileCollection $collection): void |
| 55 | { |
| 56 | // |
| 57 | } |
| 58 | |
| 59 | /** |
| 60 | * If your extension needs to hook into the page discovery process, |
| 61 | * you can configure the following handler method. It will be called |
| 62 | * at the end of the page discovery process. The collection instance |
| 63 | * will be injected, so that you can interact with it directly. |
| 64 | */ |
| 65 | public function discoverPages(PageCollection $collection): void |
| 66 | { |
| 67 | // |
| 68 | } |
| 69 | |
| 70 | /** |
| 71 | * If your extension needs to hook into the route discovery process, |
| 72 | * you can configure the following handler method. It will be called |
| 73 | * at the end of the route discovery process. The collection instance |
| 74 | * will be injected, so that you can interact with it directly. |
| 75 | */ |
| 76 | public function discoverRoutes(RouteCollection $collection): void |
| 77 | { |
| 78 | // |
| 79 | } |
| 80 | } |