私はsymfony2を初めて使用し、カスタムリポジトリクラスを作成しようとしていますが、作成できませんでした。
これが私がしていることです:
- エンティティクラス(携帯電話)にアノテーションを追加しました
@ORM \ Entity(repositoryClass = "Maak \ DefaultBundle \ Entity \ MobilePhonesRepository")
MobilePhonesRepositoryで、という名前のカスタム関数を作成しました
findAllMobilePhones()
コントローラで、次を使用して関数を呼び出しました。
$ em-> getRepository('MaakDefaultBundle:MobilePhones')-> findAllMobilePhones();
しかし、私は取得しますUndefined method findAllMobilePhones()
、私はキャッシュをクリアして試しましたが、同じエラーです。なにが問題ですか?
私のリポジトリクラス:
<?php
namespace Maak\DefaultBundle\Entity;
use Doctrine\ORM\EntityRepository;
class MobilePhonesRepository extends EntityRepository
{
public function findAllMobilePhones()
{
return $this->getEntityManager()->createQuery('SELECT p FROM AcmeStoreBundle:Product p ORDER BY p.name ASC') ->getResult();
}
}