Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 2c3d666

Browse files
Benoit Viguierondrejmirtes
Benoit Viguier
authored andcommitted
Support for alias to inlined service
1 parent d530cfe commit 2c3d666

File tree

3 files changed

+20
-2
lines changed

3 files changed

+20
-2
lines changed

‎src/Symfony/XmlServiceMapFactory.php‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,11 @@ public function create(): ServiceMap
4848
}
4949

5050
$service = new Service(
51-
strpos((string) $attrs->id, '.') === 0 ? substr((string) $attrs->id, 1) : (string) $attrs->id,
51+
$this->cleanServiceId((string) $attrs->id),
5252
isset($attrs->class) ? (string) $attrs->class : null,
5353
isset($attrs->public) && (string) $attrs->public === 'true',
5454
isset($attrs->synthetic) && (string) $attrs->synthetic === 'true',
55-
isset($attrs->alias) ? (string) $attrs->alias : null
55+
isset($attrs->alias) ? $this->cleanServiceId((string) $attrs->alias) : null
5656
);
5757

5858
if ($service->getAlias() !== null) {
@@ -79,4 +79,9 @@ public function create(): ServiceMap
7979
return new DefaultServiceMap($services);
8080
}
8181

82+
private function cleanServiceId(string $id): string
83+
{
84+
return strpos($id, '.') === 0 ? substr($id, 1) : $id;
85+
}
86+
8287
}

‎tests/Symfony/DefaultServiceMapTest.php‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,17 @@ static function (?Service $service): void {
113113
self::assertSame('withClass', $service->getAlias());
114114
},
115115
];
116+
yield [
117+
'aliasForInlined',
118+
static function (?Service $service): void {
119+
self::assertNotNull($service);
120+
self::assertSame('aliasForInlined', $service->getId());
121+
self::assertNull($service->getClass());
122+
self::assertFalse($service->isPublic());
123+
self::assertFalse($service->isSynthetic());
124+
self::assertSame('inlined', $service->getAlias());
125+
},
126+
];
116127
}
117128

118129
}

‎tests/Symfony/container.xml‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,5 +41,7 @@
4141
<service id="public" class="Foo" public="true"></service>
4242
<service id="synthetic" class="Foo" synthetic="true"></service>
4343
<service id="alias" class="Bar" alias="withClass"></service>
44+
<service id=".inlined"></service>
45+
<service id="aliasForInlined" alias=".inlined"></service>
4446
</services>
4547
</container>

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /