2011-03-18 134 views
0

我該怎麼做? 我嘗試運行:自動生成註釋

app/console doctrine:generate:entities BlogWebBundle 

但我在這個例子中得到無類註釋( 「@orm ......」 在評論)
http://symfony.com/doc/2.0/book/doctrine/orm/overview.html

// Sensio/HelloBundle/Entity/User.php 
namespace Sensio\HelloBundle\Entity; 

/** 
* @orm:Entity 
*/ 
class User 
{ 
    /** 
    * @orm:Id 
    * @orm:Column(type="integer") 
    * @orm:GeneratedValue(strategy="AUTO") 
    */ 
    protected $id; 

    /** 
    * @orm:Column(type="string", length="255") 
    */ 
    protected $name; 
} 

我有這個YAML

Blog\WebBundle\Entity\Posts: 
    type: entity 
    table: posts 
    fields: 
    id: 
     id: true 
     type: integer 
     unsigned: false 
     nullable: false 
     generator: 
     strategy: IDENTITY 
    title: 
     type: string 
     length: 255 
     fixed: false 
     nullable: false 
    content: 
     type: text 
     nullable: false 
    uid: 
     type: integer 
     unsigned: false 
     nullable: false 
    lifecycleCallbacks: { } 

而實體生成:

<?php 

namespace Blog\WebBundle\Entity; 

/** 
* Blog\WebBundle\Entity\Posts 
*/ 
class Posts 
{ 
    /** 
    * @var integer $id 
    */ 
    private $id; 

    /** 
    * @var string $title 
    */ 
    private $title; 

    /** 
    * @var text $content 
    */ 
    private $content; 

    /** 
    * @var integer $uid 
    */ 
    private $uid; 


    /** 
    * Get id 
    * 
    * @return integer $id 
    */ 
    public function getId() 
    { 
     return $this->id; 
    } 

    /** 
    * Set title 
    * 
    * @param string $title 
    */ 
    public function setTitle($title) 
    { 
     $this->title = $title; 
    } 

    /** 
    * Get title 
    * 
    * @return string $title 
    */ 
    public function getTitle() 
    { 
     return $this->title; 
    } 

    /** 
    * Set content 
    * 
    * @param text $content 
    */ 
    public function setContent($content) 
    { 
     $this->content = $content; 
    } 

    /** 
    * Get content 
    * 
    * @return text $content 
    */ 
    public function getContent() 
    { 
     return $this->content; 
    } 

    /** 
    * Set uid 
    * 
    * @param integer $uid 
    */ 
    public function setUid($uid) 
    { 
     $this->uid = $uid; 
    } 

    /** 
    * Get uid 
    * 
    * @return integer $uid 
    */ 
    public function getUid() 
    { 
     return $this->uid; 
    } 
} 

回答

0

您可以編輯vendor/symfony/src/Symfony/Bundle/DoctrineBundle/Command/DoctrineCommand.php

變化$entityGenerator->setGenerateAnnotations(false);true

1

爲什麼您希望實體在您已經在YAML文檔中創建映射時進行註釋。我想也許這就是爲什麼它不會將註釋添加到您生成的實體中?

(我不知道是肯定的,我不會生成我的實體)

+0

對於看不到DB結構或YML文件..但我已經修復它,通過添加一些像這樣的'$ this-> setAnnotations(true)'在發生器中 – azat 2011-03-24 06:51:55