Skip to content

Commit 584a719

Browse files
authored
Adding base path to messages in WebUI. (#131)
* Adding base path to messages in WebUI. This is needed for the CLI. The "full_path" was removed when redoing the metadata * Applied changes from StyleCI
1 parent dc5b6ef commit 584a719

File tree

4 files changed

+14
-1
lines changed

4 files changed

+14
-1
lines changed

Controller/WebUIController.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ public function showAction($configName, $locale, $domain)
118118
'configNames' => $configManager->getNames(),
119119
'allow_create' => $this->getParameter('php_translation.webui.allow_create'),
120120
'allow_delete' => $this->getParameter('php_translation.webui.allow_delete'),
121+
'file_base_path' => $this->getParameter('php_translation.webui.file_base_path'),
121122
]);
122123
}
123124

DependencyInjection/Configuration.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,7 @@ private function addWebUINode(ArrayNodeDefinition $root)
210210
->children()
211211
->booleanNode('allow_create')->defaultTrue()->end()
212212
->booleanNode('allow_delete')->defaultTrue()->end()
213+
->scalarNode('file_base_path')->defaultNull()->info('Base path for SourceLocation\'s. Defaults to "%kernel.project_dir%".')->end()
213214
->end()
214215
->end()
215216
->end();

DependencyInjection/TranslationExtension.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,17 @@ private function enableWebUi(ContainerBuilder $container, array $config)
149149
$container->setParameter('php_translation.webui.enabled', true);
150150
$container->setParameter('php_translation.webui.allow_create', $config['webui']['allow_create']);
151151
$container->setParameter('php_translation.webui.allow_delete', $config['webui']['allow_delete']);
152+
153+
$path = $config['webui']['file_base_path'];
154+
if (null === $path) {
155+
if ($container->hasParameter('kernel.project_dir')) {
156+
$path = $container->getParameter('kernel.project_dir');
157+
} else {
158+
$path = $container->getParameter('kernel.root_dir').'/..';
159+
}
160+
}
161+
162+
$container->setParameter('php_translation.webui.file_base_path', rtrim($path, '/').'/');
152163
}
153164

154165
/**

Resources/views/WebUI/show.html.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@
107107
{% if message.sourceLocations|length > 0 %}
108108
<ul class="location-list">
109109
{% for location in message.sourceLocations %}
110-
<li><a href="{{ location['full_path']|file_link(location['line']) }}">{{ location['path'] }} at line {{ location['line'] }} </a></li>
110+
<li><a href="{{ (file_base_path ~ location['path'])|file_link(location['line']) }}">{{ location['path'] }} at line {{ location['line'] }} </a></li>
111111
{% endfor %}
112112
</ul>
113113
{% endif %}

0 commit comments

Comments
 (0)