-1
カスタムDoctrineのORMリポジトリを作成し拡張しようとしていますが、動作させる方法が見つかりません。今のところ、これは私が持っているものです。Doctrineのリポジトリを拡張できません
元リポジトリ
//AppBundle\Repository\LocaleRepository.php
namespace AppBundle\Repository;
use Doctrine\ORM\EntityRepository;
use JMS\DiExtraBundle\Annotation as DI;
class LocaleRepository extends EntityRepository
{
protected myCustomFunction(){
}
}
拡張リポジトリ
//OfficeBundle\Repository\OfficeRepository.php
namespace OfficeBundle\Repository;
use AppBundle\Repository\LocaleRepository;
class OfficeRepository extends LocaleRepository
{
//Empty class
}
マイentiy:
namespace OfficeBundle\Entity;
// some calls to traits
use Doctrine\ORM\Mapping as ORM;
/**
* Office
*
* @ORM\Table(name="office__office")
* @ORM\Entity(repositoryClass="OfficeBundle\Repository\OfficeRepository")
*/
class Office implements TranslatableInterface{
//...
}
そして最後にコール:
$em = $this->getDoctrine()->getManager();
$this->getEntityManager();
$office=$em->getRepository('OfficeBundle:Office')->myCustomeFunction($slug);
このtrows例外:
私はOfficeRepository内myCustomeFunctionを配置する場合、それは正常に動作しますが、それはextendindリポジトリの目的をダウンさせます。また、コントローラによって読み込まれたリポジトリは正しいものであり、クラスには「OfficeBundle \ Repository \ OfficeRepository」と表示されます。
最後に私はオフィスエンティティでKNP DoctrineBehaviors(翻訳可能)を使用しています。
ありがとうございました。私はダンプです –