Commit 344ca25f authored by Sebastian Castro's avatar Sebastian Castro

Fixs configuration url scheme

parent a51866db
......@@ -6,6 +6,7 @@ parameters:
use_as_saas: false
# URL config
base_protocol: https
base_url: saas.localhost # my-site.com
base_path: ~ # on localhost its probably something like /GoGoCarto/web/app_dev.php
......
......@@ -57,5 +57,5 @@ services:
biopen.gogocartojs_service:
class: Biopen\GeoDirectoryBundle\Services\GoGoCartoJsService
arguments: [ "@doctrine.odm.mongoDB.document_manager", "@security.context", "@router", "@session" ]
arguments: [ "@doctrine.odm.mongoDB.document_manager", "@security.context", "@router", "@session", "%base_protocol%" ]
scope: request
......@@ -8,12 +8,13 @@ use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
class GoGoCartoJsService
{
public function __construct(DocumentManager $documentManager, SecurityContext $securityContext, $router, $session)
public function __construct(DocumentManager $documentManager, SecurityContext $securityContext, $router, $session, $base_protocol)
{
$this->odm = $documentManager;
$this->securityContext = $securityContext;
$this->router = $router;
$this->session = $session;
$this->base_protocol = $base_protocol;
}
public function getConfig()
......@@ -174,7 +175,7 @@ class GoGoCartoJsService
"data" =>
[
"taxonomy" => json_decode($taxonomyJson),
"elements" => $this->router->generate('biopen_api_elements_index', [], UrlGeneratorInterface::ABSOLUTE_URL),
"elements" => $this->getAbsolutePath('biopen_api_elements_index'),
"requestByBounds" => true,
],
];
......@@ -187,9 +188,9 @@ class GoGoCartoJsService
$result['inIframe'] = $feature->getActiveInIframe();
if ($route == 'biopen_element_edit')
$url = str_replace('fake', '', $this->router->generate('biopen_element_edit', ['id'=>'fake'], UrlGeneratorInterface::ABSOLUTE_URL));
$url = str_replace('fake', '', $this->getAbsolutePath('biopen_element_edit', ['id'=>'fake']));
elseif ($route)
$url = $this->router->generate($route, [], UrlGeneratorInterface::ABSOLUTE_URL);
$url = $this->getAbsolutePath($route);
else
$url = '';
$result['url'] = $url;
......@@ -199,4 +200,9 @@ class GoGoCartoJsService
return $result;
}
private function getAbsolutePath($route, $params = [])
{
return $this->base_protocol . ':' . $this->router->generate($route, $params, UrlGeneratorInterface::NETWORK_PATH);
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment