2016-11-22 6 views
0

Doctrine Repositoryを生成する方法についてはthis tutorialに従っています。symfony doctrineリポジトリジェネレータが間違ったクラスを作成する

マイエンティティEvent:上記のチュートリアル後

namespace AppBundle\Entity; 

use Doctrine\ORM\Mapping as ORM; 
use JMS\Serializer\Annotation as Serializer; 
use Symfony\Component\HttpKernel\Exception\HttpException; 
use Symfony\Component\Validator\Constraints as Assert; 
use Gedmo\Mapping\Annotation as Gedmo; 

/** 
* Class Event 
* @package AppBundle\Entity 
* @ORM\Entity(repositoryClass="AppBundle\Repository\EventRepository") 
* @ORM\Table(name="event") 
*/ 
class Event 
{ 
    /** 
    * @ORM\Column(type="guid") 
    * @ORM\Id 
    * @ORM\GeneratedValue(strategy="UUID") 
    */ 
    private $uuid; 

    /** 
    * @ORM\Column(type="string", length=100) 
    * @Assert\NotBlank(message="parameter ""name"" should not be blank") 
    */ 
    private $name; 

    /** 
    * @Assert\NotBlank(message="parameter ""description"" should not be blank") 
    * @ORM\Column(type="text") 
    */ 
    private $description; 

    /** 
    * @Assert\NotBlank(message="parameter ""startDate"" should not be blank") 
    * @Assert\DateTime(message="parameter ""startDate"" expects format of Y-m-d H:i:s") 
    * @ORM\Column(type="datetime") 
    * @Serializer\Type("DateTime<'Y-m-d H:i:s'>") 
    */ 
    private $startDate; 

    /** 
    * @Assert\NotBlank(message="parameter ""endDate"" should not be blank") 
    * @Assert\DateTime(message="parameter ""endDate"" expects format of Y-m-d H:i:s") 
    * @ORM\Column(type="datetime") 
    * @Serializer\Type("DateTime<'Y-m-d H:i:s'>") 
    */ 
    private $endDate; 

    // getters and setters left out 

} 

は、私が

php bin/console doctrine:generate:entities AppBundle 

私の期待は、それがリポジトリクラスEventRepositoryを生成でしょう実行します。その代わりに、この作成されます。

namespace AppBundle; 

use Symfony\Component\HttpKernel\Bundle\Bundle; 

class AppBundle extends Bundle 
{ 
} 

を私はジェネレータが生成するクラスを決定するために、repositoryClass注釈を点検するだろうと思いました。私は代わりに

php bin/console doctrine:generate:entities AppBundle:Event 

の代わりに使用しようとしました。動作しませんでした。

私はクラスを自分で書くことができますが、私は単にジェネレータを間違って使うのか、それともドキュメントを手に入れないのか不思議です。

+0

このコマンドを試す: php app/console doctrine:generate:entities AppBundle:Event –

答えて

2

あなたはここで答えを見つけることができます。

Link to answer

をすでに repositoryClassマッピングを追加する前に、あなたのエンティティクラスを生成している場合は、自分でクラスを作成する必要があります。 幸いにも、それはかなり簡単です。バンドルの リポジトリディレクトリにクラスを作成し、それが Doctrine \ ORM \ EntityRepositoryまで拡張されていることを確認してください。クラスを作成したら、 エンティティを照会するメソッドを追加できます。

関連する問題