Skip to content

Commit 58e19a0

Browse files
committed
MappingFactory in Mapper requires its own method so we can override it when doing framework integrations
1 parent a3ae4e6 commit 58e19a0

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

src/Mapping/Mapper.php

+16-8
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,7 @@ public function __construct(array $mappings = null)
3333
{
3434
if (is_array($mappings)) {
3535
foreach ($mappings as $mappedClass) {
36-
if (is_string($mappedClass) && class_exists($mappedClass, true)) {
37-
$mapping = MappingFactory::fromClass($mappedClass);
38-
} else {
39-
$mapping = MappingFactory::fromArray($mappedClass);
40-
}
36+
$mapping = $this->buildMapping($mappedClass);
4137

4238
if (false === empty($this->aliasMap[$mapping->getClassAlias()])) {
4339
throw new MappingException(
@@ -52,11 +48,15 @@ public function __construct(array $mappings = null)
5248
}
5349

5450
/**
55-
* @param array $array
51+
* @param string|array $mappedClass
52+
*
53+
* @return array
5654
*/
57-
public function setClassMap(array $array)
55+
protected function buildMapping($mappedClass)
5856
{
59-
$this->classMap = $array;
57+
return (is_string($mappedClass) && class_exists($mappedClass, true)) ?
58+
MappingFactory::fromClass($mappedClass) :
59+
MappingFactory::fromArray($mappedClass);
6060
}
6161

6262
/**
@@ -66,4 +66,12 @@ public function getClassMap()
6666
{
6767
return $this->classMap;
6868
}
69+
70+
/**
71+
* @param array $array
72+
*/
73+
public function setClassMap(array $array)
74+
{
75+
$this->classMap = $array;
76+
}
6977
}

0 commit comments

Comments
 (0)