From 9e6a3ab12e99d3f6ec73493994530e449884593b Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Sat, 14 May 2022 18:07:23 +0200 Subject: [PATCH 01/22] Create the Core files --- src/Core/HydeManager.php | 8 ++++++++ src/Core/HydeManagerContract.php | 20 ++++++++++++++++++++ src/HydeServiceProvider.php | 6 ++++++ 3 files changed, 34 insertions(+) create mode 100644 src/Core/HydeManager.php create mode 100644 src/Core/HydeManagerContract.php diff --git a/src/Core/HydeManager.php b/src/Core/HydeManager.php new file mode 100644 index 00000000..9eca1496 --- /dev/null +++ b/src/Core/HydeManager.php @@ -0,0 +1,8 @@ +app->singleton(HydeManagerContract::class, function ($app) { + return new HydeManager(); + }); + $this->commands([ Commands\HydePublishHomepageCommand::class, Commands\HydeUpdateConfigsCommand::class, From 39406f687078d0e228472155381ba4cca6c49744 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Sat, 14 May 2022 18:19:09 +0200 Subject: [PATCH 02/22] Define the first service contract --- src/Core/HydeManager.php | 5 +++- src/Core/HydeManagerContract.php | 6 ++++- src/Core/SourceLocationManager.php | 35 ++++++++++++++++++++++++++ src/Core/SourceLocationProvider.php | 39 +++++++++++++++++++++++++++++ 4 files changed, 83 insertions(+), 2 deletions(-) create mode 100644 src/Core/SourceLocationManager.php create mode 100644 src/Core/SourceLocationProvider.php diff --git a/src/Core/HydeManager.php b/src/Core/HydeManager.php index 9eca1496..95d85fd0 100644 --- a/src/Core/HydeManager.php +++ b/src/Core/HydeManager.php @@ -4,5 +4,8 @@ class HydeManager implements HydeManagerContract { - // + public function getSourceLocationManager(): string + { + return SourceLocationProvider::class; + } } \ No newline at end of file diff --git a/src/Core/HydeManagerContract.php b/src/Core/HydeManagerContract.php index 64d3ffc8..9c684a9c 100644 --- a/src/Core/HydeManagerContract.php +++ b/src/Core/HydeManagerContract.php @@ -16,5 +16,9 @@ */ interface HydeManagerContract { - // + /** + * Get the fully qualified class name of the SourceLocationManager implementation. + * @see \Hyde\Framework\Core\SourceLocationManager + */ + public function getSourceLocationManager(): string; } \ No newline at end of file diff --git a/src/Core/SourceLocationManager.php b/src/Core/SourceLocationManager.php new file mode 100644 index 00000000..2d909746 --- /dev/null +++ b/src/Core/SourceLocationManager.php @@ -0,0 +1,35 @@ + Date: Sat, 14 May 2022 18:26:07 +0200 Subject: [PATCH 03/22] Add the bootstrap method --- src/Core/HydeManager.php | 19 +++++++++++++++++++ src/Core/HydeManagerContract.php | 5 +++++ 2 files changed, 24 insertions(+) diff --git a/src/Core/HydeManager.php b/src/Core/HydeManager.php index 95d85fd0..2d8930f2 100644 --- a/src/Core/HydeManager.php +++ b/src/Core/HydeManager.php @@ -2,8 +2,27 @@ namespace Hyde\Framework\Core; +/** + * The HydeManager bootstraps the Hyde Framework Core Services. + * + * To extend implementations, create a class that extends this class, + * and register it as the Singleton implementation of the Contract in a + * ServiceProvider extending the HydeServiceProvider and load it in app.php. + */ class HydeManager implements HydeManagerContract { + protected SourceLocationManager $sourceLocationManager; + + public function __construct() + { + $this->bootstrap(); + } + + public function bootstrap(): void + { + $this->sourceLocationManager = new ($this->getSourceLocationManager()); + } + public function getSourceLocationManager(): string { return SourceLocationProvider::class; diff --git a/src/Core/HydeManagerContract.php b/src/Core/HydeManagerContract.php index 9c684a9c..264b574a 100644 --- a/src/Core/HydeManagerContract.php +++ b/src/Core/HydeManagerContract.php @@ -16,6 +16,11 @@ */ interface HydeManagerContract { + /** + * Load all the core service implementations into the HydeManager. + */ + public function bootstrap(): void; + /** * Get the fully qualified class name of the SourceLocationManager implementation. * @see \Hyde\Framework\Core\SourceLocationManager From d9c3af867df065030241fa0ecda6c986b6312c5d Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Sat, 14 May 2022 18:27:21 +0200 Subject: [PATCH 04/22] Add PHPDoc --- src/HydeServiceProvider.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/HydeServiceProvider.php b/src/HydeServiceProvider.php index 4d9f155a..8afcba25 100644 --- a/src/HydeServiceProvider.php +++ b/src/HydeServiceProvider.php @@ -34,6 +34,10 @@ function () { } ); + /** + * Register the HydeManager implementation class. + * Swap this out if you want to override the services. + */ $this->app->singleton(HydeManagerContract::class, function ($app) { return new HydeManager(); }); From 56a77fda4de62d0b13543c2a149a99b724565920 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Sat, 14 May 2022 18:42:42 +0200 Subject: [PATCH 05/22] Create the system manager --- src/Core/HydeSystemManager.php | 12 ++++++++++++ src/Core/HydeSystemProvider.php | 14 ++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 src/Core/HydeSystemManager.php create mode 100644 src/Core/HydeSystemProvider.php diff --git a/src/Core/HydeSystemManager.php b/src/Core/HydeSystemManager.php new file mode 100644 index 00000000..10b51669 --- /dev/null +++ b/src/Core/HydeSystemManager.php @@ -0,0 +1,12 @@ + Date: Sat, 14 May 2022 18:43:05 +0200 Subject: [PATCH 06/22] Implement the system manager --- src/Concerns/Internal/FileHelpers.php | 22 ++++++++++++++++++++-- src/Core/HydeManager.php | 12 ++++++++++++ src/Core/HydeManagerContract.php | 11 +++++++++++ 3 files changed, 43 insertions(+), 2 deletions(-) diff --git a/src/Concerns/Internal/FileHelpers.php b/src/Concerns/Internal/FileHelpers.php index 0138ba0b..faa85a06 100644 --- a/src/Concerns/Internal/FileHelpers.php +++ b/src/Concerns/Internal/FileHelpers.php @@ -2,6 +2,8 @@ namespace Hyde\Framework\Concerns\Internal; +use Hyde\Framework\Core\HydeManagerContract; + /** * Offloads file helper methods for the Hyde Facade. * @@ -51,12 +53,28 @@ public static function docsIndexPath(): string|false public static function path(string $path = ''): string { if (empty($path)) { - return getcwd(); + return static::getProjectRoot(); } $path = trim($path, '/\\'); - return getcwd().DIRECTORY_SEPARATOR.$path; + return static::getProjectRoot().DIRECTORY_SEPARATOR.$path; + } + + /** + * Get the path to the Hyde root directory. + * Catches binding resolution errors allowing the function to + * be used in PHPUnit tests before the application is booted. + * + * @return string + */ + public static function getProjectRoot(): string + { + try { + return app(HydeManagerContract::class)->hydeSystemManager()->getProjectRoot(); + } catch (\Illuminate\Contracts\Container\BindingResolutionException) { + return getcwd(); + } } /** diff --git a/src/Core/HydeManager.php b/src/Core/HydeManager.php index 2d8930f2..681a633b 100644 --- a/src/Core/HydeManager.php +++ b/src/Core/HydeManager.php @@ -11,6 +11,7 @@ */ class HydeManager implements HydeManagerContract { + protected HydeSystemManager $hydeSystemManager; protected SourceLocationManager $sourceLocationManager; public function __construct() @@ -20,11 +21,22 @@ public function __construct() public function bootstrap(): void { + $this->hydeSystemManager = new ($this->getHydeSystemManager()); $this->sourceLocationManager = new ($this->getSourceLocationManager()); } + public function getHydeSystemManager(): string + { + return HydeSystemProvider::class; + } + public function getSourceLocationManager(): string { return SourceLocationProvider::class; } + + public function hydeSystemManager(): HydeSystemManager + { + return $this->hydeSystemManager; + } } \ No newline at end of file diff --git a/src/Core/HydeManagerContract.php b/src/Core/HydeManagerContract.php index 264b574a..b71846c5 100644 --- a/src/Core/HydeManagerContract.php +++ b/src/Core/HydeManagerContract.php @@ -21,6 +21,17 @@ interface HydeManagerContract */ public function bootstrap(): void; + /** + * Get the fully qualified class name of the HydeSystemManager implementation. + * @see \Hyde\Framework\Core\HydeSystemManager + */ + public function getHydeSystemManager(): string; + + /** + * Get the instantiated HydeSystemManager implementation. + */ + public function hydeSystemManager(): HydeSystemManager; + /** * Get the fully qualified class name of the SourceLocationManager implementation. * @see \Hyde\Framework\Core\SourceLocationManager From 8fe22c8cf62960ade2a152fbfa79a7aa223b4af2 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Sat, 14 May 2022 18:47:14 +0200 Subject: [PATCH 07/22] Restructure PHPDocs to remove redundancy --- src/Core/HydeManagerContract.php | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/Core/HydeManagerContract.php b/src/Core/HydeManagerContract.php index b71846c5..9263043e 100644 --- a/src/Core/HydeManagerContract.php +++ b/src/Core/HydeManagerContract.php @@ -22,19 +22,23 @@ interface HydeManagerContract public function bootstrap(): void; /** - * Get the fully qualified class name of the HydeSystemManager implementation. - * @see \Hyde\Framework\Core\HydeSystemManager + * ========================================================================= + * Get the fully qualified class name of the manager implementation to use. + * + * Default return syntax: \Hyde\Framework\Core\ServiceManager::class + * ========================================================================= */ + public function getHydeSystemManager(): string; - /** - * Get the instantiated HydeSystemManager implementation. - */ - public function hydeSystemManager(): HydeSystemManager; + public function getSourceLocationManager(): string; + /** - * Get the fully qualified class name of the SourceLocationManager implementation. - * @see \Hyde\Framework\Core\SourceLocationManager + * ========================================================================= + * Get the manager implementation instantiated in the bootstrap process. + * ========================================================================= */ - public function getSourceLocationManager(): string; + + public function hydeSystemManager(): HydeSystemManager; } \ No newline at end of file From 7dea469532bf25d86da38c4098e00cc74537c5fc Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Sat, 14 May 2022 18:47:53 +0200 Subject: [PATCH 08/22] Add the sourceLocationManager getter --- src/Core/HydeManager.php | 5 +++++ src/Core/HydeManagerContract.php | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Core/HydeManager.php b/src/Core/HydeManager.php index 681a633b..ddf66d4a 100644 --- a/src/Core/HydeManager.php +++ b/src/Core/HydeManager.php @@ -39,4 +39,9 @@ public function hydeSystemManager(): HydeSystemManager { return $this->hydeSystemManager; } + + public function sourceLocationManager(): SourceLocationManager + { + return $this->sourceLocationManager; + } } \ No newline at end of file diff --git a/src/Core/HydeManagerContract.php b/src/Core/HydeManagerContract.php index 9263043e..0698c279 100644 --- a/src/Core/HydeManagerContract.php +++ b/src/Core/HydeManagerContract.php @@ -30,7 +30,6 @@ public function bootstrap(): void; */ public function getHydeSystemManager(): string; - public function getSourceLocationManager(): string; @@ -41,4 +40,5 @@ public function getSourceLocationManager(): string; */ public function hydeSystemManager(): HydeSystemManager; + public function sourceLocationManager(): SourceLocationManager; } \ No newline at end of file From 62b6b9c2005cae949c75d8876e0bfdede9ccd68f Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Sat, 14 May 2022 20:47:45 +0200 Subject: [PATCH 09/22] Deprecate version bindings --- src/HydeServiceProvider.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/HydeServiceProvider.php b/src/HydeServiceProvider.php index 8afcba25..f22ba5dc 100644 --- a/src/HydeServiceProvider.php +++ b/src/HydeServiceProvider.php @@ -20,6 +20,9 @@ class HydeServiceProvider extends ServiceProvider */ public function register() { + /** + * @deprecated + */ $this->app->bind( 'hyde.version', function () { @@ -27,6 +30,9 @@ function () { } ); + /** + * @deprecated + */ $this->app->bind( 'framework.version', function () { From b22e4fa846a6ac18f960b0f1283e843386cbf855 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Sat, 14 May 2022 20:47:54 +0200 Subject: [PATCH 10/22] Add notice it's not yet implemented --- src/Core/SourceLocationManager.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Core/SourceLocationManager.php b/src/Core/SourceLocationManager.php index 2d909746..dfa5d0bb 100644 --- a/src/Core/SourceLocationManager.php +++ b/src/Core/SourceLocationManager.php @@ -6,6 +6,8 @@ * Define where the source content files are located. * This is then used for Hyde auto-discovery. * Returned paths must be relative to the project root. e.g. '_posts', 'src/posts', etc. + * + * @todo Please note that these methods are not yet used, but will be. */ interface SourceLocationManager { From 8640d811ffafa81a98f26f15c155f3c2e3dc3795 Mon Sep 17 00:00:00 2001 From: StyleCI Bot Date: Sat, 14 May 2022 18:48:06 +0000 Subject: [PATCH 11/22] Apply fixes from StyleCI [ci skip] [skip ci] --- src/Core/HydeManager.php | 2 +- src/Core/HydeManagerContract.php | 9 ++++----- src/Core/HydeSystemManager.php | 2 +- src/Core/HydeSystemProvider.php | 2 +- src/Core/SourceLocationManager.php | 6 +++++- src/Core/SourceLocationProvider.php | 3 +-- 6 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/Core/HydeManager.php b/src/Core/HydeManager.php index ddf66d4a..a3440240 100644 --- a/src/Core/HydeManager.php +++ b/src/Core/HydeManager.php @@ -44,4 +44,4 @@ public function sourceLocationManager(): SourceLocationManager { return $this->sourceLocationManager; } -} \ No newline at end of file +} diff --git a/src/Core/HydeManagerContract.php b/src/Core/HydeManagerContract.php index 0698c279..994ffd28 100644 --- a/src/Core/HydeManagerContract.php +++ b/src/Core/HydeManagerContract.php @@ -28,17 +28,16 @@ public function bootstrap(): void; * Default return syntax: \Hyde\Framework\Core\ServiceManager::class * ========================================================================= */ - public function getHydeSystemManager(): string; - public function getSourceLocationManager(): string; + public function getSourceLocationManager(): string; /** * ========================================================================= * Get the manager implementation instantiated in the bootstrap process. - * ========================================================================= + * =========================================================================. */ - public function hydeSystemManager(): HydeSystemManager; + public function sourceLocationManager(): SourceLocationManager; -} \ No newline at end of file +} diff --git a/src/Core/HydeSystemManager.php b/src/Core/HydeSystemManager.php index 10b51669..e9d54883 100644 --- a/src/Core/HydeSystemManager.php +++ b/src/Core/HydeSystemManager.php @@ -9,4 +9,4 @@ interface HydeSystemManager * Used to assemble all file paths in the Hyde::path() method. */ public function getProjectRoot(): string; -} \ No newline at end of file +} diff --git a/src/Core/HydeSystemProvider.php b/src/Core/HydeSystemProvider.php index b5fb0228..bc2832d1 100644 --- a/src/Core/HydeSystemProvider.php +++ b/src/Core/HydeSystemProvider.php @@ -11,4 +11,4 @@ public function getProjectRoot(): string { return getcwd(); } -} \ No newline at end of file +} diff --git a/src/Core/SourceLocationManager.php b/src/Core/SourceLocationManager.php index dfa5d0bb..1e06e8e1 100644 --- a/src/Core/SourceLocationManager.php +++ b/src/Core/SourceLocationManager.php @@ -13,25 +13,29 @@ interface SourceLocationManager { /** * Return the directory BladePages are stored in. + * * @see \Hyde\Framework\Models\BladePage */ public function findBladePagesIn(): string; /** * Return the directory MarkdownPages are stored in. + * * @see \Hyde\Framework\Models\MarkdownPage */ public function findMarkdownPagesIn(): string; /** * Return the directory MarkdownPosts are stored in. + * * @see \Hyde\Framework\Models\MarkdownPost */ public function findMarkdownPostsIn(): string; /** * Return the directory DocumentationPages are stored in. + * * @see \Hyde\Framework\Models\DocumentationPage */ public function findDocumentationPagesIn(): string; -} \ No newline at end of file +} diff --git a/src/Core/SourceLocationProvider.php b/src/Core/SourceLocationProvider.php index cccb8d4f..24c9c81d 100644 --- a/src/Core/SourceLocationProvider.php +++ b/src/Core/SourceLocationProvider.php @@ -4,7 +4,6 @@ class SourceLocationProvider implements SourceLocationManager { - /** * @inheritDoc */ @@ -36,4 +35,4 @@ public function findDocumentationPagesIn(): string { return '_docs'; } -} \ No newline at end of file +} From 8be292351577f680d51cf0307f9a7ae0734cb686 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Sat, 14 May 2022 21:22:29 +0200 Subject: [PATCH 12/22] Allow disabling of the creation of default directories --- src/Core/HydeSystemManager.php | 8 ++++++++ src/Core/HydeSystemProvider.php | 5 +++++ src/HydeServiceProvider.php | 9 ++++++++- 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/Core/HydeSystemManager.php b/src/Core/HydeSystemManager.php index e9d54883..7f2273b9 100644 --- a/src/Core/HydeSystemManager.php +++ b/src/Core/HydeSystemManager.php @@ -9,4 +9,12 @@ interface HydeSystemManager * Used to assemble all file paths in the Hyde::path() method. */ public function getProjectRoot(): string; + + /** + * Should the default directories be created automatically? + * + * Useful when proxying a project or when exposing the Hyde API. + * Note that builds may fail if the directories are not created. + */ + public function shouldPublishDefaultDirectories(): bool; } diff --git a/src/Core/HydeSystemProvider.php b/src/Core/HydeSystemProvider.php index bc2832d1..15235035 100644 --- a/src/Core/HydeSystemProvider.php +++ b/src/Core/HydeSystemProvider.php @@ -11,4 +11,9 @@ public function getProjectRoot(): string { return getcwd(); } + + public function shouldPublishDefaultDirectories(): bool + { + return true; + } } diff --git a/src/HydeServiceProvider.php b/src/HydeServiceProvider.php index f22ba5dc..3596bf1d 100644 --- a/src/HydeServiceProvider.php +++ b/src/HydeServiceProvider.php @@ -7,6 +7,8 @@ use Hyde\Framework\Core\HydeManager; use Hyde\Framework\Core\HydeManagerContract; use Illuminate\Support\ServiceProvider; +use Psr\Container\ContainerExceptionInterface; +use Psr\Container\NotFoundExceptionInterface; /** * Register and bootstrap Hyde application services. @@ -70,7 +72,12 @@ function () { */ public function boot() { - (new CreatesDefaultDirectories)->__invoke(); + try { + if ($this->app->get(HydeManagerContract::class)->hydeSystemManager()->shouldPublishDefaultDirectories()) { + (new CreatesDefaultDirectories)->__invoke(); + } + } catch (NotFoundExceptionInterface|ContainerExceptionInterface) { + } $this->loadViewsFrom(__DIR__.'/../resources/views', 'hyde'); From 51bdcd896099a85d4965fb9549ba98ebb7787831 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Sat, 14 May 2022 21:39:19 +0200 Subject: [PATCH 13/22] Add helper to quickly get the instantiated provider from the service container for the given contract. --- src/Core/HydeManager.php | 8 ++++++++ src/HydeServiceProvider.php | 3 ++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/Core/HydeManager.php b/src/Core/HydeManager.php index a3440240..ceba8cd3 100644 --- a/src/Core/HydeManager.php +++ b/src/Core/HydeManager.php @@ -44,4 +44,12 @@ public function sourceLocationManager(): SourceLocationManager { return $this->sourceLocationManager; } + + /** + * Get the instantiated provider from the service container for the given contract. + */ + public static function get(string $classImplementingContract) + { + return app()->get(HydeManagerContract::class)->{basename($classImplementingContract)}(); + } } diff --git a/src/HydeServiceProvider.php b/src/HydeServiceProvider.php index 3596bf1d..84ee4851 100644 --- a/src/HydeServiceProvider.php +++ b/src/HydeServiceProvider.php @@ -6,6 +6,7 @@ use Hyde\Framework\Actions\CreatesDefaultDirectories; use Hyde\Framework\Core\HydeManager; use Hyde\Framework\Core\HydeManagerContract; +use Hyde\Framework\Core\HydeSystemManager; use Illuminate\Support\ServiceProvider; use Psr\Container\ContainerExceptionInterface; use Psr\Container\NotFoundExceptionInterface; @@ -73,7 +74,7 @@ function () { public function boot() { try { - if ($this->app->get(HydeManagerContract::class)->hydeSystemManager()->shouldPublishDefaultDirectories()) { + if (HydeManager::get(HydeSystemManager::class)->shouldPublishDefaultDirectories()) { (new CreatesDefaultDirectories)->__invoke(); } } catch (NotFoundExceptionInterface|ContainerExceptionInterface) { From 8a3c673f1f2686c7c24ebc88bb08feb23728aa2d Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Sat, 14 May 2022 21:59:50 +0200 Subject: [PATCH 14/22] Deprecate static::$sourceDirectory --- src/Contracts/AbstractPage.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Contracts/AbstractPage.php b/src/Contracts/AbstractPage.php index c17c577e..ffa50623 100644 --- a/src/Contracts/AbstractPage.php +++ b/src/Contracts/AbstractPage.php @@ -10,6 +10,9 @@ */ abstract class AbstractPage { + /** + * @deprecated version 0.25.0 + */ public static string $sourceDirectory; public static string $fileExtension; public static string $parserClass; From a84e678719ed026bb274ddd57409abce182bcf1c Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Sat, 14 May 2022 22:15:25 +0200 Subject: [PATCH 15/22] Add note that it breaks the RC --- src/Core/SourceLocationManager.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Core/SourceLocationManager.php b/src/Core/SourceLocationManager.php index 1e06e8e1..0b57ba0b 100644 --- a/src/Core/SourceLocationManager.php +++ b/src/Core/SourceLocationManager.php @@ -6,6 +6,8 @@ * Define where the source content files are located. * This is then used for Hyde auto-discovery. * Returned paths must be relative to the project root. e.g. '_posts', 'src/posts', etc. + * + * @note that changing these will cause the realtime compiler to fail. * * @todo Please note that these methods are not yet used, but will be. */ From 4defd9aec725600fba312b4d073cf568b219c77a Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Sat, 14 May 2022 22:18:08 +0200 Subject: [PATCH 16/22] Revert to original behaviour --- src/Contracts/AbstractPage.php | 3 --- src/Core/SourceLocationManager.php | 2 ++ src/Core/SourceLocationProvider.php | 3 +++ 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/Contracts/AbstractPage.php b/src/Contracts/AbstractPage.php index ffa50623..c17c577e 100644 --- a/src/Contracts/AbstractPage.php +++ b/src/Contracts/AbstractPage.php @@ -10,9 +10,6 @@ */ abstract class AbstractPage { - /** - * @deprecated version 0.25.0 - */ public static string $sourceDirectory; public static string $fileExtension; public static string $parserClass; diff --git a/src/Core/SourceLocationManager.php b/src/Core/SourceLocationManager.php index 0b57ba0b..edc7fcf4 100644 --- a/src/Core/SourceLocationManager.php +++ b/src/Core/SourceLocationManager.php @@ -10,6 +10,8 @@ * @note that changing these will cause the realtime compiler to fail. * * @todo Please note that these methods are not yet used, but will be. + * + * @deprecated */ interface SourceLocationManager { diff --git a/src/Core/SourceLocationProvider.php b/src/Core/SourceLocationProvider.php index 24c9c81d..e2b0729a 100644 --- a/src/Core/SourceLocationProvider.php +++ b/src/Core/SourceLocationProvider.php @@ -2,6 +2,9 @@ namespace Hyde\Framework\Core; +/** + * @deprecated + */ class SourceLocationProvider implements SourceLocationManager { /** From 4daa47ab12de7f6e8e5a345901aeeeda8d6a452b Mon Sep 17 00:00:00 2001 From: StyleCI Bot Date: Sat, 14 May 2022 20:18:23 +0000 Subject: [PATCH 17/22] Apply fixes from StyleCI [ci skip] [skip ci] --- src/Core/SourceLocationManager.php | 6 +++--- src/Core/SourceLocationProvider.php | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Core/SourceLocationManager.php b/src/Core/SourceLocationManager.php index edc7fcf4..65cb1136 100644 --- a/src/Core/SourceLocationManager.php +++ b/src/Core/SourceLocationManager.php @@ -6,12 +6,12 @@ * Define where the source content files are located. * This is then used for Hyde auto-discovery. * Returned paths must be relative to the project root. e.g. '_posts', 'src/posts', etc. - * + * * @note that changing these will cause the realtime compiler to fail. * * @todo Please note that these methods are not yet used, but will be. - * - * @deprecated + * + * @deprecated */ interface SourceLocationManager { diff --git a/src/Core/SourceLocationProvider.php b/src/Core/SourceLocationProvider.php index e2b0729a..3451d589 100644 --- a/src/Core/SourceLocationProvider.php +++ b/src/Core/SourceLocationProvider.php @@ -3,7 +3,7 @@ namespace Hyde\Framework\Core; /** - * @deprecated + * @deprecated */ class SourceLocationProvider implements SourceLocationManager { From 580cd9a616ea5ea7303ac92a04f04a6903828d15 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Sat, 14 May 2022 22:30:55 +0200 Subject: [PATCH 18/22] Add autodiscovery information --- src/Services/BuildService.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Services/BuildService.php b/src/Services/BuildService.php index be938156..5892b218 100644 --- a/src/Services/BuildService.php +++ b/src/Services/BuildService.php @@ -42,6 +42,8 @@ public static function getFileExtensionForModelFiles(string $model): string /** * Get the source directory path of a model. + * + * This is what powers the Hyde autodiscovery. */ public static function getFilePathForModelClassFiles(string $model): string { From 029febafd511b664921597ff7d980cd1a09d3a3d Mon Sep 17 00:00:00 2001 From: StyleCI Bot Date: Sat, 14 May 2022 20:31:10 +0000 Subject: [PATCH 19/22] Apply fixes from StyleCI [ci skip] [skip ci] --- src/Services/BuildService.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Services/BuildService.php b/src/Services/BuildService.php index 5892b218..db05fa99 100644 --- a/src/Services/BuildService.php +++ b/src/Services/BuildService.php @@ -42,7 +42,7 @@ public static function getFileExtensionForModelFiles(string $model): string /** * Get the source directory path of a model. - * + * * This is what powers the Hyde autodiscovery. */ public static function getFilePathForModelClassFiles(string $model): string From 1fe5d4b79def2f00edd271d93078dca6f68843cd Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Sat, 14 May 2022 22:48:55 +0200 Subject: [PATCH 20/22] Remove source location --- src/Core/SourceLocationManager.php | 45 ----------------------------- src/Core/SourceLocationProvider.php | 41 -------------------------- 2 files changed, 86 deletions(-) delete mode 100644 src/Core/SourceLocationManager.php delete mode 100644 src/Core/SourceLocationProvider.php diff --git a/src/Core/SourceLocationManager.php b/src/Core/SourceLocationManager.php deleted file mode 100644 index 65cb1136..00000000 --- a/src/Core/SourceLocationManager.php +++ /dev/null @@ -1,45 +0,0 @@ - Date: Sat, 14 May 2022 22:57:29 +0200 Subject: [PATCH 21/22] Disable CreatesDefaultDirectories using config instead --- src/Core/HydeSystemManager.php | 8 -------- src/Core/HydeSystemProvider.php | 5 ----- src/HydeServiceProvider.php | 15 +++++++++------ 3 files changed, 9 insertions(+), 19 deletions(-) diff --git a/src/Core/HydeSystemManager.php b/src/Core/HydeSystemManager.php index 7f2273b9..e9d54883 100644 --- a/src/Core/HydeSystemManager.php +++ b/src/Core/HydeSystemManager.php @@ -9,12 +9,4 @@ interface HydeSystemManager * Used to assemble all file paths in the Hyde::path() method. */ public function getProjectRoot(): string; - - /** - * Should the default directories be created automatically? - * - * Useful when proxying a project or when exposing the Hyde API. - * Note that builds may fail if the directories are not created. - */ - public function shouldPublishDefaultDirectories(): bool; } diff --git a/src/Core/HydeSystemProvider.php b/src/Core/HydeSystemProvider.php index 15235035..bc2832d1 100644 --- a/src/Core/HydeSystemProvider.php +++ b/src/Core/HydeSystemProvider.php @@ -11,9 +11,4 @@ public function getProjectRoot(): string { return getcwd(); } - - public function shouldPublishDefaultDirectories(): bool - { - return true; - } } diff --git a/src/HydeServiceProvider.php b/src/HydeServiceProvider.php index 84ee4851..db170f62 100644 --- a/src/HydeServiceProvider.php +++ b/src/HydeServiceProvider.php @@ -73,13 +73,16 @@ function () { */ public function boot() { - try { - if (HydeManager::get(HydeSystemManager::class)->shouldPublishDefaultDirectories()) { - (new CreatesDefaultDirectories)->__invoke(); - } - } catch (NotFoundExceptionInterface|ContainerExceptionInterface) { + /** + * Creates the default directories required for Hyde to be able to process files. + * If you running the Framework in a non-standard environment that does not + * use the Framework to generate files automatically, such as in Buddy, + * you can disable this with the "hidden" config option seen below. + */ + if (config('hyde.create_default_directories', true)) { + (new CreatesDefaultDirectories)->__invoke(); } - + $this->loadViewsFrom(__DIR__.'/../resources/views', 'hyde'); $this->publishes([ From 9abd49ff35bbeb7a70971ba09efc5adf754e266e Mon Sep 17 00:00:00 2001 From: StyleCI Bot Date: Sat, 14 May 2022 20:57:42 +0000 Subject: [PATCH 22/22] Apply fixes from StyleCI [ci skip] [skip ci] --- src/HydeServiceProvider.php | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/HydeServiceProvider.php b/src/HydeServiceProvider.php index db170f62..83c55ca2 100644 --- a/src/HydeServiceProvider.php +++ b/src/HydeServiceProvider.php @@ -6,10 +6,7 @@ use Hyde\Framework\Actions\CreatesDefaultDirectories; use Hyde\Framework\Core\HydeManager; use Hyde\Framework\Core\HydeManagerContract; -use Hyde\Framework\Core\HydeSystemManager; use Illuminate\Support\ServiceProvider; -use Psr\Container\ContainerExceptionInterface; -use Psr\Container\NotFoundExceptionInterface; /** * Register and bootstrap Hyde application services. @@ -82,7 +79,7 @@ public function boot() if (config('hyde.create_default_directories', true)) { (new CreatesDefaultDirectories)->__invoke(); } - + $this->loadViewsFrom(__DIR__.'/../resources/views', 'hyde'); $this->publishes([