2012-01-17 12 views
2

Gedmo Translatable ExtensionをDoctrine 2.2/Zendに統合しようとしましたが、成功せず、助けが必要でした。私はいつもこの致命的なエラーを受けています:Gedmo Doctrine 2.2/Zendの翻訳可能な統合

Uncaught exception 'Doctrine\ORM\Mapping\MappingException' with message 'Class AliasStaticPage is not a valid entity or mapped super class.' in[...]library/Doctrine/ORM/Mapping/MappingException.php:147

APCが稼働していて、Doctrine 2.2も正常に動作していました。

この

は( Best practices for setting up with annotationsと同様に)私のブートストラップです:

<?php 
use Doctrine\ORM\Mapping\Id; 
use Doctrine\ORM\Mapping as ORM; 

/** 
* @ORM\Entity 
* @ORM\Table(name="alias") 
* @ORM\InheritanceType("JOINED") 
* @ORM\DiscriminatorMap({"aliasProject" = "AliasProject",      
*     "aliasStaticPage" = "AliasStaticPage"}) 
*/ 
abstract class Alias 
{ 
/** 
* @Id 
* @ORM\Column(type="integer") 
* @ORM\GeneratedValue(strategy="AUTO") 
*/ 
private $id; 
[...] 
} 

そして、参加クラス:

<?php 
use Doctrine\ORM\Mapping\Id; 
use Doctrine\ORM\Mapping as ORM; 

/** 
* @ORM\Entity 
* @ORM\Table(name="aliasStaticPage") 
*/ 
class AliasStaticPage extends Alias 
{ 

/** 
* @ManyToOne(targetEntity="StaticPage") 
* @JoinColumns({@JoinColumn(name="staticPage_id", referencedColumnName="id")}) 
*/ 
private $staticPage; 
[...] 
} 

I

$cache = new \Doctrine\Common\Cache\ApcCache();  
    $config->setQueryCacheImpl($cache); 
    $config->setResultCacheImpl($cache); 
    $config->setMetadataCacheImpl($cache); 

    $config->setProxyNamespace('App\Proxies'); 

    $annotationReader = new Doctrine\Common\Annotations\AnnotationReader(); 

    Doctrine\Common\Annotations\AnnotationRegistry::registerAutoloadNamespace(
     'Gedmo\Mapping\Annotation', 
     '../library/DoctrineExtensions/Gedmo' 
    ); 
    Doctrine\Common\Annotations\AnnotationRegistry::registerFile(
     '../library/Doctrine/ORM/Mapping/Driver/DoctrineAnnotations.php' 
    ); 

    $chainDriverImpl = new \Doctrine\ORM\Mapping\Driver\DriverChain();  
    $annotationDriver = new Doctrine\ORM\Mapping\Driver\AnnotationDriver($annotationReader, 
      array(
      APPLICATION_PATH . '/models', 
      '../library/DoctrineExtensions/Gedmo/Translatable/Entity' 
      )); 
    $chainDriverImpl->addDriver($annotationDriver, 'Entity'); 
    $chainDriverImpl->addDriver($annotationDriver, 'Gedmo\Translatable\Entity'); 

    $config->setMetaDataDriverImpl($chainDriverImpl); 

、ここでは、クラス定義の一部でありますdoctrine-project.orgでこのアプローチを試してみました...

アイデアをお寄せいただきありがとうございます。 ...なぜ知らないこの方法は、同じオブジェクトのハッシュにライン93で\教義\ ORM \マッピング\ドライバーの\ DriverChain内主導AnnotationDriverを実装

、それだけでループ:だからここ

+0

解決しますが、私の解決策には4時間ほどで答えることができません。 – theColaKid

答えて

0

は私のソリューションです一度。だから私は2 annotationDrivers、Gedmoエンティティのための私のモデルの1つずつで、それを分割:追加のドライバの名前空間が私の名前空間に準拠していませんでした

$annotationReader = new Doctrine\Common\Annotations\AnnotationReader(); 
$annotationDriver1 = new Doctrine\ORM\Mapping\Driver\AnnotationDriver($annotationReader, array('../library/DoctrineExtensions/Gedmo/Translatable/Entity')); 
$annotationDriver2 = new Doctrine\ORM\Mapping\Driver\AnnotationDriver($annotationReader, array(APPLICATION_PATH . '/models')); 

$chainDriverImpl = new \Doctrine\ORM\Mapping\Driver\DriverChain(); 
$chainDriverImpl->addDriver($annotationDriver1, 'Gedmo\Translatable\Entity'); 
$chainDriverImpl->addDriver($annotationDriver2, 'Model'); 

次に、それはそれはクラスに見てしまったことはありません方法です。 また、すべてのManyToOneに接頭辞@ORM \を追加する必要がありました...

それはそれでした。これが同じ状況で他の人を助けることができることを願っています。

関連する問題