Entityのアノテーションでハマる

Repositoryに定義した独自メソッドが呼ばれない

Undefined method 'findAllWithAreasCount2'. The method name must start with either findBy or findOneBy!

対象のEntityのアノテーションを確認すると、

@ORM\Entity()

↑この状態だと、独自Repositoryの親クラスであるEntityRepositoryを見に行ってしまう。

↓このように独自Repositoryへのパスを指定すればOK!

@ORM\Entity(repositoryClass="独自Repositoryへのパス\独自Repository")

ファイルアップロードボタンが表示されない

public $file;

↑これだけだと単なるテキストフィールドが表示されただけ。

↓このようにアノテーションを貼ることで、解決。

/**
 * @Assert\File(maxSize="6000000")
 */
public $file;

f:id:c1644:20130516155757p:plain

留意すべき点

アノテーションを変更した後は、DBに変更することを忘れずに。

$ php app/console doctrine:schema:update --force
$ php app/console doctrine:schema:update --force --env=test