Skip to content

Commit

Permalink
refactor: Providers rename (#200)
Browse files Browse the repository at this point in the history
To be more consistent.
  • Loading branch information
LastDragon-ru authored Nov 16, 2024
2 parents 551b3fe + 2a1ba38 commit 3e7b957
Show file tree
Hide file tree
Showing 67 changed files with 588 additions and 406 deletions.
18 changes: 9 additions & 9 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -175,15 +175,15 @@
},
"laravel": {
"providers": [
"LastDragon_ru\\LaraASP\\Core\\Provider",
"LastDragon_ru\\LaraASP\\Dev\\Provider",
"LastDragon_ru\\LaraASP\\Documentator\\Provider",
"LastDragon_ru\\LaraASP\\Eloquent\\Provider",
"LastDragon_ru\\LaraASP\\Formatter\\Provider",
"LastDragon_ru\\LaraASP\\GraphQL\\Provider",
"LastDragon_ru\\LaraASP\\Migrator\\Provider",
"LastDragon_ru\\LaraASP\\Serializer\\Provider",
"LastDragon_ru\\LaraASP\\Spa\\Provider"
"LastDragon_ru\\LaraASP\\Core\\PackageProvider",
"LastDragon_ru\\LaraASP\\Dev\\PackageProvider",
"LastDragon_ru\\LaraASP\\Documentator\\PackageProvider",
"LastDragon_ru\\LaraASP\\Eloquent\\PackageProvider",
"LastDragon_ru\\LaraASP\\Formatter\\PackageProvider",
"LastDragon_ru\\LaraASP\\GraphQL\\PackageProvider",
"LastDragon_ru\\LaraASP\\Migrator\\PackageProvider",
"LastDragon_ru\\LaraASP\\Serializer\\PackageProvider",
"LastDragon_ru\\LaraASP\\Spa\\PackageProvider"
]
}
},
Expand Down
8 changes: 8 additions & 0 deletions packages/core/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)

* [ ] [`WithRoutes::bootRoutes()`][code-links/141085a29c14a778] requires settings.

* [ ] Use [`PackageProvider`][code-links/b1bdaf40c86b0742] instead of [`💀Provider`][code-links/8b4dc3d615948332].

# Upgrade from v5

[include:file]: ../../docs/Shared/Upgrade/FromV5.md
Expand All @@ -54,6 +56,12 @@ Please also see [changelog](https://github.com/LastDragon-ru/lara-asp/releases)
[//]: # (start: code-links)
[//]: # (warning: Generated automatically. Do not edit.)

[code-links/b1bdaf40c86b0742]: src/PackageProvider.php
"\LastDragon_ru\LaraASP\Core\PackageProvider"

[code-links/8b4dc3d615948332]: src/Provider.php
"\LastDragon_ru\LaraASP\Core\Provider"

[code-links/141085a29c14a778]: src/Provider/WithRoutes.php#L16-L41
"\LastDragon_ru\LaraASP\Core\Provider\WithRoutes::bootRoutes()"

Expand Down
2 changes: 1 addition & 1 deletion packages/core/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
},
"laravel": {
"providers": [
"LastDragon_ru\\LaraASP\\Core\\Provider"
"LastDragon_ru\\LaraASP\\Core\\PackageProvider"
]
}
},
Expand Down
33 changes: 33 additions & 0 deletions packages/core/src/PackageProvider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php declare(strict_types = 1);

namespace LastDragon_ru\LaraASP\Core;

use Illuminate\Container\Container;
use Illuminate\Contracts\Config\Repository;
use Illuminate\Contracts\Foundation\Application;
use Illuminate\Support\ServiceProvider;
use LastDragon_ru\LaraASP\Core\Application\ApplicationResolver;
use LastDragon_ru\LaraASP\Core\Application\ConfigResolver;
use LastDragon_ru\LaraASP\Core\Application\ContainerResolver;
use Override;

class PackageProvider extends ServiceProvider {
#[Override]
public function register(): void {
parent::register();

$this->registerResolvers();
}

protected function registerResolvers(): void {
$this->app->singletonIf(ContainerResolver::class, static function (): ContainerResolver {
return new ContainerResolver(static fn () => Container::getInstance());
});
$this->app->singletonIf(ApplicationResolver::class, static function (): ApplicationResolver {
return new ApplicationResolver(static fn () => Container::getInstance()->make(Application::class));
});
$this->app->singletonIf(ConfigResolver::class, static function (): ConfigResolver {
return new ConfigResolver(static fn () => Container::getInstance()->make(Repository::class));
});
}
}
33 changes: 5 additions & 28 deletions packages/core/src/Provider.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,9 @@

namespace LastDragon_ru\LaraASP\Core;

use Illuminate\Container\Container;
use Illuminate\Contracts\Config\Repository;
use Illuminate\Contracts\Foundation\Application;
use Illuminate\Support\ServiceProvider;
use LastDragon_ru\LaraASP\Core\Application\ApplicationResolver;
use LastDragon_ru\LaraASP\Core\Application\ConfigResolver;
use LastDragon_ru\LaraASP\Core\Application\ContainerResolver;
use Override;

class Provider extends ServiceProvider {
#[Override]
public function register(): void {
parent::register();

$this->registerResolvers();
}

protected function registerResolvers(): void {
$this->app->singletonIf(ContainerResolver::class, static function (): ContainerResolver {
return new ContainerResolver(static fn () => Container::getInstance());
});
$this->app->singletonIf(ApplicationResolver::class, static function (): ApplicationResolver {
return new ApplicationResolver(static fn () => Container::getInstance()->make(Application::class));
});
$this->app->singletonIf(ConfigResolver::class, static function (): ConfigResolver {
return new ConfigResolver(static fn () => Container::getInstance()->make(Repository::class));
});
}
/**
* @deprecated %{VERSION} The {@see PackageProvider} should be used instead.
*/
class Provider extends PackageProvider {
// empty
}
4 changes: 2 additions & 2 deletions packages/core/src/Testing/Package/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace LastDragon_ru\LaraASP\Core\Testing\Package;

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

Expand All @@ -18,7 +18,7 @@ abstract class TestCase extends PackageTestCase {
#[Override]
protected function getPackageProviders(mixed $app): array {
return array_merge(parent::getPackageProviders($app), [
Provider::class,
PackageProvider::class,
]);
}
}
13 changes: 13 additions & 0 deletions packages/dev/UPGRADE.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,16 @@ Please also see [changelog](https://github.com/LastDragon-ru/lara-asp/releases)
* [ ] Direct usages of `Container::getInstances()` were replaced by explicit constructor parameters. You may need to update your code accordingly (#151).

[//]: # (end: preprocess/9679e76379216855)

* [ ] Use [`PackageProvider`][code-links/462e33ec6b6fe967] instead of [`💀Provider`][code-links/076fdf36381becef].

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

[code-links/462e33ec6b6fe967]: src/PackageProvider.php
"\LastDragon_ru\LaraASP\Dev\PackageProvider"

[code-links/076fdf36381becef]: src/Provider.php
"\LastDragon_ru\LaraASP\Dev\Provider"

[//]: # (end: code-links)
2 changes: 1 addition & 1 deletion packages/dev/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"extra": {
"laravel": {
"providers": [
"LastDragon_ru\\LaraASP\\Dev\\Provider"
"LastDragon_ru\\LaraASP\\Dev\\PackageProvider"
]
}
},
Expand Down
17 changes: 17 additions & 0 deletions packages/dev/src/PackageProvider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php declare(strict_types = 1);

namespace LastDragon_ru\LaraASP\Dev;

use Illuminate\Support\ServiceProvider;
use LastDragon_ru\LaraASP\Dev\App\Example;
use LastDragon_ru\LaraASP\Documentator\Processor\Tasks\Preprocess\Instructions\IncludeExample\Contracts\Runner;
use Override;

class PackageProvider extends ServiceProvider {
#[Override]
public function register(): void {
parent::register();

$this->app->bind(Runner::class, Example::class);
}
}
17 changes: 5 additions & 12 deletions packages/dev/src/Provider.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,9 @@

namespace LastDragon_ru\LaraASP\Dev;

use Illuminate\Support\ServiceProvider;
use LastDragon_ru\LaraASP\Dev\App\Example;
use LastDragon_ru\LaraASP\Documentator\Processor\Tasks\Preprocess\Instructions\IncludeExample\Contracts\Runner;
use Override;

class Provider extends ServiceProvider {
#[Override]
public function register(): void {
parent::register();

$this->app->bind(Runner::class, Example::class);
}
/**
* @deprecated %{VERSION} The {@see PackageProvider} should be used instead.
*/
class Provider extends PackageProvider {
// empty
}
8 changes: 8 additions & 0 deletions packages/documentator/UPGRADE.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ Please also see [changelog](https://github.com/LastDragon-ru/lara-asp/releases)

* [ ] `💀\LastDragon_ru\LaraASP\Documentator\Processor\Exceptions\FileDependencyNotFound` replaced by [`DependencyNotFound`][code-links/b5c6ff41fa24071c].

* [ ] Use [`PackageProvider`][code-links/bddbc83c8cbd0c67] instead of [`💀Provider`][code-links/a76f14008cba70b9].

# Upgrade from v5

[include:file]: ../../docs/Shared/Upgrade/FromV5.md
Expand All @@ -70,6 +72,9 @@ Please also see [changelog](https://github.com/LastDragon-ru/lara-asp/releases)
[//]: # (start: code-links)
[//]: # (warning: Generated automatically. Do not edit.)

[code-links/bddbc83c8cbd0c67]: src/PackageProvider.php
"\LastDragon_ru\LaraASP\Documentator\PackageProvider"

[code-links/f4718f92376c3c25]: src/Processor/Contracts/Dependency.php
"\LastDragon_ru\LaraASP\Documentator\Processor\Contracts\Dependency"

Expand All @@ -88,4 +93,7 @@ Please also see [changelog](https://github.com/LastDragon-ru/lara-asp/releases)
[code-links/f9077a28b352f84b]: src/Processor/Tasks/Preprocess/Instructions/IncludeExample/Contracts/Runner.php
"\LastDragon_ru\LaraASP\Documentator\Processor\Tasks\Preprocess\Instructions\IncludeExample\Contracts\Runner"

[code-links/a76f14008cba70b9]: src/Provider.php
"\LastDragon_ru\LaraASP\Documentator\Provider"

[//]: # (end: code-links)
2 changes: 1 addition & 1 deletion packages/documentator/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
"extra": {
"laravel": {
"providers": [
"LastDragon_ru\\LaraASP\\Documentator\\Provider"
"LastDragon_ru\\LaraASP\\Documentator\\PackageProvider"
]
},
"lara-asp": {
Expand Down
40 changes: 40 additions & 0 deletions packages/documentator/src/PackageProvider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php declare(strict_types = 1);

namespace LastDragon_ru\LaraASP\Documentator;

use Illuminate\Support\ServiceProvider;
use LastDragon_ru\LaraASP\Core\Provider\WithViews;
use LastDragon_ru\LaraASP\Documentator\Commands\Commands;
use LastDragon_ru\LaraASP\Documentator\Commands\Preprocess;
use LastDragon_ru\LaraASP\Documentator\Commands\Requirements;
use LastDragon_ru\LaraASP\Documentator\Processor\Contracts\Factory as ProcessorFactoryContract;
use LastDragon_ru\LaraASP\Documentator\Processor\Factory as ProcessorFactory;
use LastDragon_ru\LaraASP\Documentator\Processor\Tasks\CodeLinks\Contracts\LinkFactory as LinkFactoryContract;
use LastDragon_ru\LaraASP\Documentator\Processor\Tasks\CodeLinks\Links\Factory as LinkFactory;
use Override;

class PackageProvider extends ServiceProvider {
use WithViews;

#[Override]
public function register(): void {
parent::register();

$this->app->scopedIf(ProcessorFactoryContract::class, ProcessorFactory::class);
$this->app->scopedIf(LinkFactoryContract::class, LinkFactory::class);
}

public function boot(): void {
$this->bootViews();
$this->commands(
Requirements::class,
Preprocess::class,
Commands::class,
);
}

#[Override]
protected function getName(): string {
return Package::Name;
}
}
40 changes: 5 additions & 35 deletions packages/documentator/src/Provider.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,39 +2,9 @@

namespace LastDragon_ru\LaraASP\Documentator;

use Illuminate\Support\ServiceProvider;
use LastDragon_ru\LaraASP\Core\Provider\WithViews;
use LastDragon_ru\LaraASP\Documentator\Commands\Commands;
use LastDragon_ru\LaraASP\Documentator\Commands\Preprocess;
use LastDragon_ru\LaraASP\Documentator\Commands\Requirements;
use LastDragon_ru\LaraASP\Documentator\Processor\Contracts\Factory as ProcessorFactoryContract;
use LastDragon_ru\LaraASP\Documentator\Processor\Factory as ProcessorFactory;
use LastDragon_ru\LaraASP\Documentator\Processor\Tasks\CodeLinks\Contracts\LinkFactory as LinkFactoryContract;
use LastDragon_ru\LaraASP\Documentator\Processor\Tasks\CodeLinks\Links\Factory as LinkFactory;
use Override;

class Provider extends ServiceProvider {
use WithViews;

#[Override]
public function register(): void {
parent::register();

$this->app->scopedIf(ProcessorFactoryContract::class, ProcessorFactory::class);
$this->app->scopedIf(LinkFactoryContract::class, LinkFactory::class);
}

public function boot(): void {
$this->bootViews();
$this->commands(
Requirements::class,
Preprocess::class,
Commands::class,
);
}

#[Override]
protected function getName(): string {
return Package::Name;
}
/**
* @deprecated %{VERSION} The {@see PackageProvider} should be used instead.
*/
class Provider extends PackageProvider {
// empty
}
8 changes: 4 additions & 4 deletions packages/documentator/src/Testing/Package/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

namespace LastDragon_ru\LaraASP\Documentator\Testing\Package;

use LastDragon_ru\LaraASP\Core\Provider as CoreProvider;
use LastDragon_ru\LaraASP\Documentator\Provider;
use LastDragon_ru\LaraASP\Serializer\Provider as SerializerProvider;
use LastDragon_ru\LaraASP\Core\PackageProvider as CoreProvider;
use LastDragon_ru\LaraASP\Documentator\PackageProvider;
use LastDragon_ru\LaraASP\Serializer\PackageProvider as SerializerProvider;
use LastDragon_ru\LaraASP\Testing\Testing\TestCase as PackageTestCase;
use Override;

Expand All @@ -20,7 +20,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,
SerializerProvider::class,
]);
Expand Down
13 changes: 13 additions & 0 deletions packages/eloquent/UPGRADE.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ Please also see [changelog](https://github.com/LastDragon-ru/lara-asp/releases)

[//]: # (end: preprocess/9679e76379216855)

* [ ] Use [`PackageProvider`][code-links/7d48369ba7f64059] instead of [`💀Provider`][code-links/a893f38bdb4f8ccd].

# Upgrade from v5

[include:file]: ../../docs/Shared/Upgrade/FromV5.md
Expand All @@ -48,3 +50,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/7d48369ba7f64059]: src/PackageProvider.php
"\LastDragon_ru\LaraASP\Eloquent\PackageProvider"

[code-links/a893f38bdb4f8ccd]: src/Provider.php
"\LastDragon_ru\LaraASP\Eloquent\Provider"

[//]: # (end: code-links)
2 changes: 1 addition & 1 deletion packages/eloquent/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
"extra": {
"laravel": {
"providers": [
"LastDragon_ru\\LaraASP\\Eloquent\\Provider"
"LastDragon_ru\\LaraASP\\Eloquent\\PackageProvider"
]
},
"lara-asp": {
Expand Down
9 changes: 9 additions & 0 deletions packages/eloquent/src/PackageProvider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php declare(strict_types = 1);

namespace LastDragon_ru\LaraASP\Eloquent;

use Illuminate\Support\ServiceProvider;

class PackageProvider extends ServiceProvider {
// empty
}
Loading

0 comments on commit 3e7b957

Please sign in to comment.