-
-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Nicolas Bastien
committed
Mar 6, 2014
1 parent
2b79b3d
commit 840a3ef
Showing
6 changed files
with
75 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?php | ||
/* | ||
* This file is part of the Sonata package. | ||
* | ||
* (c) Thomas Rabaix <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
namespace Sonata\TranslationBundle\Admin\Extension\Phpcr; | ||
|
||
use Doctrine\ODM\PHPCR\DocumentManager; | ||
use Sonata\AdminBundle\Admin\AdminInterface; | ||
use Sonata\TranslationBundle\Admin\Extension\AbstractTranslatableAdminExtension; | ||
|
||
/** | ||
* @author Nicolas Bastien <[email protected]> | ||
*/ | ||
class TranslatableAdminExtension extends AbstractTranslatableAdminExtension | ||
{ | ||
/** | ||
* @param AdminInterface $admin | ||
* | ||
* @return DocumentManager | ||
*/ | ||
protected function getDocumentManager(AdminInterface $admin) | ||
{ | ||
return $admin->getModelManager()->getDocumentManager(); | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function alterObject(AdminInterface $admin, $object) | ||
{ | ||
$locale = $this->getTranslatableLocale($admin); | ||
|
||
if ($this->isTranslatable($object) && ($object->getLocale() != $locale)) { | ||
$object = $this->getDocumentManager($admin)->findTranslation($admin->getClass(), $object->getId(), $locale); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
/* | ||
* This file is part of the Sonata project. | ||
* | ||
* (c) Thomas Rabaix <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
namespace Sonata\TranslationBundle\Model\Phpcr; | ||
|
||
use Sonata\TranslationBundle\Model\TranslatableInterface as GenericTranslatableInterface; | ||
|
||
/** | ||
* This is a Convenient interface made to easily plug PHPCR admin extension on models | ||
* | ||
* @author Nicolas Bastien <[email protected]> | ||
*/ | ||
interface TranslatableInterface extends GenericTranslatableInterface | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters