Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
priyadi committed Nov 12, 2024
1 parent 98606b1 commit cfce7d3
Showing 1 changed file with 27 additions and 2 deletions.
29 changes: 27 additions & 2 deletions src/MapperFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -179,10 +179,14 @@ class MapperFactory

private ?TransformerRegistryInterface $transformerRegistry = null;

private ?ContainerInterface $propertyMapperLocator = null;

private ?PropertyMapperResolverInterface $propertyMapperResolver = null;

private ?ObjectMapperTableFactoryInterface $objectMapperTableFactory = null;

private ?ContainerInterface $objectMapperLocator = null;

private ?ObjectMapperResolverInterface $objectMapperResolver = null;

private ?PropertyReadInfoExtractorInterface $propertyReadInfoExtractor = null;
Expand Down Expand Up @@ -443,7 +447,7 @@ protected function getObjectMapperTransformer(): TransformerInterface
if (null === $this->objectMapperTransformer) {
$this->objectMapperTransformer = new ObjectMapperTransformer(
$this->getSubMapperFactory(),
$this->getTransformersLocator(),
$this->getObjectMapperLocator(),
$this->getObjectMapperTableFactory(),
$this->getObjectMapperResolver(),
);
Expand Down Expand Up @@ -800,6 +804,23 @@ protected function getObjectMapperTableFactory(): ObjectMapperTableFactoryInterf
return $this->objectMapperTableFactory;
}

protected function getObjectMapperLocator(): ContainerInterface
{
if ($this->objectMapperLocator !== null) {
return $this->objectMapperLocator;
}

$services = [];

foreach ($this->objectMappers as $objectMapper) {
$service = $objectMapper['service'];
$class = $service::class;
$services[$class] = $service;
}

return $this->objectMapperLocator = new ServiceLocator($services);
}

protected function getObjectMapperResolver(): ObjectMapperResolverInterface
{
if (null === $this->objectMapperResolver) {
Expand All @@ -813,6 +834,10 @@ protected function getObjectMapperResolver(): ObjectMapperResolverInterface

protected function getPropertyMapperLocator(): ContainerInterface
{
if ($this->propertyMapperLocator !== null) {
return $this->propertyMapperLocator;
}

$services = [];

foreach ($this->propertyMappers as $propertyMapper) {
Expand All @@ -821,7 +846,7 @@ protected function getPropertyMapperLocator(): ContainerInterface
$services[$class] = $service;
}

return new ServiceLocator($services);
return $this->propertyMapperLocator = new ServiceLocator($services);
}

protected function getPropertyReadInfoExtractor(): PropertyReadInfoExtractorInterface
Expand Down

0 comments on commit cfce7d3

Please sign in to comment.