Skip to content

Commit

Permalink
[translatable] tramnslation repository is useless for personal transl…
Browse files Browse the repository at this point in the history
…ations, update readme
  • Loading branch information
l3pp4rd committed Feb 2, 2012
1 parent 0f03dcb commit 8c40921
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 3 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ objects anyway you prefere and still enjoy all features **Translatable** provide
- There were **BC** breaks introduced in **master** branch of extensions which is
based on **doctrine2.3.x** version. If you are not interested in upgrading you can
safely checkout at **2.2.x** or **2.1.x** [tag](http://github.com/l3pp4rd/DoctrineExtensions/tags).
To upgrade your source code follow the [upgrade guide](upgrade/2-3-0.md)
To upgrade your source code follow the [upgrade guide](https://github.com/l3pp4rd/DoctrineExtensions/blob/master/upgrade/2-3-0.md)
- Library now can map only **MappedSuperclass**es which would avoid generation of **ext_**
tables which might not be used. Also it provides [convinient methods](lib/Gedmo/DoctrineExtensions.php#L66)
tables which might not be used. Also it provides [convinient methods](https://github.com/l3pp4rd/DoctrineExtensions/blob/master/lib/Gedmo/DoctrineExtensions.php#L66)
to hook extension metadata drivers into metadata driver chain.
- [Example demo application](example/em.php) has a detailed configuration provided, which
explains and shows how extensions can or should be used with **Doctrine2** ORM. To install
Expand Down Expand Up @@ -128,6 +128,8 @@ To setup and run tests follow these steps:
- run: **phpunit -c tests**
- optional - run mongodb in background to complete all tests

<a name="example-demo"></a>

### Running the example:

To setup and run example follow these steps:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
use Gedmo\Translatable\TranslatableListener;
use Doctrine\ODM\MongoDB\DocumentRepository;
use Doctrine\ODM\MongoDB\Cursor;
use Doctrine\ODM\MongoDB\DocumentManager;
use Doctrine\ODM\MongoDB\UnitOfWork;
use Doctrine\ODM\MongoDB\Mapping\ClassMetadata;
use Gedmo\Tool\Wrapper\MongoDocumentWrapper;
use Gedmo\Translatable\Mapping\Event\Adapter\ODM as TranslatableAdapterODM;
use Doctrine\ODM\MongoDB\Mapping\Types\Type;
Expand All @@ -29,6 +32,17 @@ class TranslationRepository extends DocumentRepository
*/
private $listener;

/**
* {@inheritdoc}
*/
public function __construct(DocumentManager $dm, UnitOfWork $uow, ClassMetadata $class)
{
if ($class->getReflectionClass()->isSubclassOf('Gedmo\Translatable\Document\MappedSuperclass\AbstractPersonalTranslation')) {
throw new \Gedmo\Exception\UnexpectedValueException('This repository is useless for personal translations');
}
parent::__construct($dm, $uow, $class);
}

/**
* Makes additional translation of $document $field into $locale
* using $value
Expand Down
13 changes: 13 additions & 0 deletions lib/Gedmo/Translatable/Entity/Repository/TranslationRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
use Gedmo\Translatable\TranslatableListener;
use Doctrine\ORM\EntityRepository;
use Doctrine\ORM\Query;
use Doctrine\ORM\EntityManager;
use Doctrine\ORM\Mapping\ClassMetadata;
use Gedmo\Tool\Wrapper\EntityWrapper;
use Gedmo\Translatable\Mapping\Event\Adapter\ORM as TranslatableAdapterORM;
use Doctrine\DBAL\Types\Type;
Expand All @@ -29,6 +31,17 @@ class TranslationRepository extends EntityRepository
*/
private $listener;

/**
* {@inheritdoc}
*/
public function __construct(EntityManager $em, ClassMetadata $class)
{
if ($class->getReflectionClass()->isSubclassOf('Gedmo\Translatable\Entity\MappedSuperclass\AbstractPersonalTranslation')) {
throw new \Gedmo\Exception\UnexpectedValueException('This repository is useless for personal translations');
}
parent::__construct($em, $class);
}

/**
* Makes additional translation of $entity $field into $locale
* using $value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

/**
* @ORM\Table(name="article_translations")
* @ORM\Entity(repositoryClass="Gedmo\Translatable\Entity\Repository\TranslationRepository")
* @ORM\Entity
*/
class PersonalArticleTranslation extends AbstractPersonalTranslation
{
Expand Down

0 comments on commit 8c40921

Please sign in to comment.