private function mapUrls(JsonApiTransformer $transformer, Router $router)
{
$request = Request::createFromGlobals();
$baseUrl = $request->getSchemeAndHttpHost();
$reflectionClass = new ReflectionClass($transformer);
$reflectionProperty = $reflectionClass->getProperty('mappings');
$reflectionProperty->setAccessible(true);
$mappings = $reflectionProperty->getValue($transformer);
foreach ($mappings as &$mapping) {
$mappingClass = new ReflectionClass($mapping);
$this->setUrlWithReflection($router, $mapping, $mappingClass, 'resourceUrlPattern', $baseUrl);
$this->setUrlWithReflection($router, $mapping, $mappingClass, 'selfUrl', $baseUrl);
$mappingProperty = $mappingClass->getProperty('otherUrls');
$mappingProperty->setAccessible(true);
$otherUrls = $mappingProperty->getValue($mapping);
foreach ($otherUrls as &$url) {
$url = $this->getUrlPattern($router, $url, $baseUrl);
}
$mappingProperty->setValue($mapping, $otherUrls);
$mappingProperty = $mappingClass->getProperty('relationshipSelfUrl');
$mappingProperty->setAccessible(true);
$relationshipSelfUrl = $mappingProperty->getValue($mapping);
foreach ($relationshipSelfUrl as &$urlMember) {
foreach ($urlMember as &$url) {
$url = $this->getUrlPattern($router, $url, $baseUrl);
}
}
$mappingProperty->setValue($mapping, $relationshipSelfUrl);
}
$reflectionProperty->setValue($transformer, $mappings);
}