Skip to content

Commit

Permalink
\LastDragon_ru\LaraASP\Spa\Provider => `\LastDragon_ru\LaraASP\Spa\…
Browse files Browse the repository at this point in the history
…PackageProvider`.
  • Loading branch information
LastDragon-ru committed Nov 16, 2024
1 parent 3b05adc commit 2a1ba38
Show file tree
Hide file tree
Showing 9 changed files with 76 additions and 53 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@
"LastDragon_ru\\LaraASP\\GraphQL\\PackageProvider",
"LastDragon_ru\\LaraASP\\Migrator\\PackageProvider",
"LastDragon_ru\\LaraASP\\Serializer\\PackageProvider",
"LastDragon_ru\\LaraASP\\Spa\\Provider"
"LastDragon_ru\\LaraASP\\Spa\\PackageProvider"
]
}
},
Expand Down
13 changes: 13 additions & 0 deletions packages/spa/UPGRADE.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ Please also see [changelog](https://github.com/LastDragon-ru/lara-asp/releases)

* [ ] Package config now uses objects instead of an array, it is recommended to migrate to the new format. 🤝

* [ ] Use [`PackageProvider`][code-links/fd2e6dfbce2f47cb] instead of [`💀Provider`][code-links/15f480832d63e0d6].

# Upgrade from v5

[include:file]: ../../docs/Shared/Upgrade/FromV5.md
Expand All @@ -50,3 +52,14 @@ Please also see [changelog](https://github.com/LastDragon-ru/lara-asp/releases)
* [ ] Laravel v9 is not supported anymore. Migrate to the newer version.

[//]: # (end: preprocess/2e85dad2b0618274)

[//]: # (start: code-links)
[//]: # (warning: Generated automatically. Do not edit.)

[code-links/fd2e6dfbce2f47cb]: src/PackageProvider.php
"\LastDragon_ru\LaraASP\Spa\PackageProvider"

[code-links/15f480832d63e0d6]: src/Provider.php
"\LastDragon_ru\LaraASP\Spa\Provider"

[//]: # (end: code-links)
2 changes: 1 addition & 1 deletion packages/spa/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
"extra": {
"laravel": {
"providers": [
"LastDragon_ru\\LaraASP\\Spa\\Provider"
"LastDragon_ru\\LaraASP\\Spa\\PackageProvider"
]
},
"lara-asp": {
Expand Down
4 changes: 2 additions & 2 deletions packages/spa/src/Http/Controllers/SpaControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use LastDragon_ru\LaraASP\Spa\Config\Config;
use LastDragon_ru\LaraASP\Spa\PackageConfig;
use LastDragon_ru\LaraASP\Spa\Provider;
use LastDragon_ru\LaraASP\Spa\PackageProvider;
use LastDragon_ru\LaraASP\Spa\Testing\Package\TestCase;
use LastDragon_ru\LaraASP\Testing\Constraints\Json\JsonSchemaFile;
use LastDragon_ru\LaraASP\Testing\Constraints\Response\Response;
Expand Down Expand Up @@ -47,7 +47,7 @@ static function (Config $config) use ($routes, $prefix, $settings): void {
},
);

$provider = new class($this->app()) extends Provider {
$provider = new class($this->app()) extends PackageProvider {
// empty
};
$provider->boot();
Expand Down
49 changes: 49 additions & 0 deletions packages/spa/src/PackageProvider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?php declare(strict_types = 1);

namespace LastDragon_ru\LaraASP\Spa;

use Illuminate\Support\ServiceProvider;
use LastDragon_ru\LaraASP\Core\Provider\WithConfig;
use LastDragon_ru\LaraASP\Core\Provider\WithRoutes;
use LastDragon_ru\LaraASP\Core\Provider\WithTranslations;
use Override;

class PackageProvider extends ServiceProvider {
use WithConfig;
use WithRoutes;
use WithTranslations;

// <editor-fold desc="\Illuminate\Support\ServiceProvider">
// =========================================================================
#[Override]
public function register(): void {
parent::register();

$this->registerConfig(PackageConfig::class);
}

public function boot(): void {
$this->bootTranslations();
$this->bootRoutes(function (): array {
$config = $this->app->make(PackageConfig::class)->getInstance();
$settings = [
'enabled' => $config->routes->enabled,
'attributes' => [
'prefix' => $config->routes->prefix,
'middleware' => $config->routes->middleware,
],
];

return $settings;
});
}
// </editor-fold>

// <editor-fold desc="Functions">
// =========================================================================
#[Override]
protected function getName(): string {
return Package::Name;
}
// </editor-fold>
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
/**
* @internal
*/
#[CoversClass(Provider::class)]
final class ProviderTest extends TestCase {
#[CoversClass(PackageProvider::class)]
final class PackageProviderTest extends TestCase {
public function testConfig(): void {
self::assertConfigurationExportable(PackageConfig::class);
}
Expand All @@ -30,7 +30,7 @@ public function testLegacyConfig(): void {

self::assertIsArray($config->get($package));

(new Provider($app))->register();
(new PackageProvider($app))->register();

// Test
$expected = new Config();
Expand Down
49 changes: 5 additions & 44 deletions packages/spa/src/Provider.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,48 +2,9 @@

namespace LastDragon_ru\LaraASP\Spa;

use Illuminate\Support\ServiceProvider;
use LastDragon_ru\LaraASP\Core\Provider\WithConfig;
use LastDragon_ru\LaraASP\Core\Provider\WithRoutes;
use LastDragon_ru\LaraASP\Core\Provider\WithTranslations;
use Override;

class Provider extends ServiceProvider {
use WithConfig;
use WithRoutes;
use WithTranslations;

// <editor-fold desc="\Illuminate\Support\ServiceProvider">
// =========================================================================
#[Override]
public function register(): void {
parent::register();

$this->registerConfig(PackageConfig::class);
}

public function boot(): void {
$this->bootTranslations();
$this->bootRoutes(function (): array {
$config = $this->app->make(PackageConfig::class)->getInstance();
$settings = [
'enabled' => $config->routes->enabled,
'attributes' => [
'prefix' => $config->routes->prefix,
'middleware' => $config->routes->middleware,
],
];

return $settings;
});
}
// </editor-fold>

// <editor-fold desc="Functions">
// =========================================================================
#[Override]
protected function getName(): string {
return Package::Name;
}
// </editor-fold>
/**
* @deprecated %{VERSION} The {@see PackageProvider} should be used instead.
*/
class Provider extends PackageProvider {
// empty
}
4 changes: 2 additions & 2 deletions packages/spa/src/Testing/Package/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace LastDragon_ru\LaraASP\Spa\Testing\Package;

use LastDragon_ru\LaraASP\Core\PackageProvider as CoreProvider;
use LastDragon_ru\LaraASP\Spa\Provider;
use LastDragon_ru\LaraASP\Spa\PackageProvider;
use LastDragon_ru\LaraASP\Testing\Testing\TestCase as PackageTestCase;
use Override;

Expand All @@ -19,7 +19,7 @@ abstract class TestCase extends PackageTestCase {
#[Override]
protected function getPackageProviders(mixed $app): array {
return array_merge(parent::getPackageProviders($app), [
Provider::class,
PackageProvider::class,
CoreProvider::class,
]);
}
Expand Down

0 comments on commit 2a1ba38

Please sign in to comment.