无法部署条令鉴别器更新


Cannot deploy doctrine discriminator update

我有一个使用symfony2和条令的php应用程序。我需要为不同的内容类型在鉴别器映射中添加一个类。目前,我有以下鉴别器映射的基本抽象类:

/**
 * @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
// 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;
    }
}

无论出于什么原因,当我尝试运行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

任何帮助都将是惊人的,我一整天都在用头撞墙。

我已经为任何在谷歌上搜索同一问题的人找到了这一点。不知怎的,在我们的config_prod.yml文件中,以下几行被注释掉了:

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

取消这些行的注释解决了问题。