Permalink
Browse files

[translatable] tramnslation repository is useless for personal transl…

…ations, update readme
  • Loading branch information...
1 parent 0f03dcb commit 8c40921ed8d92bc972a2b15eb9aa3842e9d11762 @l3pp4rd l3pp4rd committed Feb 2, 2012
View
@@ -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
@@ -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:
@@ -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;
@@ -30,6 +33,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
*
@@ -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;
@@ -30,6 +32,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
*
@@ -6,7 +6,7 @@
/**
* @ORM\Table(name="article_translations")
- * @ORM\Entity(repositoryClass="Gedmo\Translatable\Entity\Repository\TranslationRepository")
+ * @ORM\Entity
*/
class PersonalArticleTranslation extends AbstractPersonalTranslation
{

0 comments on commit 8c40921

Please sign in to comment.