Skip to content

Commit b821b38

Browse files
authored
Add shared attribute to service definition (#914)
A service can also be shared or not shared. This information is now available in the service definition.
1 parent d013008 commit b821b38

2 files changed

Lines changed: 11 additions & 0 deletions

File tree

src/ValueObject/ServiceDefinition.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ public function __construct(
1616
private ?string $class,
1717
private bool $isPublic,
1818
private bool $isSynthetic,
19+
private bool $isShared,
1920
private ?string $alias,
2021
private array $tags
2122
) {
@@ -41,6 +42,11 @@ public function isSynthetic(): bool
4142
return $this->isSynthetic;
4243
}
4344

45+
public function isShared(): bool
46+
{
47+
return $this->isShared;
48+
}
49+
4450
public function getAlias(): ?string
4551
{
4652
return $this->alias;

src/ValueObjectFactory/ServiceMapFactory.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,10 @@ private function createServiceFromXmlAndTagsData(SimpleXMLElement $attrs, array
113113
$attrs,
114114
'synthetic'
115115
) && $attrs->synthetic instanceof SimpleXMLElement && (string) $attrs->synthetic === 'true',
116+
! (property_exists(
117+
$attrs,
118+
'shared'
119+
) && $attrs->shared instanceof SimpleXMLElement) || (string) $attrs->shared !== 'false',
116120
property_exists(
117121
$attrs,
118122
'alias'
@@ -144,6 +148,7 @@ private function createAliasServiceDefinitions(array $aliases, array $services):
144148
$services[$alias]->getClass(),
145149
$service->isPublic(),
146150
$service->isSynthetic(),
151+
$service->isShared(),
147152
$alias,
148153
[]
149154
);

0 commit comments

Comments
 (0)