Skip to content

Commit 5f75b10

Browse files
committed
fix generating urls when run inside another app
1 parent acf2440 commit 5f75b10

File tree

4 files changed

+23
-14
lines changed

4 files changed

+23
-14
lines changed

CHANGELOG.md

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Changelog
2+
3+
## 3.0.1 - 2023-04-30
4+
5+
### Fixed
6+
7+
- Fix urls when run inside another app

src/Template/Index.php

+5-4
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
use Innmind\Profiler\Profile;
77
use Innmind\Filesystem\File\Content;
8-
use Innmind\Url\Url;
98
use Innmind\UrlTemplate\Template;
109
use Innmind\Html\{
1110
Node\Document,
@@ -27,11 +26,13 @@
2726

2827
final class Index
2928
{
29+
private Template $list;
3030
private Template $profile;
3131

32-
public function __construct()
32+
public function __construct(Template $list, Template $profile)
3333
{
34-
$this->profile = Template::of('/profile/{id}');
34+
$this->list = $list;
35+
$this->profile = $profile;
3536
}
3637

3738
/**
@@ -62,7 +63,7 @@ public function __invoke(Sequence $profiles): Content
6263
'header',
6364
null,
6465
Sequence::of(A::of(
65-
Url::of('/'),
66+
$this->list->expand(Map::of()),
6667
null,
6768
Sequence::of(SelfClosingElement::of(
6869
'img',

src/Template/Profile.php

+7-6
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
use Innmind\Profiler\Profile as Data;
77
use Innmind\Filesystem\File\Content;
8-
use Innmind\Url\Url;
98
use Innmind\UrlTemplate\Template;
109
use Innmind\Html\{
1110
Node\Document,
@@ -27,11 +26,13 @@
2726

2827
final class Profile
2928
{
30-
private Template $template;
29+
private Template $list;
30+
private Template $section;
3131

32-
public function __construct()
32+
public function __construct(Template $list, Template $section)
3333
{
34-
$this->template = Template::of('/profile/{id}/{section}');
34+
$this->list = $list;
35+
$this->section = $section;
3536
}
3637

3738
/**
@@ -69,7 +70,7 @@ public function __invoke(Data $profile, Maybe $active): Content
6970
null,
7071
Sequence::of(
7172
A::of(
72-
Url::of('/'),
73+
$this->list->expand(Map::of()),
7374
null,
7475
Sequence::of(SelfClosingElement::of('img', Set::of(
7576
Attribute::of('alt', 'home'),
@@ -83,7 +84,7 @@ public function __invoke(Data $profile, Maybe $active): Content
8384
'li',
8485
null,
8586
Sequence::of(A::of(
86-
$this->template->expand(Map::of(
87+
$this->section->expand(Map::of(
8788
['id', $profile->id()->toString()],
8889
['section', $section->slug()],
8990
)),

src/Web/Kernel.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,13 @@ public function __invoke(Application $app): Application
5252
Load::of($os->clock()),
5353
),
5454
)
55-
->service('innmind/profiler.listProfiles', static fn($get) => new ListProfiles(
55+
->service('innmind/profiler.listProfiles', fn($get) => new ListProfiles(
5656
$get('innmind/profiler'),
57-
new Index,
57+
new Index($this->list->template(), $this->profile->template()),
5858
))
59-
->service('innmind/profiler.showProfile', static fn($get) => new ShowProfile(
59+
->service('innmind/profiler.showProfile', fn($get) => new ShowProfile(
6060
$get('innmind/profiler'),
61-
new Profile,
61+
new Profile($this->list->template(), $this->section->template()),
6262
))
6363
->appendRoutes(
6464
fn($routes, $get) => $routes

0 commit comments

Comments
 (0)