Skip to content

Commit

Permalink
Merge cf82623 into 92c67e5
Browse files Browse the repository at this point in the history
  • Loading branch information
EmmanuelVella committed Aug 25, 2017
2 parents 92c67e5 + cf82623 commit 7f26e35
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
22 changes: 22 additions & 0 deletions Admin/Extension/Phpcr/TranslatableAdminExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,28 @@
namespace Sonata\TranslationBundle\Admin\Extension\Phpcr;

use Doctrine\ODM\PHPCR\DocumentManager;
use Doctrine\ODM\PHPCR\Translation\LocaleChooser\LocaleChooser;
use Sonata\AdminBundle\Admin\AdminInterface;
use Sonata\AdminBundle\Datagrid\ProxyQueryInterface;
use Sonata\TranslationBundle\Admin\Extension\AbstractTranslatableAdminExtension;
use Sonata\TranslationBundle\Checker\TranslatableChecker;

/**
* @author Nicolas Bastien <nbastien.pro@gmail.com>
*/
class TranslatableAdminExtension extends AbstractTranslatableAdminExtension
{
/**
* @var LocaleChooser
*/
private $localeChooser;

public function __construct(TranslatableChecker $translatableChecker, LocaleChooser $localeChooser)
{
parent::__construct($translatableChecker);
$this->localeChooser = $localeChooser;
}

/**
* {@inheritdoc}
*/
Expand All @@ -43,6 +57,14 @@ public function alterObject(AdminInterface $admin, $object)
}
}

/**
* {@inheritdoc}
*/
public function configureQuery(AdminInterface $admin, ProxyQueryInterface $query, $context = 'list')
{
$this->localeChooser->setLocale($this->getTranslatableLocale($admin));
}

/**
* @param AdminInterface $admin
*
Expand Down
1 change: 1 addition & 0 deletions Resources/config/service_phpcr.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<service id="sonata_translation.admin.extension.phpcr_translatable" class="%sonata_translation.admin.extension.phpcr_translatable.class%">
<tag name="sonata.admin.extension"/>
<argument type="service" id="sonata_translation.checker.translatable"/>
<argument type="service" id="doctrine_phpcr.odm.locale_chooser"/>
</service>
</services>
</container>

0 comments on commit 7f26e35

Please sign in to comment.