Skip to content

Commit

Permalink
MappingFactory in Mapper requires its own method so we can override i…
Browse files Browse the repository at this point in the history
…t when doing framework integrations
  • Loading branch information
nilportugues committed Oct 16, 2015
1 parent a3ae4e6 commit 58e19a0
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions src/Mapping/Mapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,7 @@ public function __construct(array $mappings = null)
{
if (is_array($mappings)) {
foreach ($mappings as $mappedClass) {
if (is_string($mappedClass) && class_exists($mappedClass, true)) {
$mapping = MappingFactory::fromClass($mappedClass);
} else {
$mapping = MappingFactory::fromArray($mappedClass);
}
$mapping = $this->buildMapping($mappedClass);

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

/**
* @param array $array
* @param string|array $mappedClass
*
* @return array
*/
public function setClassMap(array $array)
protected function buildMapping($mappedClass)
{
$this->classMap = $array;
return (is_string($mappedClass) && class_exists($mappedClass, true)) ?
MappingFactory::fromClass($mappedClass) :
MappingFactory::fromArray($mappedClass);
}

/**
Expand All @@ -66,4 +66,12 @@ public function getClassMap()
{
return $this->classMap;
}

/**
* @param array $array
*/
public function setClassMap(array $array)
{
$this->classMap = $array;
}
}

0 comments on commit 58e19a0

Please sign in to comment.