2016-05-13 3 views
0

私はsymfony2とdoctrineを使っているphpアプリケーションを持っています。私は、異なるコンテンツタイプのために、ディスクリミネータマップにクラスを追加する必要があります。現在、私は弁別マップのため、次の基本抽象クラスを持っている:私がしようとすると、何らかの理由でdoctrine discriminator updateをインストールできない

<?php 

// src/Acme/UserBundle/Entity/TowelContent.php 
namespace PrintSyndicate\HubBundle\Entity; 

use Doctrine\ORM\Mapping as ORM; 
use Doctrine\ORM\Mapping\JoinTable as JoinTable; 
use Doctrine\ORM\Mapping\JoinColumn as JoinColumn; 
use Symfony\Component\Validator\Constraints as Assert; 
use PrintSyndicate\HubBundle\Entity\Content; 

/** 
* @ORM\Entity 
*/ 
class TowelContent extends Content 
{ 
    /** 
    * Validate that this is a well formated apparel front image 
    */ 
    public function validate($errors = array()) 
    { 
     //do initial validation 
     $parentValid = parent::validate($errors); 
     //check if png 
     //check sizing 
     // 
     return $parentValid; 
    } 
} 

:私は追加したい

/** 
* @ORM\Entity(repositoryClass="PrintSyndicate\HubBundle\EntityRepository\ContentRepository") 
* @ORM\InheritanceType("SINGLE_TABLE") 
* @ORM\DiscriminatorColumn(name="type", type="string") 
* * @ORM\DiscriminatorMap({ "site_content"="SiteContent", 
          "site_content_image"="SiteContentImage", 
          "site_content_carousel"="SiteContentCarousel", 
          "site_content_html"="SiteContentHtml", 
          "site_content_static_text"="SiteContentStaticText", 
          "apparel_front"="ApparelFrontContent", 
          "apparel_back"="ApparelBackContent", 
          "blanket"="BlanketContent", 
          "canvas"="CanvasContent", 
          "phone_case"="PhoneCaseContent", 
          "tablet_case"="TabletCaseContent", 
          "pillow"="PillowContent", 
          "tote"="ToteContent", 
          "poster"="PosterContent", 
          "sticker"="StickerContent", 
          "mug"="MugContent", 
          "gift_card"="GiftCardContent", 
          "collection_image"="CollectionImageContent", 
          "greeting_card"="GreetingCardContent", 
          "towel"="TowelContent" 
         }) 
* @ORM\Table(name="content", indexes={@Index(name="content_guid_index", columns={"guid"})}) 
**/ 
abstract class Content extends Model 
{ 

新しいクラスは次のようになりますこと、TowelContentクラスですPHPアプリ/コンソール教義を実行する:キャッシュ:明確なメタデータ--env = prodのアプリ/キャッシュフォルダ内のすべてのファイルを削除した後、私は次のエラー

[Doctrine\ORM\Mapping\MappingException]                                                                        
    Entity 'PrintSyndicate\HubBundle\Entity\TowelContent' has to be part of the discriminator map of 'PrintSyndicate\HubBundle\Entity\Content' to be properly mapped in the inheritance hierarchy. Alternatively you can make 'PrintSyndicate\HubBundle\Entity\TowelContent' an abstract class to avoid this exception from occurring. 

私は理解していないことということです取得します明らかに弁別者マップの一部であり、キャッシュフォルダが削除されているため、弁別者マップの一部ではないとわかりません。

また、キャッシュをクリアせずに展開しようとするとすべてのルートで次のエラーが表示されます。

Warning: require(/app/app/cache/prod/doctrine/orm/Proxies/__CG__PrintSyndicateHubBundleEntityStatus.php): failed to open stream: No such file or directory in /app/vendor/doctrine/common/lib/Doctrine/Common/Proxy/AbstractProxyFactory.php on line 209 

Fatal error: require(): Failed opening required '/app/app/cache/prod/doctrine/orm/Proxies/__CG__PrintSyndicateHubBundleEntityStatus.php' (include_path='/app/vendor/phpunit/php-file-iterator:.:/usr/share/php:/usr/share/pear') in /app/vendor/doctrine/common/lib/Doctrine/Common/Proxy/AbstractProxyFactory.php on line 209 

Fatal error: Uncaught exception 'Symfony\Component\Debug\Exception\FatalErrorException' with message 'Compile Error: require(): Failed opening required '/app/app/cache/prod/doctrine/orm/Proxies/__CG__PrintSyndicateHubBundleEntityStatus.php' (include_path='/app/vendor/phpunit/php-file-iterator:.:/usr/share/php:/usr/share/pear')' in /app/vendor/doctrine/common/lib/Doctrine/Common/Proxy/AbstractProxyFactory.php:209 Stack trace: #0 {main} thrown in /app/vendor/doctrine/common/lib/Doctrine/Common/Proxy/AbstractProxyFactory.php on line 209 

私はこの一日中壁に頭を打っています。

答えて

0

同じ問題を抱えている人のために私の場合はこれを理解しました。どういうわけか、私たちconfig_prod.ymlファイルに以下の行をコメントアウトした。これらの行をコメントアウト

doctrine: 
    orm: 
     metadata_cache_driver: apc 
     result_cache_driver: apc 
     query_cache_driver: apc 

は、問題を解決しました。

関連する問題