Skip to content

Instantly share code, notes, and snippets.

@Bendihossan
Last active December 15, 2015 17:49
Show Gist options
  • Save Bendihossan/5299619 to your computer and use it in GitHub Desktop.
Save Bendihossan/5299619 to your computer and use it in GitHub Desktop.
Honour assets_base_urls if used
<?php
/**
* Get the RequireJS configuration options.
* @return array
*/
public function getConfiguration()
{
if ($this->useControllerForAssets && $this->container->isScopeActive('request')) {
$baseUrl = $this->container->get('request')->getBaseUrl();
$baseUrl = \ltrim($baseUrl, '/');
} else {
$baseUrl = $this->container->get('templating.helper.assets')->getUrl(\ltrim($this->baseUrl, '/'));
// remove ?version from end of URL
if (($p = strpos($baseUrl, '?')) !== false) {
$baseUrl = substr($baseUrl, 0, $p);
}
}
$config = array(
'baseUrl' => $baseUrl,
'locale' => $this->translator->getLocale(),
);
if ($this->paths !== null) {
$config['paths'] = $this->paths;
}
return array_merge($config, $this->additionalConfig);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment