Skip to content

Commit a18575d

Browse files
Removed facades
1 parent b66acb2 commit a18575d

File tree

5 files changed

+21
-69
lines changed

5 files changed

+21
-69
lines changed

src/Facades/Action.php

Lines changed: 0 additions & 32 deletions
This file was deleted.

src/Facades/Name.php

Lines changed: 0 additions & 32 deletions
This file was deleted.

src/Helpers/Name.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,17 @@
1717

1818
namespace DragonCode\LaravelRouteNames\Helpers;
1919

20-
use DragonCode\LaravelRouteNames\Facades\Action;
2120
use Illuminate\Support\Collection;
2221
use Illuminate\Support\Str;
2322

2423
class Name
2524
{
2625
protected string $default = 'main';
2726

27+
public function __construct(
28+
protected Action $action
29+
) {}
30+
2831
public function get(array $methods, string $uri): string
2932
{
3033
$resolved = $this->resolve($uri);
@@ -50,7 +53,7 @@ protected function resolve(string $uri): Collection
5053

5154
protected function getMethodSuffix(array $methods, string $uri): string
5255
{
53-
return Action::get($methods, $uri);
56+
return $this->action->get($methods, $uri);
5457
}
5558

5659
protected function has(string $value): bool

src/Routing/Route.php

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717

1818
namespace DragonCode\LaravelRouteNames\Routing;
1919

20-
use DragonCode\LaravelRouteNames\Facades\Name;
20+
use Closure;
21+
use DragonCode\LaravelRouteNames\Helpers\Name;
2122
use Illuminate\Routing\Route as BaseRoute;
2223
use Illuminate\Support\Str;
2324

@@ -26,14 +27,23 @@
2627

2728
class Route extends BaseRoute
2829
{
30+
public function __construct(
31+
array|string $methods,
32+
string $uri,
33+
array|Closure $action,
34+
protected Name $naming
35+
) {
36+
parent::__construct($methods, $uri, $action);
37+
}
38+
2939
public function getName(): ?string
3040
{
3141
if ($this->isProtectedRouteName()) {
3242
return $this->getProtectedRouteName();
3343
}
3444

3545
return app()->call($this->getRouteNamesExtender(), [
36-
'name' => Name::get($this->methods(), $this->uri()),
46+
'name' => $this->naming->get($this->methods(), $this->uri()),
3747
'route' => $this,
3848
]);
3949
}

src/Routing/Router.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,19 @@
1717

1818
namespace DragonCode\LaravelRouteNames\Routing;
1919

20+
use DragonCode\LaravelRouteNames\Helpers\Name;
2021
use Illuminate\Routing\Router as BaseRouter;
2122

23+
use function app;
24+
2225
class Router extends BaseRouter
2326
{
2427
public function newRoute(
2528
$methods, // @pest-ignore-type
2629
$uri, // @pest-ignore-type
2730
$action // @pest-ignore-type
2831
): Route {
29-
return (new Route($methods, $uri, $action))
32+
return (new Route($methods, $uri, $action, app(Name::class)))
3033
->setRouter($this)
3134
->setContainer($this->container);
3235
}

0 commit comments

Comments
 (0)