Skip to content

Commit

Permalink
add sf4 support (#320)
Browse files Browse the repository at this point in the history
  • Loading branch information
cdaguerre authored and Gilles Gauthier committed May 7, 2018
1 parent 0135ac6 commit 4825bc5
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 7 deletions.
6 changes: 3 additions & 3 deletions Controller/TranslationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function overviewAction()

$stats = $this->get('lexik_translation.overview.stats_aggregator')->getStats();

return $this->render('LexikTranslationBundle:Translation:overview.html.twig', array(
return $this->render('@LexikTranslationBundle/Translation/overview.html.twig', array(
'layout' => $this->container->getParameter('lexik_translation.base_layout'),
'locales' => $this->getManagedLocales(),
'domains' => $storage->getTransUnitDomains(),
Expand All @@ -49,7 +49,7 @@ public function gridAction()
$tokens = $this->get('lexik_translation.token_finder')->find();
}

return $this->render('LexikTranslationBundle:Translation:grid.html.twig', array(
return $this->render('@LexikTranslationBundle/Translation/grid.html.twig', array(
'layout' => $this->container->getParameter('lexik_translation.base_layout'),
'inputType' => $this->container->getParameter('lexik_translation.grid_input_type'),
'autoCacheClean' => $this->container->getParameter('lexik_translation.auto_cache_clean'),
Expand Down Expand Up @@ -102,7 +102,7 @@ public function newAction(Request $request)
return $this->redirect($this->generateUrl($redirectUrl));
}

return $this->render('LexikTranslationBundle:Translation:new.html.twig', array(
return $this->render('@LexikTranslationBundle/Translation/new.html.twig', array(
'layout' => $this->container->getParameter('lexik_translation.base_layout'),
'form' => $form->createView(),
));
Expand Down
2 changes: 1 addition & 1 deletion DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function getConfigTreeBuilder()
->children()
->scalarNode('base_layout')
->cannotBeEmpty()
->defaultValue('LexikTranslationBundle::layout.html.twig')
->defaultValue('@LexikTranslationBundle/layout.html.twig')
->end()

->arrayNode('fallback_locale')
Expand Down
17 changes: 16 additions & 1 deletion DependencyInjection/LexikTranslationExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Symfony\Component\Config\Definition\Processor;
use Symfony\Component\Config\Resource\DirectoryResource;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface;
use Symfony\Component\DependencyInjection\Reference;
use Symfony\Component\DependencyInjection\Parameter;
use Symfony\Component\DependencyInjection\Definition;
Expand All @@ -23,7 +24,7 @@
*
* @author Cédric Girard <[email protected]>
*/
class LexikTranslationExtension extends Extension
class LexikTranslationExtension extends Extension implements PrependExtensionInterface
{
/**
* {@inheritdoc}
Expand Down Expand Up @@ -131,6 +132,19 @@ public function buildCacheCleanListenerDefinition(ContainerBuilder $container, $
$container->setDefinition('lexik_translation.listener.clean_translation_cache', $listener);
}

public function prepend(ContainerBuilder $container)
{
if (!$container->hasExtension('twig')) {
return;
}

$container->prependExtensionConfig('twig', [
'paths' => [
'%kernel.project_dir%/vendor/lexik/translation-bundle/Resources/views' => 'LexikTranslationBundle'
]
]);
}

/**
* Build the 'lexik_translation.translation_storage' service definition.
*
Expand Down Expand Up @@ -182,6 +196,7 @@ protected function buildTranslationStorageDefinition(ContainerBuilder $container
$storageDefinition = new Definition();
$storageDefinition->setClass($container->getParameter(sprintf('lexik_translation.%s.translation_storage.class', $storage)));
$storageDefinition->setArguments($args);
$storageDefinition->setPublic(true);

$container->setDefinition('lexik_translation.translation_storage', $storageDefinition);
}
Expand Down
4 changes: 2 additions & 2 deletions Resources/views/Translation/grid.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
{% block lexik_content %}
<div class="container">
{% block lexik_toolbar %}
{% include 'LexikTranslationBundle:Translation:_gridToolbar.html.twig' %}
{% include '@LexikTranslationBundle/Translation/_gridToolbar.html.twig' %}
{% endblock lexik_toolbar %}

{% block lexik_data_grid %}
{% include 'LexikTranslationBundle:Translation:_ngGrid.html.twig' %}
{% include '@LexikTranslationBundle/Translation/_ngGrid.html.twig' %}
{% endblock lexik_data_grid %}
</div>
{% endblock %}
Expand Down

0 comments on commit 4825bc5

Please sign in to comment.